Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GDB stub for remote debugging #74

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = cnfa
url = https://github.com/cntools/cnfa
shallow = true
[submodule "mini-gdbstub"]
path = mini-gdbstub
url = https://github.com/RinHizakura/mini-gdbstub
shallow = true
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ OBJS := \

deps := $(OBJS:%.o=.%.o.d)

GDBSTUB_LIB := mini-gdbstub/build/libgdbstub.a
LDFLAGS += $(GDBSTUB_LIB)
mini-gdbstub/Makefile:
git submodule update --init $(dir $@)
$(GDBSTUB_LIB): mini-gdbstub/Makefile
$(MAKE) -C $(dir $<)
$(OBJS): $(GDBSTUB_LIB)

$(BIN): $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)
Expand Down Expand Up @@ -152,6 +160,7 @@ build-image:

clean:
$(Q)$(RM) $(BIN) $(OBJS) $(deps)
$(Q)$(MAKE) -C mini-gdbstub clean

distclean: clean
$(Q)$(RM) riscv-harts.dtsi
Expand Down
8 changes: 8 additions & 0 deletions device.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,11 @@ bool virtio_snd_init(virtio_snd_state_t *vsnd);

/* memory mapping */
typedef struct {
bool debug;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider initializing debug flag default value

Consider initializing the debug flag to a default value since it's a boolean field in the emu_state_t struct. This helps prevent undefined behavior if the field is accessed before being explicitly set.

Code suggestion
Check the AI-generated fix before applying
Suggested change
bool debug;
bool debug = false;

Code Review Run #8e516e


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

bool stopped;
uint32_t *ram;
uint32_t *disk;
vm_t vm;
plic_state_t plic;
u8250_state_t uart;
#if SEMU_HAS(VIRTIONET)
Expand All @@ -376,4 +378,10 @@ typedef struct {
#if SEMU_HAS(VIRTIOSND)
virtio_snd_state_t vsnd;
#endif

uint32_t peripheral_update_ctr;

/* The fields used for debug mode */
bool is_interrupted;
int curr_cpuid;
} emu_state_t;
Loading
Loading