1 handle SIGUSR1 pass noprint nostop
2 handle SIGUSR2 pass noprint nostop
3 set follow-fork-mode child
6 set $lib = ((struct ExecBase *)SysBase)->LibList.lh_Head
8 printf "Base OpenC Name\n"
9 printf "---------------------------------------------------------------\n"
10 while ($lib->ln_Succ != 0)
11 printf "%p %5d %s\n", \
13 ((struct Library *)$lib)->lib_OpenCnt, \
15 set $lib = $lib->ln_Succ
19 List the current libraries in the system
23 set $dev = ((struct ExecBase *)SysBase)->DeviceList.lh_Head
24 printf "Base OpenC Name\n"
25 printf "---------------------------------------------------------------\n"
26 while ($dev->ln_Succ != 0)
27 printf "%p %5d %s\n", \
29 ((struct Library *)$dev)->lib_OpenCnt, \
31 set $dev = $dev->ln_Succ
35 List the current devices in the system
39 set $res = ((struct ExecBase *)SysBase)->ResourceList.lh_Head
41 printf "---------------------------------------------------------------\n"
42 while ($res->ln_Succ != 0)
43 printf "%p %s\n", $res, $res->ln_Name
44 set $res = $res->ln_Succ
48 List the current resources in the system
52 set $resp = (struct Resident **)((struct ExecBase *)SysBase)->ResModules
55 printf "Address Pri Flags Vers Type Name\n"
56 printf "--------------------------------------------------------------\n"
57 while (($resp)[$i] != 0)
58 set $res = ($resp)[$i]
59 printf "%p %4d %02x %3d %3d %s\n", \
61 ((struct Resident *)$res)->rt_Pri, \
62 ((struct Resident *)$res)->rt_Flags, \
63 ((struct Resident *)$res)->rt_Version, \
64 ((struct Resident *)$res)->rt_Type, \
65 ((struct Resident *)$res)->rt_Name
70 List the system resident list
74 set $task = (struct Task *)((struct ExecBase *)SysBase)->TaskReady.lh_Head
76 printf "Task SigWait SigRecvd StkSize StkUsed Pri Type Name\n"
77 printf "-----------------------------------------------------------------------------\n"
78 while ($task->tc_Node.ln_Succ != 0)
79 printf "%p %p %p %8d %8d %3d %3ld %s\n", \
83 $task->tc_SPUpper - $task->tc_SPLower, \
84 $task->tc_SPUpper - $task->tc_SPReg, \
85 $task->tc_Node.ln_Pri, \
86 $task->tc_Node.ln_Type, \
87 $task->tc_Node.ln_Name
88 set $task = (struct Task *)$task->tc_Node.ln_Succ
92 List of tasks currently ready to run
96 set $task = (struct Task *)((struct ExecBase *)SysBase)->TaskWait.lh_Head
98 printf "Task SigWait SigRecvd StkSize StkUsed Pri Type Name\n"
99 printf "-----------------------------------------------------------------------------\n"
100 while ($task->tc_Node.ln_Succ != 0)
101 printf "%p %p %p %8d %8d %3d %3ld %s\n", \
104 $task->tc_SigRecvd, \
105 $task->tc_SPUpper - $task->tc_SPLower, \
106 $task->tc_SPUpper - $task->tc_SPReg, \
107 $task->tc_Node.ln_Pri, \
108 $task->tc_Node.ln_Type, \
109 $task->tc_Node.ln_Name
110 set $task = (struct Task *)$task->tc_Node.ln_Succ
114 List of tasks currently waiting for an event
118 set $task = (struct Task *)((struct ExecBase *)SysBase)->ThisTask
119 printf "Task SigWait SigRecvd StkSize StkUsed Pri Type Name\n"
120 printf "-----------------------------------------------------------------------------\n"
121 printf "%p %p %p %8d %8d %3d %3ld %s\n", \
124 $task->tc_SigRecvd, \
125 $task->tc_SPUpper - $task->tc_SPLower, \
126 $task->tc_SPUpper - $task->tc_SPReg, \
127 $task->tc_Node.ln_Pri, \
128 $task->tc_Node.ln_Type, \
129 $task->tc_Node.ln_Name
132 Print out information about the currently running task.
136 printf "Segment Module\n"
139 printf "---------------------------------------------------------------------\n"
140 set $segnode = (struct segment *)Debug_ModList->mlh_Head
142 while ($segnode->s_node.mln_Succ != 0)
143 printf "%p %12s %2u %32s\n", $segnode->s_lowest, $segnode->s_name, $segnode->s_num, $segnode->s_mod->m_name
145 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
149 printf "---------------------------------------------------------------------\n"
150 set $kicknode = Debug_KickList
152 while ($kicknode != 0)
153 set $eh = $kicknode->eh
154 set $sh = $kicknode->sh
155 set $shnum = $eh->shnum
159 if ($sh->addr != 0) && ($sh->size != 0)
160 printf "%p %2u %32s\n", $sh->addr, $i, $kicknode->Name
165 set $kicknode = $kicknode->Next
169 List of all the modules currently loaded in memory
175 #first search in modules loaded from disk
176 printf "Searching in the loaded modules...\n"
178 set $segnode = (struct segment *)Debug_ModList->mlh_Head
180 while ($segnode->s_node.mln_Succ != 0) && $cont
181 if $arg0 >= $segnode->s_lowest && $arg0 <= $segnode->s_highest
182 printf "Address found in %s, in segment %p.\nIf this is an executable, its .text section starts at %p.\n", $segnode->s_mod->m_name, $segnode->s_seg, $segnode->s_lowest
186 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
191 printf "Searching in the kickstart list...\n"
192 set $kicknode = Debug_KickList
194 while ($kicknode != 0) && $cont
195 set $eh = $kicknode->eh
196 set $sh = $kicknode->sh
197 set $shnum = $eh->shnum
200 while ($i < $shnum) && $cont
201 if ($sh->addr != 0) && ($sh->size != 0)
202 set $lowest = $sh->addr
203 set $highest = $sh->addr + $sh->size - 1
205 if $arg0 >= $lowest && $arg0 <= $highest
206 printf "Address found in %s in section number %d starting at %p.\n", $kicknode->Name, $i, $lowest
214 set $kicknode = $kicknode->Next
218 #then in the resident list
220 printf "Searching in the resident list...\n"
223 set $resp = (struct Resident **)((struct ExecBase *)SysBase)->ResModules
226 while (($resp)[$i] != 0) && $cont
227 set $res = ($resp)[$i]
229 if ($arg0 >= $res) && ($arg0 <= $res->rt_EndSkip)
230 printf "Address found in %s, which resides at %p\n", $res->rt_Name, $res
238 printf "No matching module for this address\n"
242 -Shows the module that contains the given address
244 -To debug a problem in AROS, do the following:
246 -1. Get a stacktrace with bt or similar.
247 -2. Use findaddr with such an address to find out in which
249 -3. Use add-symbol-file to load that modules symbols.
250 -4. Now you can run bt (or similar) again and you should see the
251 - addresses resolved as symbols.
257 -(gdb) findaddr 0x4058d45b
259 -Searching in the loaded modules...
260 -Address found in Workbench:contrib/Zune/Libs/muimaster.library, which is loaded at 0x405379a4.
261 -If this is an executable, its .text section starts at 0x405379b0.
262 -(gdb) add-symbol-file contrib/Zune/Libs/muimaster.library 0x405379b0
263 -add symbol table from file "contrib/Zune/Libs/muimaster.library" at
264 - .text_addr = 0x405379b0
266 -Reading symbols from contrib/Zune/Libs/muimaster.library...done.
268 -#0 0x4058d45b in strlen (ptr=0x80 <Address 0x80 out of bounds>) at strlen.c:45
269 -#1 0x00000000 in lastx.78 ()
273 set $list = (struct TagItem *)$arg0
275 printf "Tag Data (Hex) Data (Dec)\n"
276 printf "--------------------------------------\n"
278 while $list->ti_Tag != 0
279 # Handle the possible control tag...
280 if $list->ti_Tag == 1
281 printf "TAG_IGNORE\n"
282 else if $list->ti_Tag == 2
283 printf "TAG_MORE %p\n", $list->ti_Data
284 set $list = (struct TagItem *)$list->ti_Data
285 else if $list->ti_Tag == 3
286 printf "TAG_SKIP %d\n", $list->ti_Data
287 set $list = $list + $list->ti_Tag + 1
289 printf "%p %p %9lu\n", $list->ti_Tag, $list->ti_Data, $list->ti_Data
290 set $list = $list + 1
295 document printtaglist
299 set logging file $arg0
300 set logging redirect on
301 set logging overwrite $arg1
313 set $segnode = (struct segment *)Debug_ModList->mlh_Head
314 while ($segnode->s_node.mln_Succ != 0) && $step == 1
315 if $arg0 >= $segnode->s_lowest && $arg0 <= $segnode->s_highest
316 log_to_file segname.tmp on
317 printf "%s", $segnode->s_mod->m_name
319 shell sed -i 's/.*:\(.*\)/\1/' segname.tmp
320 log_to_file loadseg.tmp on
321 printf "add-symbol-file "
323 shell head -n1 segname.tmp >>loadseg.tmp
324 log_to_file loadseg.tmp off
325 printf " %p", $segnode->s_lowest
326 if $segnode->s_node.mln_Succ != 0
327 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
328 while ($segnode->s_node.mln_Succ != 0) && $step < 5
329 if strcmp($segnode->s_name, ".text") == 0
332 printf " -s %s %p", $segnode->s_name, $segnode->s_lowest
333 set $step = $step + 1
334 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
341 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
344 set $kicknode = Debug_KickList
346 while ($kicknode != 0) && $step == 1
347 set $eh = $kicknode->eh
348 set $sh = $kicknode->sh
349 set $shnum = $eh->shnum
352 while ($i < $shnum) && $cont
353 if ($sh->addr != 0) && ($sh->size != 0)
354 set $lowest = $sh->addr
355 set $highest = $sh->addr + $sh->size - 1
357 if $arg0 >= $lowest && $arg0 <= $highest
359 set $shstrndx = $eh->shstrndx
362 if ($shstrndx < 0xFF00)
363 set $shstr = $shstrndx
364 if ($shstrndx > 0xFFFF)
365 set $shstr = $shstrndx - (0x10000 - 0xFF00)
367 log_to_file segname.tmp on
368 printf "%s", $kicknode->s_module.m_name
370 shell sed -i 's/.*:\(.*\)/\1/' segname.tmp
371 log_to_file loadseg.tmp on
372 printf "add-symbol-file "
374 shell head -n1 segname.tmp >>loadseg.tmp
375 log_to_file loadseg.tmp off
376 printf " %p", $s_lowest
381 if ($sh->addr != 0) && ($sh->size != 0)
382 set $segname = $kicknode->sh[$shstr] + $sh->name
383 printf " -s %s %p", $segname, $sh->addr
385 set $step = $step + 1
397 set $kicknode = $kicknode->Next
401 printf "no matching module for this address\n"
403 printf "no debug symbols found\n"
407 Loads the module that contains the given address
414 printf "Hunk num. | Start addr | Size \n"
415 printf "----------+------------+------------\n"
417 printf "%9d | %p | %10d\n", $count, $nextseg + sizeof(BPTR), *((ULONG *)$nextseg - 1) - sizeof(BPTR)
419 set $nextseg = *(BPTR *)$nextseg
420 set $count = $count+1
424 Shows the segments chain of the given seglist