Skip to content
New issue

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

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

Already on GitHub? # to your account

Can't get gdb to display C code #171

Open
nbosio1001 opened this issue Mar 6, 2023 · 1 comment
Open

Can't get gdb to display C code #171

nbosio1001 opened this issue Mar 6, 2023 · 1 comment

Comments

@nbosio1001
Copy link

nbosio1001 commented Mar 6, 2023

I am working on primes.c and I can't get my gdb environment setup so I can debug the code visually. I have the same .gdbinit.tmpl-riscv file and put $U/_primes\ in my Makefile. I am also running on a Raspberry Pi OS.

I run make qemu-gdb and then run gdb-multiarch user/_primes. After I run lay next, press enter and get the gdb environment in the picture.

image

@meighti
Copy link

meighti commented Mar 27, 2023

When you run make qemu-gdb, you are debugging the kernel, not user processes like user/_primes.

You might want to take a look at trampoline.S, which has a 'sret' instruction for returning to user mode. I think after 'sret' you won't be able to debug into user process and you will get back to gdb once you are back somewhere in the kernel, (probably via a syscal or timer interrupt).

In GDB, use "b trap.c:128" to break before jumping to userret. Then use "si" to step by instruction, until you reach to 'sret'. after that you will see that GDB sill not step from supervisor mode into user mode.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants