All strings are localised in wpeditor.c
[cake.git] / _gdbinit
blob6d10690b1b22b07a591881c7bedcbed3f1b7878a
1 handle SIGUSR1 pass noprint nostop
3 define liblist
4     set $lib = SysBase->LibList.lh_Head
6     printf "Base     OpenC   Name\n"
7     printf "---------------------------------------------------------------\n"
8     while ($lib->ln_Succ != 0)
9         printf "%08x %5d   %s\n", \
10             $lib, \
11             ((struct Library *)$lib)->lib_OpenCnt, \
12             $lib->ln_Name
13         set $lib = $lib->ln_Succ
14     end
15 end
16 document liblist
17 List the current libraries in the system
18 end
20 define devlist
21     set $dev = SysBase->DeviceList.lh_Head
22     printf "Base     OpenC   Name\n"
23     printf "---------------------------------------------------------------\n"
24     while ($dev->ln_Succ != 0)
25         printf "%08x %5d   %s\n", \
26             $dev, \
27             ((struct Library *)$dev)->lib_OpenCnt, \
28             $dev->ln_Name
29         set $dev = $dev->ln_Succ
30     end
31 end
32 document devlist
33 List the current devices in the system
34 end
36 define resourcelist
37     set $res = SysBase->ResourceList.lh_Head
38     printf "Base     Name\n"
39     printf "---------------------------------------------------------------\n"
40     while ($res->ln_Succ != 0)
41         printf "%08x %s\n", $res, $res->ln_Name
42         set $res = $res->ln_Succ
43     end
44 end
45 document resourcelist
46 List the current resources in the system
47 end
49 define residentlist
50     set $resp = (struct Resident **)SysBase->ResModules
51     set $i = 0
53     printf "Address    Pri Flags Vers Type  Name\n"
54     printf "--------------------------------------------------------------\n"
55     while (($resp)[$i] != 0)
56         set $res = ($resp)[$i]
57         printf "%08x  %4d    %02x  %3d  %3d  %s\n", \
58             $res, \
59             ((struct Resident *)$res)->rt_Pri, \
60             ((struct Resident *)$res)->rt_Flags, \
61             ((struct Resident *)$res)->rt_Version, \
62             ((struct Resident *)$res)->rt_Type, \
63             ((struct Resident *)$res)->rt_Name
64         set $i = $i + 1
65     end
66 end
67 document residentlist
68 List the system resident list
69 end
71 define taskready
72     set $task = (struct Task *)SysBase->TaskReady.lh_Head
74     printf "Task     SigWait  SigRecvd StkSize   StkUsed Pri Type Name\n"
75     printf "-----------------------------------------------------------------------------\n"
76     while ($task->tc_Node.ln_Succ != 0)
77         printf "%08x %08x %08x %8d %8d %3d  %3ld %s\n", \
78             $task, \
79             $task->tc_SigWait, \
80             $task->tc_SigRecvd, \
81             $task->tc_SPUpper - $task->tc_SPLower, \
82             $task->tc_SPUpper - $task->tc_SPReg, \
83             $task->tc_Node.ln_Pri, \
84             $task->tc_Node.ln_Type, \
85             $task->tc_Node.ln_Name
86         set $task = (struct Task *)$task->tc_Node.ln_Succ
87     end
88 end
89 document taskready
90 List of tasks currently ready to run
91 end
93 define taskwait
94     set $task = (struct Task *)SysBase->TaskWait.lh_Head
96     printf "Task     SigWait  SigRecvd StkSize   StkUsed Pri Type Name\n"
97     printf "-----------------------------------------------------------------------------\n"
98     while ($task->tc_Node.ln_Succ != 0)
99         printf "%08x %08x %08x %8d %8d %3d  %3ld %s\n", \
100             $task, \
101             $task->tc_SigWait, \
102             $task->tc_SigRecvd, \
103             $task->tc_SPUpper - $task->tc_SPLower, \
104             $task->tc_SPUpper - $task->tc_SPReg, \
105             $task->tc_Node.ln_Pri, \
106             $task->tc_Node.ln_Type, \
107             $task->tc_Node.ln_Name
108         set $task = (struct Task *)$task->tc_Node.ln_Succ
109     end
111 document taskwait
112 List of tasks currently waiting for an event
115 define thistask
116     set $task = (struct Task *)SysBase->ThisTask
117     printf "Task     SigWait  SigRecvd StkSize   StkUsed Pri Type Name\n"
118     printf "-----------------------------------------------------------------------------\n"
119     printf "%08x %08x %08x %8d %8d %3d  %3ld %s\n", \
120         $task, \
121         $task->tc_SigWait, \
122         $task->tc_SigRecvd, \
123         $task->tc_SPUpper - $task->tc_SPLower, \
124         $task->tc_SPUpper - $task->tc_SPReg, \
125         $task->tc_Node.ln_Pri, \
126         $task->tc_Node.ln_Type, \
127         $task->tc_Node.ln_Name
129 document thistask
130 Print out information about the currently running task.
133 define modlist
134     if debug_seglist
135         printf "SegList  Module\n"
136         printf "---------------------------------------------------------------------\n"
138         set $segnode = (struct debug_segnode *)debug_seglist.mlh_Head
140         while ($segnode->node.mln_Succ != 0)
141             printf "%08x %s\n", $segnode->seglist, $segnode->name
143             set $segnode = (struct debug_segnode *)$segnode->node.mln_Succ
144         end
145     end
147 document modlist
148 List of all the modules currently loaded in memory
151 define findaddr
152     set $cont = 1
154     #first search in modules loaded from disk
155     printf "Searching in the loaded modules...\n"
156     if debug_seglist
157         set $segnode = (struct debug_segnode *)debug_seglist.mlh_Head
159         while ($segnode->node.mln_Succ != 0) && $cont
160             set $nextseg = $segnode->seglist
162             while $nextseg && $cont
163                 if $arg0 >= $nextseg && $arg0 <= ($nextseg + *((ULONG *)$nextseg - 1) - sizeof(BPTR))
164                     printf "Address found in %s, which is loaded at 0x%08x.\nIf this is an executable, its .text section starts at 0x%08x.\n", $segnode->name, $segnode->seglist, $segnode->start_address
166                     set $cont = 0
167                 end
169                 set $nextseg = *(BPTR *)$nextseg
170             end
172             set $segnode = (struct debug_segnode *)$segnode->node.mln_Succ
173         end
174     end
176     #then in the resident list
177     if $cont
178         printf "Searching in the resident list...\n"
179     end
181     set $resp = (struct Resident **)SysBase->ResModules
182     set $i = 0
184     while (($resp)[$i] != 0) && $cont
185         set $res = ($resp)[$i]
187         if ($arg0 >= $res) && ($arg0 <= $res->rt_EndSkip)
188             printf "Address found in %s, which resides at 0x%08x\n", $res->rt_Name, $res
189             set $cont = 0
190         end
192         set $i = $i + 1
193     end
195     if $cont
196         printf "No matching module for this address\n"
197     end
199 document findaddr
200 -Shows the module that contains the given address
202 -To debug a problem in AROS, do the following:
204 -1. Get a stacktrace with bt or similar.
205 -2. Use findaddr with such an address to find out in which
206 -   module it is:
207 -3. Use add-symbol-file to load that modules symbols.
208 -4. Now you can run bt (or similar) again and you should see the
209 -   addresses resolved as symbols.
211 -Example:
213 -0x4058d45b in ?? ()
215 -(gdb) findaddr 0x4058d45b
217 -Searching in the loaded modules...
218 -Address found in Workbench:contrib/Zune/Libs/muimaster.library, which is loaded at 0x405379a4.
219 -If this is an executable, its .text section starts at 0x405379b0.
220 -(gdb) add-symbol-file contrib/Zune/Libs/muimaster.library 0x405379b0
221 -add symbol table from file "contrib/Zune/Libs/muimaster.library" at
222 -        .text_addr = 0x405379b0
223 -(y or n) y
224 -Reading symbols from contrib/Zune/Libs/muimaster.library...done.
225 -(gdb) bt
226 -#0  0x4058d45b in strlen (ptr=0x80 <Address 0x80 out of bounds>) at strlen.c:45
227 -#1  0x00000000 in lastx.78 ()
230 define printtaglist
231     set $list = (struct TagItem *)$arg0
233     printf "Tag         Data (Hex)     Data (Dec)\n"
234     printf "--------------------------------------\n"
236     while $list->ti_Tag != 0
237         # Handle the possible control tag...
238         if $list->ti_Tag == 1
239             printf "TAG_IGNORE\n"
240         else if $list->ti_Tag == 2
241             printf "TAG_MORE    0x08%x\n", $list->ti_Data
242             set $list = (struct TagItem *)$list->ti_Data
243         else if $list->ti_Tag == 3
244             printf "TAG_SKIP    %d\n", $list->ti_Data
245             set $list = $list + $list->ti_Tag + 1
246         else
247             printf "0x%08x  0x%08x      %9lu\n", $list->ti_Tag, $list->ti_Data, $list->ti_Data
248             set $list = $list + 1
249         end
250     end
251     printf "TAG_DONE\n"
253 document printtaglist
255     
256 define log_to_file
257   set logging file $arg0
258   set logging redirect on
259   set logging overwrite $arg1
260   set logging on
263 define end_log
264   set logging off
267 define loadseg
268   dont-repeat
269   set $cont = 1
270   if debug_seglist
271     set $segnode = (struct debug_segnode *)debug_seglist.mlh_Head
272     while ($segnode->node.mln_Succ != 0) && $cont
273       set $nextseg = $segnode->seglist
274       while $nextseg && $cont
275         if $arg0 >= $nextseg && $arg0 <= ($nextseg + *((ULONG *)$nextseg - 1) - sizeof(BPTR))
276           log_to_file segname.tmp on
277           printf "%s", $segnode->name
278           end_log
279           shell sed -i 's/.*:\(.*\)/\1/' segname.tmp
280           log_to_file loadseg.tmp on
281           printf "add-symbol-file "
282           end_log
283           shell head -n1 segname.tmp >>loadseg.tmp
284           log_to_file loadseg.tmp off
285           set $seginfo = (struct seginfo *)$segnode->seginfos.mlh_Head
286           while ($seginfo->node.mln_Succ != 0)
287             if (strcmp($seginfo->name, ".text") == 0)
288               printf " 0x%08x", $seginfo->addr
289               set $cont = 0
290             else
291               printf " -s %s 0x%08x", $seginfo->name, $seginfo->addr
292             end
293             set $seginfo = (struct seginfo *)$seginfo->node.mln_Succ
294           end
295           end_log
296           if $cont == 0
297             source loadseg.tmp
298           end
299           set $cont = 0
300         end
301         set $nextseg = *(BPTR *)$nextseg
302       end
303       set $segnode = (struct debug_segnode *)$segnode->node.mln_Succ
304     end
305   end
306   if $cont
307     printf "No matching module for this address\n"
308   end
310 document loadseg
311 Loads the module that contains the given address
314 define seglistdump
315     set $nextseg = $arg0
316     set $count   = 1
318     printf "Hunk num. | Start addr | Size       \n"
319     printf "----------+------------+------------\n"
320     while $nextseg
321         printf "%9d | 0x%08x | %10d\n", $count, $nextseg + sizeof(BPTR), *((ULONG *)$nextseg - 1) - sizeof(BPTR)
323         set $nextseg = *(BPTR *)$nextseg
324         set $count = $count+1
325     end
327 document seglistdump
328 Shows the segments chain of the given seglist