Reputation: 85
I am very sorry, if my English is bad. This problem is getting me for days. I have a simple C source code with a sub function which I am examining. First I am creating the .out file with gcc. This file I am examining with GDB. But if I want to disassemble the called function I always get an error message from gdb. Prolog:
unix@unix-laptop:~/booksrc $ gcc -g stack_example.c
unix@unix-laptop:~/booksrc $ gdb -q ./a.out
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) disass main
Dump of assembler code for function main:
0x08048357 <main+0>: push %ebp
0x08048358 <main+1>: mov %esp,%ebp
0x0804835a <main+3>: sub $0x18,%esp
0x0804835d <main+6>: and $0xfffffff0,%esp
0x08048360 <main+9>: mov $0x0,%eax
0x08048365 <main+14>: sub %eax,%esp
0x08048367 <main+16>: movl $0x4,0xc(%esp)
0x0804836f <main+24>: movl $0x3,0x8(%esp)
0x08048377 <main+32>: movl $0x2,0x4(%esp)
0x0804837f <main+40>: movl $0x1,(%esp)
0x08048386 <main+47>: call 0x8048344 <test_function>
0x0804838b <main+52>: leave
0x0804838c <main+53>: ret
End of assembler dump.
(gdb) disass test_function()
You can't do that without a process to debug.
(gdb)
Do you have an idea for the reason of the error? I have already used google but I can't find anything to solve the problem. I also searched for the instructions to be sure that the syntax is right. http://visualgdb.com/gdbreference/commands/disassemble
Thanks for reading, Intersect!
Upvotes: 1
Views: 1831
Reputation: 25593
Maybe the function isn't there because it was inlined during compilation. I had never seen your error message before, sorry.
Please try to compile with the following additional flags:
-O0 -g
You can also see all function start addresses with:
objdump -x <filename>
This gives you a list of symbols in your executable file which includes all the start points of functions.
You can also disassemble your code with:
objdump -d <filename>
Upvotes: 0
Reputation: 1
The syntax (of the gdb
command) is disass
function-name so you should type
disass test_function
Read the genuine GDB documentation.
But you typed wrongly ; then ending parenthesis are wrong.disass test_function()
Be sure that you compiled your source code with gcc -Wall -g
At last, you could ask gcc
to output an assembler file. Try for instance to compile your source.c
file with
gcc -O1 -S -fverbose-asm source.c
(you could omit the -O1
or replace it with -g
if you wanted to)
then look with an editor (or some pager) into the generated source.s
assembly file.
Upvotes: 2