Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

Abridge GDB Commands

okk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Abridge GDB Commands

okk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Abridge gdb commands-

@start gdb
$gdb executable-file OR $ gdb

@ help of a command
gdb) help (general class help) gdb) h disas (about disassemble
command)
gdb) h b (about breakpoints) gdb) h list (about listcommand)

@ disassemble code(may use /r )


gdb)disas start-address,end-address (shows assembly code staring address to
given end address)
gdb)disas start-address, +length (shows staring address to given length,
length in bytes *4)

gdb)disas _start (dissemble from lable _start)


gdb)disas/r 0x10074,0x100c0 (dissembles from staring address upto given end
address)

@ list source file


gdb)l (list from starting)
gdb)l start,last line number (list from starting, upto given last line)

@ set, display delete breakpoints (line number of source-file,least is first


executable)
gdb)b sourcefilename:line (set break point at n th statement of source)
gdb)b n (set break point at source line number n)
gdb)b *address (set break point at given address, shown by disas )
gdb)i b (show all breakpoints )
gdb)clear line-num (clear breakpoint at line number )
gdb)d n (delete breakpoint n )

@run program
gdb)r (run till end , or next breakpoint) use c -continue between
breakpoints
gdb)c n (run continue skipping n-1 breakpoints)
gdb)s (run next source line)
gdb)si n (run next n machine instruction)
gdb)ni (run next machine instruction,including function)
gdb)n n (run next n source instruction,including function)
gdb)where (shows the source file line number currently to be executed next)

@set value
gdb)set variable=exp ; set address=val ((assign value at address of
val )
gdb)set $cpsr=0x80000010 ( flag set)
gdb)set $pc=0x10088 (pc changed to given address, like jump)
gdb)set $r1=&val (assign address of val to r1) or set $r1=5 (assign value to
r1)
gdb set {int}0x201bc=0x11223344 (update memory contents/instruction)
set *(int *)0x201bc=0x11223344 (update memory contents/change instruction)
set {char[3]}0x201bc ="AA";(gdb) x/x 0x201bc :0x42004141
set {char[4]}0x201bc ="AAB";(gdb)x/x 0x201bc :0x00424141
set *(char *)0x8074=0x88 ; change a byte

@dispaly register value


gdb)i r (show all registers)
gdb)i all (show all registers including)
gdb)i r r1 r2 sp lr pc cpsr (show values of specified registers only)

@print value
gdb)format p/f exp
where f is type x(hexa), d(decimal,default),u(unsigned
decimal),o(octal),t(binary),a(address),c(character),f(float)
gdb)p $r1 (value in r1 in decimal) gdb)p/x $pc (value in r15 in hex)
gdb)p/t $cpsr (value in cpsr in binary) gdb)p/x &val (address of val
in hex)

@examine memory
gdb)format x/nuf exp ; n- number of; f-format as given in print
where u is SIZE b(byte), h(half word),w(word),g(giant),o(128-bit),s(null
terminated string),i(machine inst, default)
gdb)x 0x10074 (show machine instruction at given address)
gdb)x/4i 0x10074 (4 machine instructions at given address) x/4i $pc (4
inst from current pc)
gdb)x/16x 0x10074 (show 16 words from given address)
gdb)x/6 $sp (6 words in memory pointed by sp onwards) can use +/- number
with register
gdb)x/x &var (display address and value of variable)
gdb)x/2x &_start( display memory contents 2 words in hex starting from label
_start)
gdb) x/s 0x80c2 (shows the string starting from given address)

@quit gdb
gdb)q
ref:https://sourceware.org/gdb/current/onlinedocs/gdb/

You might also like