Simple GDB case

Source: Internet
Author: User

To be added ... gdb a.out [inferior 1 (Process 9718) exited with code] (GDB) listline number is out of range; T.C has lines.       (GDB) List one #include2 char foo (char *s) 3 {4 char *c=s;5 return * (c+2); 6}7 int main () 8 {9 Char arr[5]= "abc\n";Ten char B=foo (arr);(gdb) One by one printf ("%c\n", b), printf ("%s\n", arr); 1314} (GDB) Disass/mdump of Assembler code for function Main:8 {0x08048449 <+0>: Push? p 0x0804844a <+1>: mov%esp ,? p 0x0804844c <+3>: and $0xfffffff0,%esp 0x0804844f <+6>: Sub $0x20,%esp 9 char arr   [5]= "abc\n"; 0x08048452 <+9>: Movl $0xa636261, 0x1a (%ESP)0x0804845a <+17>: Movb $0x0,0x1e (%ESP) char B=foo (arr);=> 0x0804845f <+22>: Lea 0x1a (% ESP),? x //eip0x08048463 <+26>: mov x, (%ESP) 0x08048466 <+29>: Call 0x8048434 0x0804846b <+34>: mov %al,0x1f (%ESP) (GDB) Info registers Espesp 0xbfffefb00xbfffefb0#another Shell[email protected]:~> echo $ (( 0xbfffefb0+0X1A)) 3221221322[Email protected]:~> echo ' obase=16;base=10; 3221221322' | Bc BFFFEFCA(GDB) x/s 0XBFFFEFCA0XBFFFEFCA: " abc\n"//find the "abc\n"(GDB)   gdb) help Catchset catchpoints to catch events. list of catch subcommands: catch assert--CATC H failed Ada Assertionscatch catch--Catch an Exceptioncatch exception--catch Ada exceptionscatch exec--catch calls T o Execcatch Fork--catch calls to Forkcatch syscall--catch system calls by their names and/or numberscatch throw--Cat Ch an exceptioncatch vfork--Catch calls to Vfork type ' help catch ' followed by CATCH subcommand name For full Documentation. Type "Apropos word" to search for commands related to "word". Command name abbreviations is allowed if unambiguous. (GDB)   (GDB) info breakpoints num     type            disp Enb Address    what7       breakpoint      keep y   0x08048440 in foo                                              at t.c:5         Breakpoint already hit 1 time8       catchpoint     keep y               syscall ""  9        breakpoint     keep y    exception catch10       catchpoint     keep y               fork (GDB)   DisableBreakpoints 7 (GDB) condition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.