File: dotgdbinit

package info (click to toggle)
net-snmp 5.9+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 36,760 kB
  • sloc: ansic: 283,039; perl: 17,712; sh: 11,887; makefile: 2,705; xml: 663; python: 623; pascal: 62; sql: 47
file content (138 lines) | stat: -rw-r--r-- 3,110 bytes parent folder | download | duplicates (8)
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
#
# this file defines some utilities for printing various structures
# found in the net-snmp source code.  You can source it from within
# gdb and then use it to print variable chains, oids, etc directly
# from memory.
# 
# as an example, consider the variables:
#
#   oid    *name;
#   size_t name_len;
#
# normally display oids is difficult under gdb, and the best you can
# do is to use x/12dw name or so to print the first 12 numbers of the
# oid array.  however, with this file you can now use:
#
#   gdb> printoid name_len name
#   .1.3.6.1.2.1.1.0
#
# which will print oids in a more readable fashion.  etc...
#

define initme
  set $varindent = ""
end

define hookpost-run
  initme
end

define printvarval
  printf "value: "
  if $arg0->type == 2
    printf "int: %d\n", $arg0->val.integer
  end
  if $arg0->type == 4
    printf "string: %s\n", $arg0->val.string
  end
  if $arg0->type == 5
    printf "ASN NULL\n"
  end
  if $arg0->type == 6
    printoid (($arg0->val_len)/sizeof(oid)) $arg0->val.objid
  end
  if $arg0->type == 128
    printf "NO SUCH NAME\n"
  end
  if $arg0->type == 129
    printf "NO SUCH INSTANCE\n"
  end
  if $arg0->type == 130
    printf "END OF MIB VIEW\n"
  end
  if $arg0->type == 194
    printf "AGENTX INCL RANGE: "
    printoid (($arg0->val_len)/sizeof(oid)) $arg0->val.objid
  end
  if $arg0->type == 195
    printf "AGENTX EXCL RANGE: "
    printoid (($arg0->val_len)/sizeof(oid)) $arg0->val.objid
  end
end
document printvarval
  printvarval VARPTR
  prints the value part of a net-snmp "struct variable".
  This is called from inside printvar.
end

  

define printvar
  printf "%stype: %d\n", $varindent, $arg0->type
  printf "%soid: ", $varindent
  printoid $arg0->name_length $arg0->name
  printf "%s", $varindent
  printvarval $arg0
end
document printvar
  printvar VARPTR
  prints the variable information contained in a net-snmp struct
  variable.  printvarval POINTER will print it's oid, value type and
  value contents
end

define printvars
  set $tmpcount = 1
  set $tmpvar = $arg0
  set $varindent = "  "
  while $tmpvar != 0
    printf "VARIABLE #%d\n", $tmpcount
    printvar $tmpvar
    set $tmpvar = $tmpvar->next_variable
    set $tmpcount = $tmpcount + 1
  end
  set $varindent = ""
end
document printvars
  printvars VARPTR
  calls printvar repeatedly on a chain of variables, displaying all
  the variables in a net-snmp struct variable chain.
end

define printoid
  set $printoid_tmp = 0
  while $printoid_tmp < $arg0
    printf ".%d", $arg1[$printoid_tmp]
    set $printoid_tmp = $printoid_tmp + 1
  end
  printf "\n"
end
document printoid
  printoid LENGTH OIDPTR
  prints an oid (.x.y.z...) given it's length and a pointer.
end

define poid
  printoid $arg0_len $arg0
end
document poid
  poid NAME
  shorthand for 'printoid NAME_len NAME"
end

define poidl
  printoid $arg0_length $arg0
end
document poidl
  poid NAME
  shorthand for 'printoid NAME_length NAME"
end

define printindex
  printoid $arg0->len $arg0->oids
end
document printindex
  printindex NETSNMP_INDEX_PTR
  prints the OID contained in a netsnmp_index struct variable.
end