Re: [hatari-devel] VBR as a breakpoint condition

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 09/06/2018 09:57 PM, Miro Kropáček wrote:
Hi there,

is there a way how to achieve something like

b vbr ! vbr

I.e. I'm interested in situations when VBR has been changed.
Currently the debugger complains about invalid string.

Please try the attached patch.

Assuming VBR, and rest of the special regs I added, don't
need any special access functions (like SR & PC need),
they "should" work fine with just that.

Only downside to adding new regs to debugger is if their
names would conflict with some program debug symbols,
because register names take always precedence over debug
symbols in the Hatari debugger.


	- Eero
diff -r 6acf184b3679 src/debug/debugcpu.c
--- a/src/debug/debugcpu.c	Mon Aug 27 00:02:33 2018 +0300
+++ b/src/debug/debugcpu.c	Thu Sep 06 23:31:17 2018 +0300
@@ -221,9 +221,11 @@
 {
 	static const char* regs[] = {
 		"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+		"caar", "cacr",
 		"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
-		"pc", "sr",
-		"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7"		
+		"dfc", "isp", "msp", "pc", "sfc", "sr", "usp",
+		"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
+		"vbr"
 	};
 	return DebugUI_MatchHelper(regs, ARRAY_SIZE(regs), text, state);
 }
@@ -242,9 +244,37 @@
 	char r0;
 	int r1;
 
-	if (!reg[0] || !reg[1] || reg[2])
+	if (!reg[0] || !reg[1])
 		return 0;
 
+	if (reg[2])
+	{
+		/* 3-4 letter regs */
+		static const struct {
+			const char name[5];
+			Uint32 *addr;
+		} reg3_ptrs[] = {
+			{ "CAAR", &regs.caar },
+			{ "CACR", &regs.cacr },
+			{ "DFC", &regs.dfc },
+			{ "ISP", &regs.isp },
+			{ "MSP", &regs.msp },
+			{ "SFC", &regs.sfc },
+			{ "USP", &regs.usp },
+			{ "VBR", &regs.vbr }
+		};
+		int i;
+		for (i = 0; i < ARRAY_SIZE(reg3_ptrs); i++)
+		{
+			if (strcasecmp(reg, reg3_ptrs[i].name) == 0)
+			{
+				*addr = reg3_ptrs[i].addr;
+				return 32;
+			}
+		}
+		return 0;
+	}
+
 	r0 = toupper((unsigned char)reg[0]);
 	r1 = toupper((unsigned char)reg[1]) - '0';
 
@@ -252,7 +282,7 @@
 	{
 		if (r1 >= 0 && r1 <= 7)
 		{
-			*addr = &(Regs[REG_D0 + r1]);
+			*addr = &(regs.regs[REG_D0 + r1]);
 			return 32;
 		}
 		fprintf(stderr,"\tBad data register, valid values are 0-7\n");
@@ -262,7 +292,7 @@
 	{
 		if (r1 >= 0 && r1 <= 7)
 		{
-			*addr = &(Regs[REG_A0 + r1]);
+			*addr = &(regs.regs[REG_A0 + r1]);
 			return 32;
 		}
 		fprintf(stderr,"\tBad address register, valid values are 0-7\n");
@@ -288,9 +318,8 @@
  */
 int DebugCpu_Register(int nArgc, char *psArgs[])
 {
-	char reg[3], *assign;
+	char *arg, *assign;
 	Uint32 value;
-	char *arg;
 
 	/* If no parameter has been given, simply dump all registers */
 	if (nArgc == 1)
@@ -336,20 +365,17 @@
 	}
 
 	arg = Str_Trim(arg);
-	if (strlen(arg) != 2)
+	if (strlen(arg) < 2)
 	{
 		goto error_msg;
 	}
-	reg[0] = toupper((unsigned char)arg[0]);
-	reg[1] = toupper((unsigned char)arg[1]);
-	reg[2] = '\0';
 	
 	/* set SR and update conditional flags for the UAE CPU core. */
-	if (reg[0] == 'S' && reg[1] == 'R')
+	if (strcasecmp("SR", arg) == 0)
 	{
 		M68000_SetSR(value);
 	}
-	else if (reg[0] == 'P' && reg[1] == 'C')   /* set PC? */
+	else if (strcasecmp("PC", arg) == 0)  /* set PC */
 	{
 		M68000_SetPC(value);
 	}
@@ -357,7 +383,7 @@
 	{
 		Uint32 *regaddr;
 		/* check&set data and address registers */
-		if (DebugCpu_GetRegisterAddress(reg, &regaddr))
+		if (DebugCpu_GetRegisterAddress(arg, &regaddr))
 		{
 			*regaddr = value;
 		}
@@ -370,7 +396,9 @@
 
 error_msg:
 	fprintf(stderr,"\tError, usage: r or r xx=yyyy\n"
-		"\tWhere: xx=A0-A7, D0-D7, PC, SR, or V0-V7.\n");
+		"\tWhere: xx=A0-A7, D0-D7, PC, SR,\n"
+		"\tCAAR, CACR, DFC, SFC, MSP, ISP, USP, VBR\n"
+		"\tor V0-V7.\n");
 	return DEBUGGER_CMDDONE;
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/