From: Michael Snyder Date: Fri, 1 Nov 1996 00:41:21 +0000 (+0000) Subject: Thu Oct 31 16:37:17 1996 Michael Snyder X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8665f3dcfacb2b9fdb699978727a89172123645d;p=binutils-gdb.git Thu Oct 31 16:37:17 1996 Michael Snyder * m32r-tdep.c: Improved frame_chain and fn prologue analysis. * configure.tgt: Add entry for m32r target. * monitor.h: Add a flag to tell monitor_store_register to use (val, regno) instead of (regno, val). * monitor.c: Make monitor_store_register honor the above flag. Make monitor_exp ignore DC1/DC3 for m32r. Increase buf size in monitor_dump_regs. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ba38cff0560..b0725fe14c2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,14 @@ start-sanitize-m32r +Thu Oct 31 16:37:17 1996 Michael Snyder + + * m32r-tdep.c: Improved frame_chain and fn prologue analysis. + * configure.tgt: Add entry for m32r target. + * monitor.h: Add a flag to tell monitor_store_register to use + (val, regno) instead of (regno, val). + * monitor.c: Make monitor_store_register honor the above flag. + Make monitor_exp ignore DC1/DC3 for m32r. + Increase buf size in monitor_dump_regs. + Wed Oct 30 18:14:14 1996 Michael Snyder * m32r-tdep.c, m32r-rom.c: New files. diff --git a/gdb/configure.tgt b/gdb/configure.tgt index e2f83f76f7b..847a6ab9700 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -110,6 +110,10 @@ i960-*-elf*) gdb_target=mon960 ;; i960-*-nindy*) gdb_target=nindy960 ;; i960-*-vxworks*) gdb_target=vxworks960 ;; +# start-sanitize-m32r +m32r-*-elf*) gdb_target=m32r ;; +# end-sanitize-m32r + m68000-*-sunos3*) gdb_target=sun2os3 ;; m68000-*-sunos4*) gdb_target=sun2os4 ;; diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index a449223c442..98fca394620 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -93,17 +93,24 @@ m32r_scan_prologue (fi, fsr) /* this code essentially duplicates skip_prologue, but we need the start address below. */ + if (fsr) + memset (fsr->regs, '\000', sizeof fsr->regs); + if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end)) { sal = find_pc_line (prologue_start, 0); if (sal.line == 0) /* no line info, use current PC */ - prologue_end = fi->pc; + if (prologue_start != entry_point_address ()) + prologue_end = fi->pc; + else + return 0; /* _start has no frame or prologue */ else if (sal.end < prologue_end) /* next line begins after fn end */ prologue_end = sal.end; /* (probably means no prologue) */ } else - prologue_end = prologue_start + 100; /* We're in the boondocks */ + prologue_end = prologue_start + 48; /* We're in the boondocks: allow for */ + /* 16 pushes, an add, and "mv fp,sp" */ prologue_end = min (prologue_end, fi->pc); @@ -111,26 +118,39 @@ m32r_scan_prologue (fi, fsr) rp (and other regs), adjust sp and such. */ framesize = 0; - memset (fsr->regs, '\000', sizeof fsr->regs); - for (current_pc = prologue_start; current_pc < prologue_end; current_pc += 2) { int insn; int regno; insn = read_memory_unsigned_integer (current_pc, 2); - if (insn & 0x80) /* Four byte instruction? */ + if (insn & 0x8000) /* Four byte instruction? */ current_pc += 2; if ((insn & 0xf0ff) == 0x207f) { /* st reg, @-sp */ framesize += 4; regno = ((insn >> 8) & 0xf); - fsr->regs[regno] = framesize; + if (fsr) /* save_regs offset */ + fsr->regs[regno] = framesize; } - else if ((insn >> 8) == 0x4f) { /* addi sp */ - framesize += -((char) (insn & 0xff)); /* offset */ + else if ((insn >> 8) == 0x4f) /* addi sp, xx */ + /* add 8 bit sign-extended offset */ + framesize += -((char) (insn & 0xff)); + else if (insn == 0x8faf) /* add3 sp, sp, xxxx */ + /* add 16 bit sign-extended offset */ + framesize += -((short) read_memory_unsigned_integer (current_pc, 2)); + else if (((insn >> 8) == 0xe4) && /* ld24 r4, xxxxxx ; sub sp, r4 */ + read_memory_unsigned_integer (current_pc + 2, 2) == 0x0f24) + { /* subtract 24 bit sign-extended negative-offset */ + insn = read_memory_unsigned_integer (current_pc - 2, 4); + if (insn & 0x00800000) /* sign extend */ + insn |= 0xff000000; /* negative */ + else + insn &= 0x00ffffff; /* positive */ + framesize += insn; + } + else if (insn == 0x1d8f) /* mv fp, sp */ break; /* end of stack adjustments */ - } } return framesize; } @@ -152,11 +172,13 @@ m32r_init_extra_frame_info (fi) fi->pc = FRAME_SAVED_PC (fi->next); framesize = m32r_scan_prologue (fi, &fi->fsr); - +#if 0 if (PC_IN_CALL_DUMMY (fi->pc, NULL, NULL)) fi->frame = dummy_frame_stack->sp; - else if (!fi->next) - fi->frame = read_register (SP_REGNUM); + else +#endif + if (!fi->next) + fi->frame = read_register (SP_REGNUM); for (reg = 0; reg < NUM_REGS; reg++) if (fi->fsr.regs[reg] != 0) @@ -208,11 +230,19 @@ m32r_frame_chain (fi) struct frame_info *fi; { CORE_ADDR saved_fp = fi->fsr.regs[FP_REGNUM]; - - if (saved_fp == 0) - return 0; /* frameless assembly language fn (such as _start) */ - - return read_memory_integer (saved_fp, 4); + CORE_ADDR fn_start, fn_end; + + if (saved_fp != 0) + return read_memory_integer (saved_fp, 4); + else { + if (find_pc_partial_function (fi->pc, 0, &fn_start, &fn_end)) + if (fn_start == entry_point_address ()) + return 0; /* in _start fn, don't chain further */ + else + return read_register (FP_REGNUM); + else /* in the woods, what to do? */ + return 0; /* for now, play it safe and give up... */ + } } /* All we do here is record SP and FP on the call dummy stack */ @@ -240,9 +270,13 @@ int m32r_pc_in_call_dummy (pc) CORE_ADDR pc; { +#if 0 return dummy_frame_stack && pc >= CALL_DUMMY_ADDRESS () && pc <= CALL_DUMMY_ADDRESS () + DECR_PC_AFTER_BREAK; +#else + return 0; +#endif } /* Discard from the stack the innermost frame, diff --git a/gdb/monitor.c b/gdb/monitor.c index 503930ff3cd..f343f98bb5d 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -353,6 +353,7 @@ monitor_expect (string, buf, buflen) char *p = string; int obuflen = buflen; int c; + extern struct target_ops *targ_ops; immediate_quit = 1; while (1) @@ -393,6 +394,11 @@ monitor_expect (string, buf, buflen) return 0; } } + else if ((c == '\021' || c == '\023') && + (strcmp(targ_ops->to_shortname, "m32r") == 0)) + { /* m32r monitor emits random DC1/DC3 chars */ + continue; + } else { p = string; @@ -954,11 +960,11 @@ monitor_fetch_register (regno) static void monitor_dump_regs () { + char buf[1024]; + int resp_len; + if (current_monitor->dump_registers) { - char buf[200]; - int resp_len; - monitor_printf (current_monitor->dump_registers); resp_len = monitor_expect_prompt (buf, sizeof (buf)); parse_register_dump (buf, resp_len); @@ -1004,7 +1010,10 @@ monitor_store_register (regno) /* send the register deposit command */ - monitor_printf (current_monitor->setreg.cmd, name, val); + if (current_monitor->flags & MO_REGISTER_VALUE_FIRST) + monitor_printf (current_monitor->setreg.cmd, val, name); + else + monitor_printf (current_monitor->setreg.cmd, name, val); /* It's possible that there are actually some monitors out there that will prompt you when you set a register. In that case, you may @@ -1080,12 +1089,16 @@ monitor_write_memory (memaddr, myaddr, len) } } +#if 0 + /* Can't actually use long longs if VAL is an int (nice idea, though). */ if ((memaddr & 0x7) == 0 && len >= 8 && current_monitor->setmem.cmdll) { len = 8; cmd = current_monitor->setmem.cmdll; } - else if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->setmem.cmdl) + else +#endif + if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->setmem.cmdl) { len = 4; cmd = current_monitor->setmem.cmdl; @@ -1128,12 +1141,18 @@ monitor_read_memory_single (memaddr, myaddr, len) char *cmd; int i; +#if 0 + /* Can't actually use long longs (nice idea, though). In fact, the + call to strtoul below will fail if it tries to convert a value + that's too big to fit in a long. */ if ((memaddr & 0x7) == 0 && len >= 8 && current_monitor->getmem.cmdll) { len = 8; cmd = current_monitor->getmem.cmdll; } - else if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->getmem.cmdl) + else +#endif + if ((memaddr & 0x3) == 0 && len >= 4 && current_monitor->getmem.cmdl) { len = 4; cmd = current_monitor->getmem.cmdl; diff --git a/gdb/monitor.h b/gdb/monitor.h index f658921bf21..82b417b1685 100644 --- a/gdb/monitor.h +++ b/gdb/monitor.h @@ -164,6 +164,10 @@ struct monitor_ops #define MO_NO_ECHO_ON_SETMEM 0x800 +/* If set, then register store command expects value BEFORE regname */ + +#define MO_REGISTER_VALUE_FIRST 0x1000 + #define SREC_SIZE 160 extern void monitor_open PARAMS ((char *args, struct monitor_ops *ops,