gdb - yszheda/wiki GitHub Wiki
(gdb) info inferior
set breakpoint pending on
- How do I set a conditional breakpoint in gdb, when char* x points to a string whose value equals “hello”?
- GDB: break if variable equal value
(gdb) b __assert_fail@plt
#ifdef DEBUG
# if __GNUC__
# define assert(c) if (!(c)) __builtin_trap()
# elif _MSC_VER
# define assert(c) if (!(c)) __debugbreak()
# else
# define assert(c) if (!(c)) *(volatile int *)0 = 0
# endif
#else
# define assert(c)
#endif
(gdb) break exit
(gdb) catch throw
b 'std::bad_alloc::bad_alloc()'
(gdb) catch syscall mmap
(gdb) p ('MyScope::MyClass'*) ptr;
(gdb) call malloc_stats()
Arena 0:
system bytes = 135168
in use bytes = 96
Total (incl. mmap):
system bytes = 135168
in use bytes = 96
max mmap regions = 0
max mmap bytes = 0
(gdb) call malloc_info(0, stdout)
<malloc version="1">
<heap nr="0">
<sizes>
<unsorted from="1228788" to="1229476" total="3917678" count="3221220448"/>
</sizes>
<total type="fast" count="0" size="0"/>
<total type="rest" count="3221220448" size="3917678"/>
<system type="current" size="135168"/>
<system type="max" size="135168"/>
<aspace type="total" size="135168"/>
<aspace type="mprotect" size="135168"/>
</heap>
<total type="fast" count="0" size="0"/>
<total type="rest" count="3221220448" size="3917678"/>
<system type="current" size="135168
/>
<system type="max" size="135168
/>
<aspace type="total" size="135168"/>
<aspace type="mprotect" size="135168"/>
</malloc>
- Examining C/C++ Heap memory statistics in gdb
- How to use malloc_stats in C program on Linux
- https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=558e8bab0ab3808ec9f5b569ca62863ef4651b27;hb=HEAD#l6323
# step out
(gdb) fin
(gdb) thread apply all bt
set follow-fork-mode child
- https://sourceware.org/gdb/onlinedocs/gdb/Forks.html
- GDB backtrace on child process
- gdb break when entering child process
- gdb debugging process after exec call
ulimit -c unlimited
- 10.19 Copy Between Memory and a File
- Gdb dump memory in specific region, save formatted output into a file
(gdb) set logging on
Copying output to gdb.txt
(gdb) set logging off
Done logging to gdb.txt
# Record command
(gdb) set trace-commands on
(gdb) define fn
> finish
> next
> end
print {var1,var2,var3,var4}
- https://sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html
- 当debug信息单独存放为一个文件时使用gdb调试CoreDump
- How to generate gcc debug symbol outside the build target?
objcopy --only-keep-debug "${tostripfile}" "${debugdir}/${debugfile}"
strip --strip-debug --strip-unneeded "${tostripfile}"
objcopy --add-gnu-debuglink="${debugdir}/${debugfile}" "${tostripfile}"
- How can I scroll back in GDB's command window in the TUI mode?
- How to clear console in gdb while in TUI
- http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt
- https://gist.github.com/skyscribe/3978082
LC_ALL=en_US.UTF-8 gdb
- http://stackoverflow.com/questions/22309028/gdb-left-operand-of-assignment-is-not-an-lvalue
- http://stackoverflow.com/questions/1345338/gdb-behavior-value-optimized-out
- http://eli.thegreenplace.net/2011/12/15/understanding-lvalues-and-rvalues-in-c-and-c
- https://zh.wikipedia.org/wiki/Volatile%E5%8F%98%E9%87%8F
- https://en.wikipedia.org/wiki/Volatile_(computer_programming)
- http://ieng9.ucsd.edu/~cs30x/Non-modifiable%20Lvalues.htm
- http://eli.thegreenplace.net/2011/12/15/understanding-lvalues-and-rvalues-in-c-and-c
Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root user.
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
- GDB在调试程序时候提示Missing separate debuginfos, use: debuginfo-install glibc…
- gdb调试时的问题Missing separate debuginfos, use: debuginfo-install glibc-XXX
unset PYTHONPATH
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error
print *(x._M_impl._M_start+0)
break x:20 if strcmp(y, "hello") == 0