1 handle SIGUSR1 pass noprint nostop
2 handle SIGUSR2 pass noprint nostop
3 set follow-fork-mode child
6 init-if-undefined $AbsExecBase = (struct ExecBase *)SysBase
9 set $AbsExecBase = *(struct IntExecBase **)&AbsExecBase
10 set $_debug_DebugBase = (struct DebugBase *)($AbsExecBase->DebugBase)
12 if $_debug_DebugBase != 0
13 set $_debug_ModList = $_debug_DebugBase->db_Modules
14 set $_debug_KickList = $_debug_DebugBase->db_KernelModules
17 init-if-undefined $_debug_ModList = Debug_ModList
18 init-if-undefined $_debug_KickList = Debug_KickList
22 Initialize debugging convenience variables
27 set $lib = ((struct ExecBase *)$AbsExecBase)->LibList.lh_Head
29 printf "Base OpenC Name\n"
30 printf "---------------------------------------------------------------\n"
31 while ($lib->ln_Succ != 0)
32 printf "%p %5d %s\n", \
34 ((struct Library *)$lib)->lib_OpenCnt, \
36 set $lib = $lib->ln_Succ
40 List the current libraries in the system
45 set $dev = ((struct ExecBase *)$AbsExecBase)->DeviceList.lh_Head
46 printf "Base OpenC Name\n"
47 printf "---------------------------------------------------------------\n"
48 while ($dev->ln_Succ != 0)
49 printf "%p %5d %s\n", \
51 ((struct Library *)$dev)->lib_OpenCnt, \
53 set $dev = $dev->ln_Succ
57 List the current devices in the system
62 set $res = ((struct ExecBase *)$AbsExecBase)->ResourceList.lh_Head
64 printf "---------------------------------------------------------------\n"
65 while ($res->ln_Succ != 0)
66 printf "%p %s\n", $res, $res->ln_Name
67 set $res = $res->ln_Succ
71 List the current resources in the system
76 set $resp = (struct Resident **)((struct ExecBase *)$AbsExecBase)->ResModules
79 printf "Address Pri Flags Vers Type Name\n"
80 printf "--------------------------------------------------------------\n"
81 while (($resp)[$i] != 0)
82 set $res = ($resp)[$i]
83 printf "%p %4d %02x %3d %3d %s\n", \
85 ((struct Resident *)$res)->rt_Pri, \
86 ((struct Resident *)$res)->rt_Flags, \
87 ((struct Resident *)$res)->rt_Version, \
88 ((struct Resident *)$res)->rt_Type, \
89 ((struct Resident *)$res)->rt_Name
94 List the system resident list
99 set $task = (struct Task *)((struct ExecBase *)$AbsExecBase)->TaskReady.lh_Head
101 printf "Task SigWait SigRecvd StkSize StkUsed Pri Type Name\n"
102 printf "-----------------------------------------------------------------------------\n"
103 while ($task->tc_Node.ln_Succ != 0)
104 printf "%p %p %p %8d %8d %3d %3ld %s\n", \
107 $task->tc_SigRecvd, \
108 $task->tc_SPUpper - $task->tc_SPLower, \
109 $task->tc_SPUpper - $task->tc_SPReg, \
110 $task->tc_Node.ln_Pri, \
111 $task->tc_Node.ln_Type, \
112 $task->tc_Node.ln_Name
113 set $task = (struct Task *)$task->tc_Node.ln_Succ
117 List of tasks currently ready to run
122 set $task = (struct Task *)((struct ExecBase *)$AbsExecBase)->TaskWait.lh_Head
124 printf "Task SigWait SigRecvd StkSize StkUsed Pri Type Name\n"
125 printf "-----------------------------------------------------------------------------\n"
126 while ($task->tc_Node.ln_Succ != 0)
127 printf "%p %p %p %8d %8d %3d %3ld %s\n", \
130 $task->tc_SigRecvd, \
131 $task->tc_SPUpper - $task->tc_SPLower, \
132 $task->tc_SPUpper - $task->tc_SPReg, \
133 $task->tc_Node.ln_Pri, \
134 $task->tc_Node.ln_Type, \
135 $task->tc_Node.ln_Name
136 set $task = (struct Task *)$task->tc_Node.ln_Succ
140 List of tasks currently waiting for an event
145 set $task = (struct Task *)((struct ExecBase *)$AbsExecBase)->ThisTask
146 printf "Task SigWait SigRecvd StkSize StkUsed Pri Type Name\n"
147 printf "-----------------------------------------------------------------------------\n"
148 printf "%p %p %p %8d %8d %3d %3ld %s\n", \
151 $task->tc_SigRecvd, \
152 $task->tc_SPUpper - $task->tc_SPLower, \
153 $task->tc_SPUpper - $task->tc_SPReg, \
154 $task->tc_Node.ln_Pri, \
155 $task->tc_Node.ln_Type, \
156 $task->tc_Node.ln_Name
159 Print out information about the currently running task.
164 printf "Segment Module\n"
167 printf "---------------------------------------------------------------------\n"
168 set $segnode = (struct segment *)$_debug_ModList->mlh_Head
170 while ($segnode->s_node.mln_Succ != 0)
171 printf "%p %12s %2u %32s\n", $segnode->s_lowest, $segnode->s_name, $segnode->s_num, $segnode->s_mod->m_name
173 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
177 printf "---------------------------------------------------------------------\n"
178 set $kicknode = $_debug_KickList
180 while ($kicknode != 0)
181 set $eh = $kicknode->eh
182 set $sh = $kicknode->sh
183 set $shnum = $eh->shnum
187 if ($sh->addr != 0) && ($sh->size != 0)
188 printf "%p %2u %32s\n", $sh->addr, $i, $kicknode->Name
193 set $kicknode = $kicknode->Next
197 List of all the modules currently loaded in memory
204 #first search in modules loaded from disk
205 printf "Searching in the loaded modules...\n"
207 set $segnode = (struct segment *)$_debug_ModList->mlh_Head
209 while ($segnode->s_node.mln_Succ != 0) && $cont
210 if $arg0 >= $segnode->s_lowest && $arg0 <= $segnode->s_highest
211 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
215 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
220 printf "Searching in the kickstart list...\n"
221 set $kicknode = $_debug_KickList
223 while ($kicknode != 0) && $cont
224 set $eh = $kicknode->eh
225 set $sh = $kicknode->sh
226 set $shnum = $eh->shnum
229 while ($i < $shnum) && $cont
230 if ($sh->addr != 0) && ($sh->size != 0)
231 set $lowest = $sh->addr
232 set $highest = $sh->addr + $sh->size - 1
234 if $arg0 >= $lowest && $arg0 <= $highest
235 printf "Address found in %s in section number %d starting at %p.\n", $kicknode->Name, $i, $lowest
243 set $kicknode = $kicknode->Next
247 #then in the resident list
249 printf "Searching in the resident list...\n"
252 set $resp = (struct Resident **)((struct ExecBase *)$AbsExecBase)->ResModules
255 while (($resp)[$i] != 0) && $cont
256 set $res = ($resp)[$i]
258 if ($arg0 >= $res) && ($arg0 <= $res->rt_EndSkip)
259 printf "Address found in %s, which resides at %p\n", $res->rt_Name, $res
267 printf "No matching module for this address\n"
271 -Shows the module that contains the given address
273 -To debug a problem in AROS, do the following:
275 -1. Get a stacktrace with bt or similar.
276 -2. Use findaddr with such an address to find out in which
278 -3. Use add-symbol-file to load that modules symbols.
279 -4. Now you can run bt (or similar) again and you should see the
280 - addresses resolved as symbols.
286 -(gdb) findaddr 0x4058d45b
288 -Searching in the loaded modules...
289 -Address found in Workbench:contrib/Zune/Libs/muimaster.library, which is loaded at 0x405379a4.
290 -If this is an executable, its .text section starts at 0x405379b0.
291 -(gdb) add-symbol-file contrib/Zune/Libs/muimaster.library 0x405379b0
292 -add symbol table from file "contrib/Zune/Libs/muimaster.library" at
293 - .text_addr = 0x405379b0
295 -Reading symbols from contrib/Zune/Libs/muimaster.library...done.
297 -#0 0x4058d45b in strlen (ptr=0x80 <Address 0x80 out of bounds>) at strlen.c:45
298 -#1 0x00000000 in lastx.78 ()
302 set $list = (struct TagItem *)$arg0
304 printf "Tag Data (Hex) Data (Dec)\n"
305 printf "--------------------------------------\n"
307 while $list->ti_Tag != 0
308 # Handle the possible control tag...
309 if $list->ti_Tag == 1
310 printf "TAG_IGNORE\n"
311 else if $list->ti_Tag == 2
312 printf "TAG_MORE %p\n", $list->ti_Data
313 set $list = (struct TagItem *)$list->ti_Data
314 else if $list->ti_Tag == 3
315 printf "TAG_SKIP %d\n", $list->ti_Data
316 set $list = $list + $list->ti_Tag + 1
318 printf "%p %p %9lu\n", $list->ti_Tag, $list->ti_Data, $list->ti_Data
319 set $list = $list + 1
324 document printtaglist
328 set logging file $arg0
329 set logging redirect on
330 set logging overwrite $arg1
343 set $segnode = (struct segment *)$_debug_ModList->mlh_Head
344 while ($segnode->s_node.mln_Succ != 0) && $step == 1
345 if $arg0 >= $segnode->s_lowest && $arg0 <= $segnode->s_highest
346 log_to_file segname.tmp on
347 printf "%s", $segnode->s_mod->m_name
349 shell sed -i 's/.*:\(.*\)/\1/' segname.tmp
350 log_to_file loadseg.tmp on
351 printf "add-symbol-file "
353 shell head -n1 segname.tmp >>loadseg.tmp
354 log_to_file loadseg.tmp off
355 printf " %p", $segnode->s_lowest
356 if $segnode->s_node.mln_Succ != 0
357 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
358 while ($segnode->s_node.mln_Succ != 0) && $step < 5
359 if strcmp($segnode->s_name, ".text") == 0
362 printf " -s %s %p", $segnode->s_name, $segnode->s_lowest
363 set $step = $step + 1
364 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
371 set $segnode = (struct segment *)$segnode->s_node.mln_Succ
376 set $kicknode = $_debug_KickList
378 while ($kicknode != 0) && $step == 1
379 set $eh = $kicknode->eh
380 set $sh = $kicknode->sh
381 set $shnum = $eh->shnum
385 if ($sh->addr != 0) && ($sh->size != 0)
386 set $lowest = $sh->addr
387 set $highest = $sh->addr + $sh->size - 1
389 if $arg0 >= $lowest && $arg0 <= $highest
390 set $shstrndx = $eh->shstrndx
393 if ($shstrndx < 0xFF00)
394 set $shstr = $shstrndx
396 if ($shstrndx > 0xFFFF)
397 set $shstr = $shstrndx - (0x10000 - 0xFF00)
400 log_to_file segname.tmp on
401 printf "%s", $kicknode->Name
403 shell sed -i 's/.*:\(.*\)/\1/' segname.tmp
404 log_to_file loadseg.tmp on
405 printf "add-symbol-file "
407 shell head -n1 segname.tmp >>loadseg.tmp
408 log_to_file loadseg.tmp off
409 printf " %p", $lowest
415 if ($sh->addr != 0) && ($sh->size != 0)
416 # This code does not work, cause error. I have no knowledge on how to make it work.
417 # set $segname = $kicknode->sh[$shstr] + $sh->name
418 # printf " -s %s %p", $segname, $sh->addr
420 set $step = $step + 1
434 set $kicknode = $kicknode->Next
439 printf "No matching module for this address\n"
446 Loads the module that contains the given address
454 printf "Hunk num. | Start addr | Size \n"
455 printf "----------+------------+------------\n"
457 printf "%9d | %p | %10d\n", $count, $nextseg + sizeof(BPTR), *((ULONG *)$nextseg - 1) - sizeof(BPTR)
459 set $nextseg = *(BPTR *)$nextseg
460 set $count = $count+1
464 Shows the segments chain of the given seglist