Bulgarian keymap
[AROS.git] / _gdbinit
blob3f7d0d9686baf33a0d053ebffa3bf41989a0e089
1 handle SIGUSR1 pass noprint nostop
2 handle SIGUSR2 pass noprint nostop
4 define liblist
5     set $lib = SysBase->LibList.lh_Head
7     printf "Base     OpenC   Name\n"
8     printf "---------------------------------------------------------------\n"
9     while ($lib->ln_Succ != 0)
10         printf "%p %5d   %s\n", \
11             $lib, \
12             ((struct Library *)$lib)->lib_OpenCnt, \
13             $lib->ln_Name
14         set $lib = $lib->ln_Succ
15     end
16 end
17 document liblist
18 List the current libraries in the system
19 end
21 define devlist
22     set $dev = SysBase->DeviceList.lh_Head
23     printf "Base     OpenC   Name\n"
24     printf "---------------------------------------------------------------\n"
25     while ($dev->ln_Succ != 0)
26         printf "%p %5d   %s\n", \
27             $dev, \
28             ((struct Library *)$dev)->lib_OpenCnt, \
29             $dev->ln_Name
30         set $dev = $dev->ln_Succ
31     end
32 end
33 document devlist
34 List the current devices in the system
35 end
37 define resourcelist
38     set $res = SysBase->ResourceList.lh_Head
39     printf "Base     Name\n"
40     printf "---------------------------------------------------------------\n"
41     while ($res->ln_Succ != 0)
42         printf "%p %s\n", $res, $res->ln_Name
43         set $res = $res->ln_Succ
44     end
45 end
46 document resourcelist
47 List the current resources in the system
48 end
50 define residentlist
51     set $resp = (struct Resident **)SysBase->ResModules
52     set $i = 0
54     printf "Address    Pri Flags Vers Type  Name\n"
55     printf "--------------------------------------------------------------\n"
56     while (($resp)[$i] != 0)
57         set $res = ($resp)[$i]
58         printf "%p  %4d    %02x  %3d  %3d  %s\n", \
59             $res, \
60             ((struct Resident *)$res)->rt_Pri, \
61             ((struct Resident *)$res)->rt_Flags, \
62             ((struct Resident *)$res)->rt_Version, \
63             ((struct Resident *)$res)->rt_Type, \
64             ((struct Resident *)$res)->rt_Name
65         set $i = $i + 1
66     end
67 end
68 document residentlist
69 List the system resident list
70 end
72 define taskready
73     set $task = (struct Task *)SysBase->TaskReady.lh_Head
75     printf "Task     SigWait  SigRecvd StkSize   StkUsed Pri Type Name\n"
76     printf "-----------------------------------------------------------------------------\n"
77     while ($task->tc_Node.ln_Succ != 0)
78         printf "%p %p %p %8d %8d %3d  %3ld %s\n", \
79             $task, \
80             $task->tc_SigWait, \
81             $task->tc_SigRecvd, \
82             $task->tc_SPUpper - $task->tc_SPLower, \
83             $task->tc_SPUpper - $task->tc_SPReg, \
84             $task->tc_Node.ln_Pri, \
85             $task->tc_Node.ln_Type, \
86             $task->tc_Node.ln_Name
87         set $task = (struct Task *)$task->tc_Node.ln_Succ
88     end
89 end
90 document taskready
91 List of tasks currently ready to run
92 end
94 define taskwait
95     set $task = (struct Task *)SysBase->TaskWait.lh_Head
97     printf "Task     SigWait  SigRecvd StkSize   StkUsed Pri Type Name\n"
98     printf "-----------------------------------------------------------------------------\n"
99     while ($task->tc_Node.ln_Succ != 0)
100         printf "%p %p %p %8d %8d %3d  %3ld %s\n", \
101             $task, \
102             $task->tc_SigWait, \
103             $task->tc_SigRecvd, \
104             $task->tc_SPUpper - $task->tc_SPLower, \
105             $task->tc_SPUpper - $task->tc_SPReg, \
106             $task->tc_Node.ln_Pri, \
107             $task->tc_Node.ln_Type, \
108             $task->tc_Node.ln_Name
109         set $task = (struct Task *)$task->tc_Node.ln_Succ
110     end
112 document taskwait
113 List of tasks currently waiting for an event
116 define thistask
117     set $task = (struct Task *)SysBase->ThisTask
118     printf "Task     SigWait  SigRecvd StkSize   StkUsed Pri Type Name\n"
119     printf "-----------------------------------------------------------------------------\n"
120     printf "%p %p %p %8d %8d %3d  %3ld %s\n", \
121         $task, \
122         $task->tc_SigWait, \
123         $task->tc_SigRecvd, \
124         $task->tc_SPUpper - $task->tc_SPLower, \
125         $task->tc_SPUpper - $task->tc_SPReg, \
126         $task->tc_Node.ln_Pri, \
127         $task->tc_Node.ln_Type, \
128         $task->tc_Node.ln_Name
130 document thistask
131 Print out information about the currently running task.
134 define modlist
135     if Debug_ModList
136         printf "Segment           Module\n"
137         printf "---------------------------------------------------------------------\n"
139         set $segnode = (struct segment *)Debug_ModList->mlh_Head
141         while ($segnode->s_node.mln_Succ != 0)
142             printf "%p %12s %2u %32s\n", $segnode->s_lowest, $segnode->s_name, $segnode->s_num, $segnode->s_mod->mod.m_name
144             set $segnode = (struct segment *)$segnode->s_node.mln_Succ
145         end
146     end
148 document modlist
149 List of all the modules currently loaded in memory
152 define findaddr
153     set $cont = 1
155     #first search in modules loaded from disk
156     printf "Searching in the loaded modules...\n"
157     if Debug_ModList
158         set $segnode = (struct segment *)Debug_ModList->mlh_Head
160         while ($segnode->s_node.mln_Succ != 0) && $cont
161             if $arg0 >= $segnode->s_lowest && $arg0 <= $segnode->s_highest
162                 printf "Address found in %s, in segment %p.\nIf this is an executable, its .text section starts at %p.\n", $segnode->s_mod->mod.m_name, $segnode->s_seg, $segnode->s_lowest
164                 set $cont = 0
165             end
166             set $segnode = (struct segment *)$segnode->s_node.mln_Succ
167         end
168     end
170     #then in the resident list
171     if $cont
172         printf "Searching in the resident list...\n"
173     end
175     set $resp = (struct Resident **)SysBase->ResModules
176     set $i = 0
178     while (($resp)[$i] != 0) && $cont
179         set $res = ($resp)[$i]
181         if ($arg0 >= $res) && ($arg0 <= $res->rt_EndSkip)
182             printf "Address found in %s, which resides at %p\n", $res->rt_Name, $res
183             set $cont = 0
184         end
186         set $i = $i + 1
187     end
189     if $cont
190         printf "No matching module for this address\n"
191     end
193 document findaddr
194 -Shows the module that contains the given address
196 -To debug a problem in AROS, do the following:
198 -1. Get a stacktrace with bt or similar.
199 -2. Use findaddr with such an address to find out in which
200 -   module it is:
201 -3. Use add-symbol-file to load that modules symbols.
202 -4. Now you can run bt (or similar) again and you should see the
203 -   addresses resolved as symbols.
205 -Example:
207 -0x4058d45b in ?? ()
209 -(gdb) findaddr 0x4058d45b
211 -Searching in the loaded modules...
212 -Address found in Workbench:contrib/Zune/Libs/muimaster.library, which is loaded at 0x405379a4.
213 -If this is an executable, its .text section starts at 0x405379b0.
214 -(gdb) add-symbol-file contrib/Zune/Libs/muimaster.library 0x405379b0
215 -add symbol table from file "contrib/Zune/Libs/muimaster.library" at
216 -        .text_addr = 0x405379b0
217 -(y or n) y
218 -Reading symbols from contrib/Zune/Libs/muimaster.library...done.
219 -(gdb) bt
220 -#0  0x4058d45b in strlen (ptr=0x80 <Address 0x80 out of bounds>) at strlen.c:45
221 -#1  0x00000000 in lastx.78 ()
224 define printtaglist
225     set $list = (struct TagItem *)$arg0
227     printf "Tag         Data (Hex)     Data (Dec)\n"
228     printf "--------------------------------------\n"
230     while $list->ti_Tag != 0
231         # Handle the possible control tag...
232         if $list->ti_Tag == 1
233             printf "TAG_IGNORE\n"
234         else if $list->ti_Tag == 2
235             printf "TAG_MORE    %p\n", $list->ti_Data
236             set $list = (struct TagItem *)$list->ti_Data
237         else if $list->ti_Tag == 3
238             printf "TAG_SKIP    %d\n", $list->ti_Data
239             set $list = $list + $list->ti_Tag + 1
240         else
241             printf "%p  %p      %9lu\n", $list->ti_Tag, $list->ti_Data, $list->ti_Data
242             set $list = $list + 1
243         end
244     end
245     printf "TAG_DONE\n"
247 document printtaglist
249     
250 define log_to_file
251   set logging file $arg0
252   set logging redirect on
253   set logging overwrite $arg1
254   set logging on
257 define end_log
258   set logging off
261 define loadseg
262   dont-repeat
263   if Debug_ModList
264   set $step = 1
265   set $segnode = (struct segment *)Debug_ModList->mlh_Head
266   while ($segnode->s_node.mln_Succ != 0) && $step == 1
267     if $arg0 >= $segnode->s_lowest && $arg0 <= $segnode->s_highest
268       printf "%s", $segnode->s_mod->mod.m_name
269       log_to_file segname.tmp on
270       printf "%s", $segnode->s_mod->mod.m_name
271       end_log
272       shell sed -i 's/.*:\(.*\)/\1/' segname.tmp
273       log_to_file loadseg.tmp on
274       printf "add-symbol-file "
275       end_log
276       shell head -n1 segname.tmp >>loadseg.tmp
277       log_to_file loadseg.tmp off
278       printf " %p", $segnode->s_lowest
279       if $segnode->s_node.mln_Succ != 0
280         set $segnode = (struct segment *)$segnode->s_node.mln_Succ
281         while ($segnode->s_node.mln_Succ != 0) && $step < 5
282           if strcmp($segnode->s_name, ".text") == 0
283             loop_break
284           end
285           printf " -s %s %p", $segnode->s_name, $segnode->s_lowest
286           set $step = $step + 1
287           set $segnode = (struct segment *)$segnode->s_node.mln_Succ
288         end
289       end
290       end_log
291       source loadseg.tmp
292       loop_break
293     end
294     set $segnode = (struct segment *)$segnode->s_node.mln_Succ
295   end
296   if $step < 2
297     printf "no matching module for this address\n"
298   end
299   else
300     printf "no debug symbols found\n"
301   end
303 document loadseg
304 Loads the module that contains the given address
307 define seglistdump
308     set $nextseg = $arg0
309     set $count   = 1
311     printf "Hunk num. | Start addr | Size       \n"
312     printf "----------+------------+------------\n"
313     while $nextseg
314         printf "%9d | %p | %10d\n", $count, $nextseg + sizeof(BPTR), *((ULONG *)$nextseg - 1) - sizeof(BPTR)
316         set $nextseg = *(BPTR *)$nextseg
317         set $count = $count+1
318     end
320 document seglistdump
321 Shows the segments chain of the given seglist