mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 16:40:42 +08:00
Add notes for Pretty Printers.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
Pretty Printer is a GDB feature to print the contents of structures in
|
||||
a pleasant way.
|
||||
|
||||
Printing the value of a std::string may look like:
|
||||
|
||||
{static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffd330 "Hello, World!"}, _M_string_length = 13, {_M_local_buf = "Hello, World!\\000\\000", _M_allocated_capacity = 6278066737626506568}}
|
||||
|
||||
Printing the value with Pretty Pretty:
|
||||
|
||||
"Hello, World!"
|
||||
|
||||
Enable Pretty Printers via the ~/.gdbinit file.
|
||||
|
||||
% cat ~/.gdbinit
|
||||
python
|
||||
import sys
|
||||
sys.path.insert(0, '/usr/share/gcc-9/python')
|
||||
from libstdcxx.v6.printers import register_libstdcxx_printers
|
||||
register_libstdcxx_printers (None)
|
||||
end
|
||||
%
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
|
||||
Steps to compile an asm program.
|
||||
|
||||
% nasm -f elf -F stabs helloasm.asm -o helloasm_stabs.o
|
||||
% ld -m elf_i386 helloasm_stabs.o -o helloasm_stabs
|
||||
% seer -s helloasm_stabs
|
||||
% nasm -f elf -F stabs helloasm.asm -o helloasm_stabs.o
|
||||
% ld -m elf_i386 helloasm_stabs.o -o helloasm_stabs
|
||||
% seer -s helloasm_stabs
|
||||
|
||||
Find address to set start breakpoint.
|
||||
|
||||
% objdump -f helloasm_stabs
|
||||
|
||||
helloasm_stabs: file format elf32-i386
|
||||
architecture: i386, flags 0x00000112:
|
||||
EXEC_P, HAS_SYMS, D_PAGED
|
||||
start address 0x08048080
|
||||
|
||||
Add a way to provide the breakpoint address/function in the
|
||||
debug dialog and start command line.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
hellolocals
|
||||
@@ -0,0 +1,14 @@
|
||||
# This is the default target, which will be built when
|
||||
# you invoke make
|
||||
.PHONY: all
|
||||
all: hellolocals
|
||||
|
||||
# This rule tells make how to build hellolocals from hellolocals.cpp
|
||||
hellolocals: hellolocals.cpp
|
||||
g++ -g -o hellolocals hellolocals.cpp
|
||||
|
||||
# This rule tells make to delete hellolocals and hellolocals.o
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f hellolocals hellolocals.o
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Simple program to show some structures in the "locals" tab of Seer.
|
||||
|
||||
See: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34589
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(void) {
|
||||
|
||||
size_t idx = 0;
|
||||
|
||||
vector<int> v{1, 2, 3, 4, 5};
|
||||
|
||||
auto& vr = v;
|
||||
|
||||
for (auto i : v) {
|
||||
idx++;
|
||||
cout << i << "=" << v[i] << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user