除錯toybox

摩斯电码發表於2024-11-28

官網

  • https://landley.net/toybox/

下載

toybox-0.8.9.tar.gz

編譯

export CFLAGS=-g
make

除錯

$ gdb --args ./generated/unstripped/toybox ls

GNU gdb (Ubuntu 10.2-0ubuntu1~20.04~1) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./generated/unstripped/toybox...
(gdb) start
Temporary breakpoint 1 at 0x126f0: file main.c, line 279.
Starting program: /vol_8t/work/Perf_issue/toybox/toybox-0.8.9/generated/unstripped/toybox ls

Temporary breakpoint 1, main (argc=2, argv=0x7fffffffda28) at main.c:279
279     {
(gdb) l
274       }
275       xputc('\n');
276     }
277
278     int main(int argc, char *argv[])
279     {
280       int i;
281
282       for (i = 0; i < argc; i++)
283           printf("argv[%d] = %s\n", i, argv[i]);
(gdb)

相關文章