ref: 336ad60a80a72fc9ce6ca9d1e69e3144815cb94a
parent: 0feb60e566660099b427054a82e4305a964a20f3
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Aug 3 21:52:46 EDT 2013
apply richard millers arm debug fixes (from sources) From richard: A couple of patches applied yesterday should make debugging on ARM a bit more reliable. Using db or acid on ARM, you may have noticed that a program being debugged would sometimes execute through a breakpoint without stopping, or run away while being single stepped. It turns out, as often happens, that one symptom had two separate causes. For details: /n/sources/patch/applied/5db-condcode/readme /n/sources/patch/applied/arm-bkpt-cond/readme To take advantage of the patches, rebuild libmach.a, then acid and db. On machines with a kw kernel (sheevaplug et al), you'll also want to rebuild /arm/9plug; otherwise breakpoints will stop working at all. The new 9plug will, however, still work with the old libmach; and the bcm and teg2 kernels are already compatible with the new libmach.
--- a/sys/src/9/kw/trap.c
+++ b/sys/src/9/kw/trap.c
@@ -214,6 +214,7 @@
iprint("spurious irq%s interrupt: %8.8lux\n", irq.name, ibits);s = splfhi();
*irq.irq &= ibits;
+ *irq.irqmask &= ~ibits;
splx(s);
}
}
@@ -416,6 +417,9 @@
case PsrMabt: /* prefetch fault */
ldrexvalid = 0;
faultarm(ureg, ureg->pc, user, 1);
+ if(up->nnote == 0 &&
+ (*(u32int*)ureg->pc & ~(0xF<<28)) == 0x01200070)
+ postnote(up, 1, "sys: breakpoint", NDebug);
break;
case PsrMabt+1: /* data fault */
ldrexvalid = 0;
@@ -479,16 +483,21 @@
break;
case PsrMund: /* undefined instruction */
if(user){- /* look for floating point instructions to interpret */
- x = spllo();
- rv = fpiarm(ureg);
- splx(x);
- if(rv == 0){- ldrexvalid = 0;
- snprint(buf, sizeof buf,
- "undefined instruction: pc %#lux",
- ureg->pc);
- postnote(up, 1, buf, NDebug);
+ if(seg(up, ureg->pc, 0) != nil &&
+ (*(u32int*)ureg->pc & ~(0xF<<28)) == 0x01200070)
+ postnote(up, 1, "sys: breakpoint", NDebug);
+ else{+ /* look for floating point instructions to interpret */
+ x = spllo();
+ rv = fpiarm(ureg);
+ splx(x);
+ if(rv == 0){+ ldrexvalid = 0;
+ snprint(buf, sizeof buf,
+ "undefined instruction: pc %#lux",
+ ureg->pc);
+ postnote(up, 1, buf, NDebug);
+ }
}
}else{ iprint("undefined instruction: pc %#lux inst %#ux\n",--- a/sys/src/libmach/5db.c
+++ b/sys/src/libmach/5db.c
@@ -61,7 +61,7 @@
*/
Machdata armmach =
{- {0x70, 0x00, 0x20, 0xD1}, /* break point */ /* D1200070 */+ {0x70, 0x00, 0x20, 0xE1}, /* break point */ /* E1200070 */4, /* break point size */
leswab, /* short to local byte order */
@@ -602,7 +602,7 @@
case 10: return n == v;
case 11: return n != v;
case 12: return !z && (n == v);
- case 13: return z && (n != v);
+ case 13: return z || (n != v);
case 14: return 1;
case 15: return 0;
}
--
⑨