I am trying to develop a simple text based user interface which runs some gdb commands. I want to user to be able to set and break/trace point at a certain area of the code and run some debug commands.
I want to user to enter the function which needs to be debugged. I then take this function name and print out the source code of the function, then ask the user to select which line of code at which to set the break/trace point. At the moment, using the disassemble command I can print out the memory addresses for the user, but i want to print the actual source code instead.
Can this be done in gdb?
Currently:
Dump of assembler code for function test_function:
0x03800f70 <test_function+0>: push %ebp
0x03800f71 <test_function+1>: mov %esp,%ebp
0x03800f73 <test_function+3>: sub $0x48,%esp
What I want:
void main()
{
printf("Hello World\n");
}
Thanks!
EDIT: I'm getting this:
(gdb) list myFunction
941 directory/directory_etc/sourcefile.c: No such file or directory.
in directory/directory_etc/sourcefile.c
then i tried specifying linenum:
(gdb) list directory/directory_etc/sourcefile.c:941
936 in directory/directory_etc/sourcefile.c
So the behaviour is similar to what you are describing, but "list filename:linenum" still isnt working
Thank you!