forked from reactorlabs/rir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gdbinit
139 lines (113 loc) · 2.81 KB
/
.gdbinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
define berr
b errors.c:707
end
set history save
set print pretty on
set print array off
set print array-indexes on
define dumpsxp
printf "\n\n>> SEXP %p\n", $arg0
if $arg0==0
printf "NULL\n"
return
end
if $arg1==1
set $insp=do_inspect(0, 0, Rf_cons($arg0, R_NilValue), 0)
printf "%s\n", $insp
end
set $sexptype=TYPEOF($arg0)
# typename
printf "Type: %s (%d)\n", Rf_type2char($sexptype), $sexptype
# SYMSXP
if $sexptype==1
# CHAR(PRINTNAME(x))
print_char PRINTNAME($arg0)
end
# LISTSXP
if $sexptype==2
printf "(%s,%s)\n", Rf_type2char(TYPEOF(CDR($arg0))), Rf_type2char(TYPEOF(CAR($arg0)))
# printf "( ,%s)\n", type2char(TYPEOF(CDR($arg0)))
end
# CLOSXP
if $sexptype==3
dumpsxp BODY($arg0) 0
end
# PROMSXP
# Promises contain pointers to value, expr and env
# tmp = eval(tmp, rho);
if $sexptype==5
printf "Promise under evaluation: %d\n", PRSEEN($arg0)
printf "Expression: "
dumpsxp ($arg0)->u.promsxp.expr 0
# Expression: (CAR(chain))->u.promsxp.expr
end
# LANGSXP
if $sexptype==6
printf "Function:"
dumpsxp CAR($arg0) 0
printf "Args:"
dumpsxp CDR($arg0) 0
end
# SPECIALSXP
if $sexptype==7
printf "Special function: %s\n", R_FunTab[($arg0)->u.primsxp.offset].name
end
# BUILTINSXP
if $sexptype==8
printf "Function: %s\n", R_FunTab[($arg0)->u.primsxp.offset].name
end
# CHARSXP
if $sexptype==9
printf "length=%d\n", ((VECTOR_SEXPREC)(*$arg0))->vecsxp.length
#print_veclen $arg0
print_char $arg0
end
# LGLSXP
if $sexptype==10
set $lgl=*LOGICAL($arg0)
if $lgl > 0
printf "TRUE\n"
end
if $lgl == 0
printf "FALSE\n"
end
end
# INTSXP
if $sexptype==13
printf "%d\n", *(INTEGER($arg0))
end
# REALSXP
if $sexptype==14
print_veclen $arg0
#print_double $arg0
end
# STRSXP || VECSXP
if $sexptype==16 || $sexptype==19
print_veclen $arg0
set $i=LENGTH($arg0)
set $count=0
while ($count < $i)
printf "Element #%d:\n", $count
dumpsxp STRING_ELT($arg0,$count) 0
set $count = $count + 1
end
end
# RAWSXP
if $sexptype==24
print_veclen $arg0
end
printf "\n"
end
define print_veclen
printf "Vector length=%d\n", LENGTH($arg0)
end
define print_char
# this may be a bit dodgy, as I am not using the aligned union
printf "\"%s\"\n", (const char*)((VECTOR_SEXPREC *) ($arg0)+1)
end
define print_double
printf "%g\n", (double*)((VECTOR_SEXPREC *) ($arg0)+1)
end
define ds
dumpsxp $arg0 1
end