0

I am debugging a system which consist of a kernel and some user programs and I want to trace one of these user programs. The problem is they are all loaded at the same virtual address; so that when I set a breakpoint at an address; it gets hit when the execution passes by this address in any of my user programs. I know that one way to solve it would be to load them in different address spaces, but I would like to avoid it if there is a better way...

I use qemu to emulate x86 architecture in order to run the system (Kernel + user code). In order to debug, I use an external gdb client which connects to gdbserver running on qemu.

Mahouk
  • 902
  • 9
  • 28
  • How do you set your breakpoints ? What architecture are you using ? What system is it (linux-based ?) ? Default breakpoints with gdb should be code-dependent, and not address-dependent. – ElderBug Feb 09 '16 at 13:53
  • As presented, this has nothing to do with C. The solution depends on things you have not provided. What does the development system you are using provide? What does its documentation say? – ryyker Feb 09 '16 at 14:31
  • To set a breakpoint i do, break *address. – Mahouk Feb 09 '16 at 15:47
  • @ryyker You are right, it is not specific to c; I updated the post. C is the language I am programming in – Mahouk Feb 09 '16 at 15:49
  • You can attach [break conditions](https://sourceware.org/gdb/onlinedocs/gdb/Conditions.html#Conditions) to a breakpoint, and check the values of registers and memory locations to determine whether to stop. In your kernel, for example, there might be a way to distinguish the process by its command name or the name of a file it uses, contained in some kernel structures. – Mark Plotnick Feb 09 '16 at 16:52
  • Oh yes, very good idea! I will dig this way. As you say, the process' command name is a good mean to distinguish it from others. Thanks Mark – Mahouk Feb 10 '16 at 00:04

0 Answers0