Re: [hatari-devel] Basepage and proc_lives debugging from the debugger |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Am Fri, 15 Nov 2019 12:52:28 +0100
schrieb Matthias Arndt <marndt@xxxxxxxxxxxxxx>:
> Am Thu, 14 Nov 2019 16:22:08 -0500
> schrieb "Roger Burrows" <anodyne@xxxxxxxxxxxx>:
>
> > > > proc_lives is still another matter.
> > > >
> > > > Can the info item be extended? If yes, I might try to implement
> > > > the decoder and contribute a patch to Hatari.
> > >
> > > What's proc_lives and is it something supported by all TOS
> > > versions (from 1.00 to 4.x, and by EmuTOS)?
> > >
> > It's location 0x380 in low-memory. It has a value of 0x12345678 if
> > the subsequent longs contain a valid saved processor state after a
> > system crash. I don't know why the OP can't just display 0x380.
> >
> > Roger
>
> Readability and convenience to distinguish individual register values.
> In a hexdump I have to guess which bytes belongs to which long.
>
> I will contribute the patch later on.
>
> The locations are standard for TOS 1.0 onward and described very well
> in the Atari ST Profibuch, even the first edition.
The "Hitchhiker’s Guide to the Bios" calls this Post mortem information
so my patch reflects this Atari side wording:
I have added a postmortem command to the info.
Example:
> info postmortem
Post mortem information:
D0: $00000042 D1: $43540000 D2: $00000000 D3: $00000000
D4: $00000000 D5: $00000000 D6: $00000000 D7: $00000000
A0: $00000000 A1: $00000000 A2: $00000000 A3: $00000000
A4: $00000000 A5: $00000000 A6: $00000000 A7: $00000000
PC: $000200A5 USP: $00000000
Exception number: $02
Feel free to edit my patch for anything that is not to common Hatari
standards. It has been a long time for a code contribution on my end.
I would also like to ask if the debugger can display automatically on
exception? It makes it easier for the more occasional user of the
debugger.
Best regards,
Matthias
--
http://final-memory.org/
diff --git a/src/debug/debugInfo.c b/src/debug/debugInfo.c
index aeec02e1..f73a8ff4 100644
--- a/src/debug/debugInfo.c
+++ b/src/debug/debugInfo.c
@@ -402,6 +402,51 @@ static void DebugInfo_Cookiejar(FILE *fp, Uint32 dummy)
fprintf(fp, "%d items at 0x%06x.\n", items, STMemory_ReadLong(COOKIE_JAR));
}
+/**
+ * DebugInfo_PostMortem: show TOS post mortem information if valid
+ * See chapter "Post mortem information" in "A Hitchiker's Guide to the BIOS"
+ */
+static void DebugInfo_PostMortem(FILE *fp, Uint32 dummy)
+{
+ const Uint32 postmortem_magic = STMemory_ReadLong(0x00000380);
+ Uint32 proc_pc;
+
+ if(postmortem_magic != 0x12345678)
+ {
+ fprintf(fp, "proc_lives != $12345678, Post mortem information not available.\n");
+ return;
+ }
+
+ char regstr[] = " D";
+ fprintf(fp, "Post mortem information $00000380 and ff.:\n");
+ for(Uint8 r = 0; r < 16; r ++)
+ {
+ if(r < 8)
+ {
+ regstr[3] = 'D';
+ }
+ else
+ {
+ regstr[3] = 'A';
+ }
+
+ fprintf(fp, "%s%1d: $%08X", regstr, (r % 8), STMemory_ReadLong(0x00000384 + (4 * r)));
+
+ if((r % 4) == 3)
+ {
+ fprintf(fp, "\n");
+ }
+ else
+ {
+ fprintf(fp, " ");
+ }
+ }
+
+ proc_pc = STMemory_ReadLong(0x000003C4);
+
+ fprintf(fp, " PC: $%08X USP: $%08X\n", (proc_pc & 0x00FFFFFF), STMemory_ReadLong(0x000003C8));
+ fprintf(fp, " Exception number: $%02X\n", (proc_pc >> 24));
+}
/* ------------------------------------------------------------------
* CPU and DSP information wrappers
@@ -667,12 +712,13 @@ static const struct {
{ true, "dspmemdump",DebugInfo_DspMemDump, DebugInfo_DspMemArgs, "Dump DSP memory from given <space> <address>" },
{ true, "dspregs", DebugInfo_DspRegister,NULL, "Show DSP register contents" },
#endif
- { false, "dta", DebugInfo_DTA, NULL, "Show current [or given]Â DTA information" },
+ { false, "dta", DebugInfo_DTA, NULL, "Show current [or given] DTA information" },
{ true, "file", DebugInfo_FileParse, DebugInfo_FileArgs, "Parse commands from given debugger input <file>" },
{ false,"gemdos", GemDOS_Info, NULL, "Show GEMDOS HDD emu information (with <value>, show opcodes)" },
{ true, "history", History_Show, NULL, "Show history of last <count> instructions" },
{ true, "memdump", DebugInfo_CpuMemDump, NULL, "Dump CPU memory from given <address>" },
{ false,"osheader", DebugInfo_OSHeader, NULL, "Show TOS OS header contents" },
+ { false,"postmortem", DebugInfo_PostMortem, NULL, "Show TOS Post mortem information" },
{ true, "regaddr", DebugInfo_RegAddr, DebugInfo_RegAddrArgs, "Show <disasm|memdump> from CPU/DSP address pointed by <register>" },
{ true, "registers", DebugInfo_CpuRegister,NULL, "Show CPU register contents" },
{ false,"vdi", VDI_Info, NULL, "Show VDI vector contents (with <value>, show opcodes)" },