You would like to disasemble a program or function with gdb
To disassemble you first need to run gdb with the program as a parameter. Now you can use the command disas to start showing assembler code for certain functions.
(gdb) disas main
Dump of assembler code for function main:
0x00401d98 <main+0>: push %ebp
0x00401d99 <main+1>: mov $0x10,%eax
0x00401d9e <main+6>: mov %esp,%ebp
0x00401da0 <main+8>: push %ebx
0x00401da1 <main+9>: sub $0x64,%esp
0x00401da4 <main+12>: and $0xfffffff0,%esp
0x00401da7 <main+15>: call 0x407cb4 <_alloca>
0x00401dac <main+20>: call 0x401f48 <__main>
0x00401db1 <main+25>: call 0x40800c <GetCommandLineA@0>
0x00401db6 <main+30>: mov %eax,%ebx
0x00401db8 <main+32>: lea -0x58(%ebp),%eax
0x00401dbb <main+35>: mov %eax,(%esp)
0x00401dbe <main+38>: call 0x408004 <GetStartupInfoA@4>
0x00401dc3 <main+43>: sub $0x4,%esp
0x00401dc6 <main+46>: test %ebx,%ebx
0x00401dc8 <main+48>: jne 0x401dd0 <main+56>
0x00401dca <main+50>: jmp 0x401e6c <main+212>
Here you can see what the assembler code of the main fucntion looks like.
About the Author
Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.