2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
5 Desc: Alert context parsing routines
9 #include <exec/rawfmt.h>
10 #include <libraries/debug.h>
11 #include <proto/debug.h>
13 #include "exec_intern.h"
14 #include "exec_util.h"
18 #define TRACE_DEPTH 10
20 static const char modstring
[] = "\n0x%P %s Segment %lu %s + 0x%P";
21 static const char funstring
[] = "\n0x%P %s Function %s + 0x%P";
22 static const char unknownstr
[] = "\n0x%P Address not found";
23 static const char invalidstr
[] = "\n0x%P Invalid stack frame address";
26 * Make a readable text out of task's alert context
27 * The supplied buffer pointer points to the end of already existing
28 * text, so we start every our line with '\n'.
30 void FormatAlertExtra(char *buffer
, APTR stack
, UBYTE type
, APTR data
, struct ExecBase
*SysBase
)
37 buf
= Alert_AddString(buf
, "\nCPU context:\n");
38 buf
= FormatCPUContext(buf
, data
, SysBase
);
43 buf
= Alert_AddString(buf
, "\nMungwall data:\n");
44 buf
= FormatMWContext(buf
, data
, SysBase
);
49 buf
= Alert_AddString(buf
, "\nMemory manager data:\n");
50 buf
= FormatMMContext(buf
, data
, SysBase
);
56 /* If we have AlertStack, compose a backtrace */
62 buf
= Alert_AddString(buf
, "\nStack trace:");
64 for (i
= 0; i
< TRACE_DEPTH
; i
++)
66 /* Safety check: ensure that frame pointer address is valid */
70 char *modname
, *segname
, *symname
;
71 void *segaddr
, *symaddr
;
74 fp
= UnwindFrame(fp
, &caller
);
76 if (DebugBase
&& DecodeLocation(caller
,
77 DL_ModuleName
, &modname
, DL_SegmentNumber
, &segnum
,
78 DL_SegmentName
, &segname
, DL_SegmentStart
, &segaddr
,
79 DL_SymbolName
, &symname
, DL_SymbolStart
, &symaddr
,
85 symname
= "- unknown -";
87 buf
= NewRawDoFmt(funstring
, RAWFMTFUNC_STRING
, buf
, caller
, modname
, symname
, caller
- symaddr
);
92 segname
= "- unknown -";
94 buf
= NewRawDoFmt(modstring
, RAWFMTFUNC_STRING
, buf
, caller
, modname
, segnum
, segname
, caller
- segaddr
);
98 buf
= NewRawDoFmt(unknownstr
, RAWFMTFUNC_STRING
, buf
, caller
);
102 /* Invalid address stops unwinding */
103 buf
= NewRawDoFmt(invalidstr
, RAWFMTFUNC_STRING
, buf
, fp
);
107 /* Stop if we have no more frames */
112 * After NewRawDoFmt() returned pointer points to the location AFTER
113 * NULL terminator, so we need to step back in order to append one