I compiled a helloworld program in Ubuntu 20.04 LTS, I want to debug it in Simics, I set a breakpoint on main
, but Simics won't break.
I tried compile it inside QSP-x86, that binary would work.
From my understanding, Simics could break on main
no matter what the binary's original build environment was. I don't know why it doesn't break in my case.
Here is my steps:
step 1: compile helloworld in Ubuntu 20.04
$ cat a.c
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}
$ gcc -g a.c
step 2: copy a.out
to Simics project root and upload it into QSP-x86 (firststeps.simics)
step 3:
simics> enable-debugger
simics> add-symbol-file a.out
simics> bp.source_location.break main
simics> run
running>
step 4: run a.out
from the simulated serial console
Expected: the breakpoint on main
should be triggered
But got: no breakpoint triggered at all
Looks like this is running inside a Linux process on the target. To debug software at the user level, you need to enable OS awareness so that the debugger can track when that particular software is running. ASLR should not matter for user-level processes when OS awareness is active, as the virtual addresses used by the code are the same in any case, even if the physical page is moved.
Some thing like:
simics> enable-tracker
simics> board.software.enable-tracker
simics> add-symbol-file prog.elf context-query = "name='prog.elf'"
simics> bp.source_location.break main context-query = "name='prog.elf'"
simics> bp.list
simics> bp.show <<bp number>>
simics> board.serconsole.con.input "prog.elf\n"
simics> r
...
This should stop when main runs in the program.
simics> bt
simics> list
Mandatory mark #IAmIntel