Files
GDB-tutorial/debugging-techniques.txt
2025-10-19 17:04:25 +00:00

76 lines
1.9 KiB
Plaintext

DEBUGGING TECHNIQUES:
---------------------
-> Delta Debugging:
++++++++++++++++
It is a technique like binary search, where we can decrease the section
under analysis to find bugs.
Like, we can use multiple breakpoints to the program and see
where the program faces issue and when it faces. It could
face the issue before some breakpoint could be reached or
after some breakpoints are encountered.
This way we can reduce our search space and section of analysis.
-> Assertion:
++++++++++
assert(): It check if the assumption which is passed
as an argument is true. If it isn't, the
program will Abort and core dumped.
This is for runtime check and the program
is part of C library.
To use it we need #include <cassert> statement
in C++ program.
static_assert(): It check the assumption at compile time
and throw compilation error if the
assertion fails.
This is helpful where we can evaluate
variable as constant expression using
constexpr keywords, which could help
in static assertion failure.
-> Investigating Code by Calling functions within GDB:
+++++++++++++++++++++++++++++++++++++++++++++++++++
* We can call a function from GDB when haven't reached
the point where we execute the function.
We can do function call from GDB itself.
We can use...
Command:
(gdb)call <function-name>( <arguments>.... )
-> Attaching the Debugger to a Running Process:
++++++++++++++++++++++++++++++++++++++++++++
To attach a running to process to a gdb.
Command:
$gdb -p <process-id>
We can get the process id using below command:
$ps aux | grep <process-name>
To Detach a process and let it run, we can use
command:
(gdb)detach