On Fri, 10 Jul 2015, Andrew Haley wrote: > On 07/10/2015 06:03 PM, xparmenides wrote: > > 1. To debug at assembly level, the steps to compile is so complicated > > that is somewhat impractical. Is there any way make the process easily? > > Yes. Compile your program C in the normal way, then: > if you compile your c files with gcc -S --verbose-asm file.c you will get much more readable assembly output than if you use the normal disasseble output within gcc. e.g: <snip> devkmsg_poll: pushq %rbp # movl $40, %eax #, D.38788 movq %rsp, %rbp #, pushq %rbx # subq $8, %rsp #, movq 208(%rdi), %rbx # file_3(D)->private_data, user testq %rbx, %rbx # user je .L27 #, testq %rsi, %rsi # wait je .L28 #, movq (%rsi), %rax # wait_7(D)->_qproc, D.41321 testq %rax, %rax # D.41321 <snip> telling you what is being put in what register and what intermediate values gcc added in (like D.41321 here) furhter there are methods to interleave C and assembly code - atleast in the linux kernel build system make path/file.lst will generate the interleaved assembly/C files e.g. <snip> static ssize_t msg_print_ext_body(char *buf, size_t size, char *dict, size_t dict_len, char *text, size_t text_len) { ffffffff81f40f55: 41 81 fc 00 00 02 00 cmp $0x20000,%r12d char *p = buf, *e = buf + size; size_t i; /* escape non-printable characters */ for (i = 0; i < text_len; i++) { ffffffff81f40f5c: 76 44 jbe ffffffff81f40fa2 <setup_log_buf+0x94> ffffffff81f40f5e: be 00 10 00 00 mov $0x1000,%esi return scnprintf(buf, size, "%u,%llu,%llu,%c;", (msg->facility << 3) | msg->level, seq, ts_usec, cont); } <snip> see the Linux kernel scripts/makelst for more. notably when debugging optimized code this output makes it much easier to read the disassembler output in gdb. thx! hofrat