[hatari-devel] patch for memory command to follow count and range values |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: [hatari-devel] patch for memory command to follow count and range values
- From: "J.Young" <jyoung8299@xxxxxxxxxx>
- Date: Tue, 27 Feb 2024 23:15:49 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1709075751; bh=rGt1D5wImLLE4NrVzebRGi5890oJOFGw5xYTeUwyvZQ=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:From:From; b=eMXhco7GdKyaaKxRG2MBnBAU2VGOEHBof8fZnGv+rexwFrACdf2RD8fvP2AyhCQNC WcytX4TBQR8zjX8bcl4Oz7nwkoKW9osUMBEtVDhF34GT6JPIayuwD392TGfJxnGm3V aMtE4grIrETxBATdG+dYLjxmF6X8czdSCuSl6O6qJA/3p12Uzcihr/T6+5QgAvKkik 1ciRRCYbw3R6JusnkgfdFXym8Xh9NzIcnXi4BQoh/RzYTj7hQnFKWl1BON1lcuJV5k sFMxMbRW0YyHVJopywqsxHcetA/ckklokBsZWPulQAg0bOELxww3hofS+XKbrskUb5 HOlm+df7ByRUQ==
I brought up the issue on another message that the 'm' command in the
debugger would only output on line boundaries.
For instance "m b pc 1" would output an entire line instead of one byte.
Also, "m b 400-402" would output an entire line instead of 2 bytes. Same
for word and long entries.
Attached is a patch to src/debug/debugcpu.c that corrects the memory
dump routine to respect count and range values.
Tested here, but of course please try it out to see if it needs any
adjustments.
Jeff
--- debugcpu.c-orig 2024-02-27 17:49:22.135538000 -0500
+++ debugcpu.c 2024-02-27 17:46:21.136202116 -0500
@@ -455,6 +455,7 @@
char c, mode;
int i, arg, size;
uint32_t value, memdump_upper = 0;
+ int count = 0;
arg = 1;
mode = 0;
@@ -505,7 +506,7 @@
if (nArgc > arg)
{
- int count = atoi(psArgs[arg]);
+ count = atoi(psArgs[arg]);
if (!count)
{
fprintf(stderr, "Invalid count %d!\n", count);
@@ -515,18 +516,28 @@
}
}
+ int outputcount = MEMDUMP_COLS/size;
if (!memdump_upper)
{
int lines = DebugUI_GetPageLines(ConfigureParams.Debugger.nMemdumpLines, 8);
memdump_upper = memdump_addr + MEMDUMP_COLS * lines;
}
+
+ if(count > 0)
+ outputcount = count;
+ else
+ outputcount = memdump_upper - memdump_addr;
+ int outputline = MEMDUMP_COLS/size;
while (memdump_addr < memdump_upper)
{
fprintf(debugOutput, "%08X: ", memdump_addr);
+ if(outputcount < outputline)
+ outputline = outputcount;
+
/* print HEX data */
- for (i = 0; i < MEMDUMP_COLS/size; i++)
+ for (i = 0; i < outputline; i++)
{
switch (mode)
{
@@ -544,17 +555,22 @@
fprintf(debugOutput, "%0*x ", 2*size, value);
memdump_addr += size;
}
+ if(outputline < MEMDUMP_COLS/size)
+ for (i = 0; i < (((size * 2) + 1) * ((MEMDUMP_COLS / size) - outputline)); i++)
+ fprintf(debugOutput, "%c", ' ');
/* print ASCII data */
fprintf(debugOutput, " ");
- for (i = 0; i < MEMDUMP_COLS; i++)
+ for (i = 0; i < outputline * size; i++)
{
- c = STMemory_ReadByte(memdump_addr-MEMDUMP_COLS+i);
+ c = STMemory_ReadByte(memdump_addr-(outputline*size)+i);
if(!isprint((unsigned)c))
c = NON_PRINT_CHAR; /* non-printable as dots */
fprintf(debugOutput,"%c", c);
}
fprintf(debugOutput, "\n");
+
+ outputcount -= outputline;
}
fflush(debugOutput);