SlideShare a Scribd company logo
1 of 30
Download to read offline
GDB
w służbie programisty
Łukasz Majczak
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
O czym będziemy rozmawiać
● Platforma: linux, x86-64
● Podstawowe przydatne komendy
● Wbudowane zmienne i funkcje
● Automatyzacja pracy
● Aplikacji wielowątkowe
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
Jak zacząć ?
● gdb + file + run
● gdb <program> + run
● gdb attach <program>
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
break ... if cond [thread thread-id]
Set a breakpoint with condition cond; evaluate the expression cond each time the
breakpoint is reached, and stop only if the value is nonzero--that is, if cond evaluates
as true. `...' stands for one of the possible arguments: function, +offset, -offset,
linenum, filename:linenum, filename:function, *address.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
break ... if cond [thread thread-id]
commands
silent
printf “my_var is %dn”,my_var
set my_var = my_var + 1
continue
end
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
[r|a|-]watch [-l|-location] expr [thread
thread-id] [mask maskvalue]
Set a watchpoint for an expression. GDB will break when the expression expr is written into by the program
and its value changes. If the command includes a [thread thread-id] argument, GDB breaks only when the
thread identified by thread-id changes the value of expr.Ordinarily a watchpoint respects the scope of
variables in expr (see below). The -location argument tells GDB to instead watch the memory referred to by
expr. In this case, GDB will evaluate expr, take the address of the result, and watch the memory at that
address. The type of the result is used to determine the size of the watched memory. If the expression’s
result does not have an address, then GDB will print an error.
The [mask maskvalue] argument allows creation of masked watchpoints, if the current architecture supports
this feature A masked watchpoint specifies a mask in addition to an address to watch. The mask specifies
that some bits of an address should be ignored when matching the address accessed by the inferior against
the watchpoint address. Thus, a masked watchpoint watches many addresses simultaneously.The mask
argument implies -location. Examples:
(gdb) watch foo mask 0xffff00ff
(gdb) watch *0xdeadbeef mask 0xffffff00
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
catch event
Stop when event occurs. The event can be any of the following:
● throw,
● rethrow,
● catch,
● exec,
● syscall,
● fork,
● vfork,
● load,
● unload,
● signal
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
X
x [Address expression]
x /[Format] [Address expression]
x /[Length][Format] [Address expression]
Format: o,x,d,u,t,f,a,c,s,i followed by:b,h,w,g
print
print expr
print /f expr
Format: o,x,d,u,t,a,c,f
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
explore
explore arg
arg is either an expression (in the source
language), or a type visible in the current
context of the program being debugged.
whatis
whatis expr
Print the data type of expression
expr. expr is not actually
evaluated, and any side-effecting
operations (such as assignments or
function calls) inside it do not
take place
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
Podstawowe komendy
set var ...
To alter the value of a variable, evaluate an assignment expression.
Example:
set var my_var = 48
set {int}0xdeadbeef = 48
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
backtrace
This command will print one line per
frame for frames in the stack. By
default, all stack frames are
printed.
frame
When used without any argument, this
command does not change which frame is
selected, but prints a brief description
of the currently selected stack frame. It
can be abbreviated f. With an argument,
this command is used to select a stack
frame.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
step
step [count]
Continue running your program until control
reaches a different source line, then stop
it and return control to GDB. This command
is abbreviated s.
next
next [count]
Continue to the next source line in the
current (innermost) stack frame. This
is similar to step, but function calls
that appear within the line of code are
executed without stopping. Execution
stops when control reaches a different
line of code at the original stack
level that was executing when you gave
the next command. This command is
abbreviated n.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Podstawowe komendy
Podstawowe komendy
● continue, until, finish
● info thread / reg / break
● disassemble
● jump
● call, return
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Wbudowane zmienne GDB
Convenience Variables
GDB provides convenience variables that you can use within GDB to hold on to a value and refer to it later. These
variables exist entirely within GDB; they are not part of your program, and setting a convenience variable has no
direct effect on further execution of your program. That is why you can use them freely.
Convenience variables are prefixed with ‘$’. Any name preceded by ‘$’ can be used for a convenience variable,
unless it is one of the predefined machine-specific register names.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Wbudowane funkcje GDB
Convenience Functions
GDB also supplies some convenience functions. These have a syntax similar to
convenience variables. A convenience function can be used in an expression just like an
ordinary function; however, a convenience function is implemented internally to GDB.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Wbudowane funkcje GDB
Convenience Functions
● $_isvoid (expr)
● $_memeq(buf1, buf2, length)
● $_regex(str, regex)
● $_streq(str1, str2)
● $_strlen(str)
● $_caller_is(name[, number_of_frames])
● $_caller_matches(regexp[, number_of_frames])
● $_any_caller_is(name[, number_of_frames])
● $_any_caller_matches(regexp[, number_of_frames])
● $_as_string(value)
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
A user-defined command is a sequence of GDB commands to which you assign a new
name as a command. This is done with the define command. User commands may accept
up to 10 arguments separated by whitespace. Arguments are accessed within the user
command via $arg0...$arg9. A trivial example:
define adder
print $arg0 + $arg1 + $arg2
To execute the command use:
adder 1 2 3
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
define commandname
...
end
Define a command named commandname. If there is already a command by that name,
you are asked to confirm that you want to redefine it. The definition of the command is
made up of other GDB command lines, which are given following the define command. The
end of these commands is marked by a line containing end.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
if arg
Takes a single argument, which is an expression to evaluate. It is followed by a series of
commands that are executed only if the expression is true (nonzero). There can then
optionally be a line else, followed by a series of commands that are only executed if the
expression was false. The end of the list is marked by a line containing end.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
while arg
The syntax is similar to if: the command takes a single argument, which is an expression to
evaluate, and must be followed by the commands to execute, one per line, terminated by
an end. The commands are executed repeatedly as long as the expression evaluates to
true.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
document commandname
Document the user-defined command commandname, so that it can be accessed by help.
The command commandname must already be defined. This command reads lines of
documentation just as define reads the lines of the command definition, ending with end.
After the document command is finished, help on command commandname displays the
documentation you have written. You may use the document command again to change
the documentation of a command. Redefining the command with define does not change
the documentation.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
show user commandname
Display the GDB commands used to define commandname (but not its documentation). If
no commandname is given, display the definitions for all user-defined commands.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Automatyzacja
Example
(gdb) show user
User command "example":
set $i=0
while $i<16
print tab[$i++]
end
(gdb)
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
All-stop vs non-stop
All-stop
In all-stop mode, whenever your program stops under GDB for
any reason, all threads of execution stop, not just the current
thread. This allows you to examine the overall state of the
program, including switching between threads, without worrying
that things may change underfoot.
Conversely, whenever you restart the program, all threads start
executing. This is true even when single-stepping with
commands like step or next.
Non-stop
For some multi-threaded targets, GDB supports an
optional mode of operation in which you can examine
stopped program threads in the debugger while other
threads continue to execute freely. This minimizes
intrusion when debugging live systems, such as programs
where some threads have real-time constraints or must
continue to respond to external events. This is referred to
as non-stop mode.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Aplikacje wielowątkowe
Background Execution
GDB’s execution commands have two variants: the normal foreground (synchronous)
behavior, and a background (asynchronous) behavior. In foreground execution, GDB waits
for the program to report that some thread has stopped before prompting for another
command. In background execution, GDB immediately gives a command prompt so that
you can issue other commands while your program runs.
If the target doesn’t support async mode, GDB issues an error message if you attempt to
use the background execution commands.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Aplikacje wielowątkowe
Background Execution
To specify background execution, add a & to the command. For example, the background
form of the continue command is continue&, or just c&. The execution commands that
accept background execution are:
run, attach, step, stepi, next, nexti, continue, finish, until
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Aplikacje wielowątkowe
Background Execution
You can interrupt your program while it is running in the background by using the interrupt
command.
interrupt
interrupt -a
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
Aplikacje wielowątkowe
Reverse execute
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
When you are debugging a program, it is not unusual to realize that you have gone too far,
and some event of interest has already happened. If the target environment supports it,
GDB can allow you to “rewind” the program by running it backward.
A target environment that supports reverse execution should be able to “undo” the changes
in machine state that have taken place as the program was executing normally. Variables,
registers etc. should revert to their previous values. Obviously this requires a great deal of
sophistication on the part of the target environment; not all target environments can support
reverse execution.
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
● reverse-continue ('rc') -- Continue program being debugged but run it in reverse
● reverse-finish -- Execute backward until just before the selected stack frame is
called
● reverse-next ('rn') -- Step program backward, proceeding through subroutine calls.
● reverse-nexti ('rni') -- Step backward one instruction, but proceed through called
subroutines.
● reverse-step ('rs') -- Step program backward until it reaches the beginning of a
previous source line
● reverse-stepi -- Step backward exactly one instruction
● set exec-direction (forward/reverse) -- Set direction of execution.
● All subsequent execution commands (continue, step, until etc.) will run the program
being debugged in the selected direction.
Reverse execute
Dziękuję za uwagę
Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.

More Related Content

Similar to Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01

gdb-tutorial.pdf
gdb-tutorial.pdfgdb-tutorial.pdf
gdb-tutorial.pdfligi14
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handoutSuraj Kumar
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018Taro L. Saito
 
Let’s template
Let’s templateLet’s template
Let’s templateAllenKao7
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingAnil Kumar Pugalia
 
Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbSenthilKumar Selvaraj
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Bookguestd9317c
 
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)ZFConf Conference
 
HSA HSAIL Introduction Hot Chips 2013
HSA HSAIL Introduction  Hot Chips 2013 HSA HSAIL Introduction  Hot Chips 2013
HSA HSAIL Introduction Hot Chips 2013 HSA Foundation
 
Zend Framework 2 quick start
Zend Framework 2 quick startZend Framework 2 quick start
Zend Framework 2 quick startEnrico Zimuel
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learnedbasisspace
 
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...Amazon Web Services
 
Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDBChris Simmonds
 

Similar to Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01 (20)

Wavedigitech gdb
Wavedigitech gdbWavedigitech gdb
Wavedigitech gdb
 
gdb-tutorial.pdf
gdb-tutorial.pdfgdb-tutorial.pdf
gdb-tutorial.pdf
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handout
 
GCC RTL and Machine Description
GCC RTL and Machine DescriptionGCC RTL and Machine Description
GCC RTL and Machine Description
 
GNU Debugger
GNU DebuggerGNU Debugger
GNU Debugger
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
 
Let’s template
Let’s templateLet’s template
Let’s template
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Qtp Scripts
Qtp ScriptsQtp Scripts
Qtp Scripts
 
Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with Gdb
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Advanced Qtp Book
Advanced Qtp BookAdvanced Qtp Book
Advanced Qtp Book
 
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
 
HSA HSAIL Introduction Hot Chips 2013
HSA HSAIL Introduction  Hot Chips 2013 HSA HSAIL Introduction  Hot Chips 2013
HSA HSAIL Introduction Hot Chips 2013
 
Zend Framework 2 quick start
Zend Framework 2 quick startZend Framework 2 quick start
Zend Framework 2 quick start
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learned
 
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
Uber on Using Horovod for Distributed Deep Learning (AIM411) - AWS re:Invent ...
 
Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDB
 

More from Semihalf

Meetup #1 - Świat Komputera Przed Systemem Operacyjnym
Meetup #1 - Świat Komputera Przed Systemem Operacyjnym Meetup #1 - Świat Komputera Przed Systemem Operacyjnym
Meetup #1 - Świat Komputera Przed Systemem Operacyjnym Semihalf
 
ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.
ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.
ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.Semihalf
 
Embedded Debugging, czyli co kryje się w jądrze?
Embedded Debugging, czyli co kryje się w jądrze?Embedded Debugging, czyli co kryje się w jądrze?
Embedded Debugging, czyli co kryje się w jądrze?Semihalf
 
Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018
Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018
Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018Semihalf
 
Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018
Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018
Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018Semihalf
 
Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018
Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018
Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018Semihalf
 
CPU GHOST BUSTING. Semihalf Barcamp Special.
CPU GHOST BUSTING. Semihalf Barcamp Special. CPU GHOST BUSTING. Semihalf Barcamp Special.
CPU GHOST BUSTING. Semihalf Barcamp Special. Semihalf
 
Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03
Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03
Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03Semihalf
 
Skazani na firmware. ARM Trusted Firmware. S07E02
Skazani na firmware. ARM Trusted Firmware. S07E02Skazani na firmware. ARM Trusted Firmware. S07E02
Skazani na firmware. ARM Trusted Firmware. S07E02Semihalf
 
Skazani na firmware. Świat komputera przed systemem operacyjnym.
Skazani na firmware. Świat komputera przed systemem operacyjnym.Skazani na firmware. Świat komputera przed systemem operacyjnym.
Skazani na firmware. Świat komputera przed systemem operacyjnym.Semihalf
 
Złam zasady i stwórz wydajny stos IP przy użyciu DPDK
Złam zasady i stwórz wydajny stos IP przy użyciu DPDKZłam zasady i stwórz wydajny stos IP przy użyciu DPDK
Złam zasady i stwórz wydajny stos IP przy użyciu DPDKSemihalf
 
Wirtualizacja urządzeń PCI (SR-IOV).
Wirtualizacja urządzeń PCI (SR-IOV).Wirtualizacja urządzeń PCI (SR-IOV).
Wirtualizacja urządzeń PCI (SR-IOV).Semihalf
 
Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.
Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.
Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.Semihalf
 
Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?
Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?
Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?Semihalf
 
Hierarchia pamięci w systemach komputerowych.
Hierarchia pamięci w systemach komputerowych.Hierarchia pamięci w systemach komputerowych.
Hierarchia pamięci w systemach komputerowych.Semihalf
 
Programowanie sterowników w Linuksie.
Programowanie sterowników w Linuksie.Programowanie sterowników w Linuksie.
Programowanie sterowników w Linuksie.Semihalf
 
Architektura mikrokontrolera pisana słowem.
Architektura mikrokontrolera pisana słowem.Architektura mikrokontrolera pisana słowem.
Architektura mikrokontrolera pisana słowem.Semihalf
 
Bootloadery i programy bare metal.
Bootloadery i programy bare metal.Bootloadery i programy bare metal.
Bootloadery i programy bare metal.Semihalf
 
Jak napisać własny RTOS!
Jak napisać własny RTOS!Jak napisać własny RTOS!
Jak napisać własny RTOS!Semihalf
 
Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.
Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.
Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.Semihalf
 

More from Semihalf (20)

Meetup #1 - Świat Komputera Przed Systemem Operacyjnym
Meetup #1 - Świat Komputera Przed Systemem Operacyjnym Meetup #1 - Świat Komputera Przed Systemem Operacyjnym
Meetup #1 - Świat Komputera Przed Systemem Operacyjnym
 
ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.
ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.
ARM CoreSight - sprawdź, co tak naprawdę robi Twój SoC.
 
Embedded Debugging, czyli co kryje się w jądrze?
Embedded Debugging, czyli co kryje się w jądrze?Embedded Debugging, czyli co kryje się w jądrze?
Embedded Debugging, czyli co kryje się w jądrze?
 
Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018
Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018
Oczyszczacz powietrza i stos sieciowy? Czas na test! Semihalf Barcamp 13/06/2018
 
Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018
Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018
Programuj wbrew regułom. Barcamp Semihalf S08:E02 29/05/2018
 
Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018
Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018
Programuj wbrew regułom - Bug Legends Quiz Show. Semihalf Barcamp 25/04/2018
 
CPU GHOST BUSTING. Semihalf Barcamp Special.
CPU GHOST BUSTING. Semihalf Barcamp Special. CPU GHOST BUSTING. Semihalf Barcamp Special.
CPU GHOST BUSTING. Semihalf Barcamp Special.
 
Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03
Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03
Skazani na firmware. Serwer na ARM64? Tak, to możliwe! S07E03
 
Skazani na firmware. ARM Trusted Firmware. S07E02
Skazani na firmware. ARM Trusted Firmware. S07E02Skazani na firmware. ARM Trusted Firmware. S07E02
Skazani na firmware. ARM Trusted Firmware. S07E02
 
Skazani na firmware. Świat komputera przed systemem operacyjnym.
Skazani na firmware. Świat komputera przed systemem operacyjnym.Skazani na firmware. Świat komputera przed systemem operacyjnym.
Skazani na firmware. Świat komputera przed systemem operacyjnym.
 
Złam zasady i stwórz wydajny stos IP przy użyciu DPDK
Złam zasady i stwórz wydajny stos IP przy użyciu DPDKZłam zasady i stwórz wydajny stos IP przy użyciu DPDK
Złam zasady i stwórz wydajny stos IP przy użyciu DPDK
 
Wirtualizacja urządzeń PCI (SR-IOV).
Wirtualizacja urządzeń PCI (SR-IOV).Wirtualizacja urządzeń PCI (SR-IOV).
Wirtualizacja urządzeń PCI (SR-IOV).
 
Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.
Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.
Software Defined Networks (SDN) na przykładzie rozwiązania OpenContrail.
 
Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?
Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?
Jak stworzyć wysokowydajny i skalowalny stos sieciowy dla 72 rdzeni CPU?
 
Hierarchia pamięci w systemach komputerowych.
Hierarchia pamięci w systemach komputerowych.Hierarchia pamięci w systemach komputerowych.
Hierarchia pamięci w systemach komputerowych.
 
Programowanie sterowników w Linuksie.
Programowanie sterowników w Linuksie.Programowanie sterowników w Linuksie.
Programowanie sterowników w Linuksie.
 
Architektura mikrokontrolera pisana słowem.
Architektura mikrokontrolera pisana słowem.Architektura mikrokontrolera pisana słowem.
Architektura mikrokontrolera pisana słowem.
 
Bootloadery i programy bare metal.
Bootloadery i programy bare metal.Bootloadery i programy bare metal.
Bootloadery i programy bare metal.
 
Jak napisać własny RTOS!
Jak napisać własny RTOS!Jak napisać własny RTOS!
Jak napisać własny RTOS!
 
Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.
Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.
Masz wiadomość! Komunikacja wieloprocesorowa w praktyce.
 

Recently uploaded

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01

  • 1. GDB w służbie programisty Łukasz Majczak Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 2. O czym będziemy rozmawiać ● Platforma: linux, x86-64 ● Podstawowe przydatne komendy ● Wbudowane zmienne i funkcje ● Automatyzacja pracy ● Aplikacji wielowątkowe Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 3. Podstawowe komendy Jak zacząć ? ● gdb + file + run ● gdb <program> + run ● gdb attach <program> Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 4. Podstawowe komendy break ... if cond [thread thread-id] Set a breakpoint with condition cond; evaluate the expression cond each time the breakpoint is reached, and stop only if the value is nonzero--that is, if cond evaluates as true. `...' stands for one of the possible arguments: function, +offset, -offset, linenum, filename:linenum, filename:function, *address. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 5. Podstawowe komendy break ... if cond [thread thread-id] commands silent printf “my_var is %dn”,my_var set my_var = my_var + 1 continue end Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 6. Podstawowe komendy [r|a|-]watch [-l|-location] expr [thread thread-id] [mask maskvalue] Set a watchpoint for an expression. GDB will break when the expression expr is written into by the program and its value changes. If the command includes a [thread thread-id] argument, GDB breaks only when the thread identified by thread-id changes the value of expr.Ordinarily a watchpoint respects the scope of variables in expr (see below). The -location argument tells GDB to instead watch the memory referred to by expr. In this case, GDB will evaluate expr, take the address of the result, and watch the memory at that address. The type of the result is used to determine the size of the watched memory. If the expression’s result does not have an address, then GDB will print an error. The [mask maskvalue] argument allows creation of masked watchpoints, if the current architecture supports this feature A masked watchpoint specifies a mask in addition to an address to watch. The mask specifies that some bits of an address should be ignored when matching the address accessed by the inferior against the watchpoint address. Thus, a masked watchpoint watches many addresses simultaneously.The mask argument implies -location. Examples: (gdb) watch foo mask 0xffff00ff (gdb) watch *0xdeadbeef mask 0xffffff00 Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 7. Podstawowe komendy catch event Stop when event occurs. The event can be any of the following: ● throw, ● rethrow, ● catch, ● exec, ● syscall, ● fork, ● vfork, ● load, ● unload, ● signal Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 8. X x [Address expression] x /[Format] [Address expression] x /[Length][Format] [Address expression] Format: o,x,d,u,t,f,a,c,s,i followed by:b,h,w,g print print expr print /f expr Format: o,x,d,u,t,a,c,f Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Podstawowe komendy
  • 9. explore explore arg arg is either an expression (in the source language), or a type visible in the current context of the program being debugged. whatis whatis expr Print the data type of expression expr. expr is not actually evaluated, and any side-effecting operations (such as assignments or function calls) inside it do not take place Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Podstawowe komendy
  • 10. Podstawowe komendy set var ... To alter the value of a variable, evaluate an assignment expression. Example: set var my_var = 48 set {int}0xdeadbeef = 48 Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 11. backtrace This command will print one line per frame for frames in the stack. By default, all stack frames are printed. frame When used without any argument, this command does not change which frame is selected, but prints a brief description of the currently selected stack frame. It can be abbreviated f. With an argument, this command is used to select a stack frame. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Podstawowe komendy
  • 12. step step [count] Continue running your program until control reaches a different source line, then stop it and return control to GDB. This command is abbreviated s. next next [count] Continue to the next source line in the current (innermost) stack frame. This is similar to step, but function calls that appear within the line of code are executed without stopping. Execution stops when control reaches a different line of code at the original stack level that was executing when you gave the next command. This command is abbreviated n. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Podstawowe komendy
  • 13. Podstawowe komendy ● continue, until, finish ● info thread / reg / break ● disassemble ● jump ● call, return Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 14. Wbudowane zmienne GDB Convenience Variables GDB provides convenience variables that you can use within GDB to hold on to a value and refer to it later. These variables exist entirely within GDB; they are not part of your program, and setting a convenience variable has no direct effect on further execution of your program. That is why you can use them freely. Convenience variables are prefixed with ‘$’. Any name preceded by ‘$’ can be used for a convenience variable, unless it is one of the predefined machine-specific register names. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 15. Wbudowane funkcje GDB Convenience Functions GDB also supplies some convenience functions. These have a syntax similar to convenience variables. A convenience function can be used in an expression just like an ordinary function; however, a convenience function is implemented internally to GDB. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 16. Wbudowane funkcje GDB Convenience Functions ● $_isvoid (expr) ● $_memeq(buf1, buf2, length) ● $_regex(str, regex) ● $_streq(str1, str2) ● $_strlen(str) ● $_caller_is(name[, number_of_frames]) ● $_caller_matches(regexp[, number_of_frames]) ● $_any_caller_is(name[, number_of_frames]) ● $_any_caller_matches(regexp[, number_of_frames]) ● $_as_string(value) Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 17. Automatyzacja A user-defined command is a sequence of GDB commands to which you assign a new name as a command. This is done with the define command. User commands may accept up to 10 arguments separated by whitespace. Arguments are accessed within the user command via $arg0...$arg9. A trivial example: define adder print $arg0 + $arg1 + $arg2 To execute the command use: adder 1 2 3 Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 18. Automatyzacja define commandname ... end Define a command named commandname. If there is already a command by that name, you are asked to confirm that you want to redefine it. The definition of the command is made up of other GDB command lines, which are given following the define command. The end of these commands is marked by a line containing end. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 19. Automatyzacja if arg Takes a single argument, which is an expression to evaluate. It is followed by a series of commands that are executed only if the expression is true (nonzero). There can then optionally be a line else, followed by a series of commands that are only executed if the expression was false. The end of the list is marked by a line containing end. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 20. Automatyzacja while arg The syntax is similar to if: the command takes a single argument, which is an expression to evaluate, and must be followed by the commands to execute, one per line, terminated by an end. The commands are executed repeatedly as long as the expression evaluates to true. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 21. Automatyzacja document commandname Document the user-defined command commandname, so that it can be accessed by help. The command commandname must already be defined. This command reads lines of documentation just as define reads the lines of the command definition, ending with end. After the document command is finished, help on command commandname displays the documentation you have written. You may use the document command again to change the documentation of a command. Redefining the command with define does not change the documentation. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 22. Automatyzacja show user commandname Display the GDB commands used to define commandname (but not its documentation). If no commandname is given, display the definitions for all user-defined commands. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 23. Automatyzacja Example (gdb) show user User command "example": set $i=0 while $i<16 print tab[$i++] end (gdb) Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.
  • 24. All-stop vs non-stop All-stop In all-stop mode, whenever your program stops under GDB for any reason, all threads of execution stop, not just the current thread. This allows you to examine the overall state of the program, including switching between threads, without worrying that things may change underfoot. Conversely, whenever you restart the program, all threads start executing. This is true even when single-stepping with commands like step or next. Non-stop For some multi-threaded targets, GDB supports an optional mode of operation in which you can examine stopped program threads in the debugger while other threads continue to execute freely. This minimizes intrusion when debugging live systems, such as programs where some threads have real-time constraints or must continue to respond to external events. This is referred to as non-stop mode. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Aplikacje wielowątkowe
  • 25. Background Execution GDB’s execution commands have two variants: the normal foreground (synchronous) behavior, and a background (asynchronous) behavior. In foreground execution, GDB waits for the program to report that some thread has stopped before prompting for another command. In background execution, GDB immediately gives a command prompt so that you can issue other commands while your program runs. If the target doesn’t support async mode, GDB issues an error message if you attempt to use the background execution commands. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Aplikacje wielowątkowe
  • 26. Background Execution To specify background execution, add a & to the command. For example, the background form of the continue command is continue&, or just c&. The execution commands that accept background execution are: run, attach, step, stepi, next, nexti, continue, finish, until Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Aplikacje wielowątkowe
  • 27. Background Execution You can interrupt your program while it is running in the background by using the interrupt command. interrupt interrupt -a Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. Aplikacje wielowątkowe
  • 28. Reverse execute Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. When you are debugging a program, it is not unusual to realize that you have gone too far, and some event of interest has already happened. If the target environment supports it, GDB can allow you to “rewind” the program by running it backward. A target environment that supports reverse execution should be able to “undo” the changes in machine state that have taken place as the program was executing normally. Variables, registers etc. should revert to their previous values. Obviously this requires a great deal of sophistication on the part of the target environment; not all target environments can support reverse execution.
  • 29. Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information. ● reverse-continue ('rc') -- Continue program being debugged but run it in reverse ● reverse-finish -- Execute backward until just before the selected stack frame is called ● reverse-next ('rn') -- Step program backward, proceeding through subroutine calls. ● reverse-nexti ('rni') -- Step backward one instruction, but proceed through called subroutines. ● reverse-step ('rs') -- Step program backward until it reaches the beginning of a previous source line ● reverse-stepi -- Step backward exactly one instruction ● set exec-direction (forward/reverse) -- Set direction of execution. ● All subsequent execution commands (continue, step, until etc.) will run the program being debugged in the selected direction. Reverse execute
  • 30. Dziękuję za uwagę Copyright © 2018 Semihalf. All rights reserved. Confidential and proprietary information.