Skip to content

Commit a7386ba

Browse files
committed
gdbinit
1 parent 00779bf commit a7386ba

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

gdbinit

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
set history save on
2+
set history size unlimited
3+
4+
# Safe loading for EVER9ONE
5+
add-auto-load-safe-path /home/rzou/
6+
7+
set breakpoint pending on
8+
9+
# Dump to std::cout
10+
define cout
11+
call (void)operator<<(std::cout, $arg0)
12+
call (void)std::cout.flush()
13+
printf "\n"
14+
end
15+
16+
#
17+
# std::vector<>
18+
#
19+
20+
define pvector
21+
if $argc == 0
22+
help pvector
23+
else
24+
set $size = $arg0._M_impl._M_finish - $arg0._M_impl._M_start
25+
set $capacity = $arg0._M_impl._M_end_of_storage - $arg0._M_impl._M_start
26+
set $size_max = $size - 1
27+
end
28+
if $argc == 1
29+
set $i = 0
30+
while $i < $size
31+
printf "elem[%u]: ", $i
32+
p *($arg0._M_impl._M_start + $i)
33+
set $i++
34+
end
35+
end
36+
if $argc == 2
37+
set $idx = $arg1
38+
if $idx < 0 || $idx > $size_max
39+
printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
40+
else
41+
printf "elem[%u]: ", $idx
42+
p *($arg0._M_impl._M_start + $idx)
43+
end
44+
end
45+
if $argc == 3
46+
set $start_idx = $arg1
47+
set $stop_idx = $arg2
48+
if $start_idx > $stop_idx
49+
set $tmp_idx = $start_idx
50+
set $start_idx = $stop_idx
51+
set $stop_idx = $tmp_idx
52+
end
53+
if $start_idx < 0 || $stop_idx < 0 || $start_idx > $size_max || $stop_idx > $size_max
54+
printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
55+
else
56+
set $i = $start_idx
57+
while $i <= $stop_idx
58+
printf "elem[%u]: ", $i
59+
p *($arg0._M_impl._M_start + $i)
60+
set $i++
61+
end
62+
end
63+
end
64+
if $argc > 0
65+
printf "Vector size = %u\n", $size
66+
printf "Vector capacity = %u\n", $capacity
67+
printf "Element "
68+
whatis $arg0._M_impl._M_start
69+
end
70+
end
71+
72+
document pvector
73+
Prints std::vector<T> information.
74+
Syntax: pvector <vector> <idx1> <idx2>
75+
Note: idx, idx1 and idx2 must be in acceptable range [0..<vector>.size()-1].
76+
Examples:
77+
pvector v - Prints vector content, size, capacity and T typedef
78+
pvector v 0 - Prints element[idx] from vector
79+
pvector v 1 2 - Prints elements in range [idx1..idx2] from vector
80+
end
81+
82+
#
83+
# std::string
84+
#
85+
86+
define pstring
87+
if $argc == 0
88+
help pstring
89+
else
90+
printf "String \t\t\t= \"%s\"\n", $arg0._M_data()
91+
printf "String size/length \t= %u\n", $arg0._M_rep()._M_length
92+
printf "String capacity \t= %u\n", $arg0._M_rep()._M_capacity
93+
printf "String ref-count \t= %d\n", $arg0._M_rep()._M_refcount
94+
end
95+
end
96+
97+
document pstring
98+
Prints std::string information.
99+
Syntax: pstring <string>
100+
Example:
101+
pstring s - Prints content, size/length, capacity and ref-count of string s
102+
end
103+
104+
#
105+
# C++ related beautifiers (optional)
106+
#
107+
108+
set print pretty on
109+
set print object on
110+
set print static-members on
111+
set print vtbl on
112+
set print demangle on
113+
set demangle-style gnu-v3
114+
set print sevenbit-strings off

inputrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set editing-mode vi
2+
# TODO(rzou): I don't remember what the following things are for
3+
"\e[A": history-search-backward
4+
"\e[B": history-search-forward
5+
"\C-w": backward-delete-word

0 commit comments

Comments
 (0)