static void exec_one_dummy_insn (struct gdbarch *gdbarch) { #define DUMMY_INSN_ADDR gdbarch_tdep (gdbarch)->text_segment_base+0x200 int ret, status, pid; CORE_ADDR prev_pc; void *bp; /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that this address will never be executed again by the real code. */ bp = deprecated_insert_raw_breakpoint (DUMMY_INSN_ADDR); /* You might think this could be done with a single ptrace call, and you'd be correct for just about every platform I've ever worked on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up -- the inferior never hits the breakpoint (it's also worth noting powerpc-ibm-aix4.1.3 works correctly). */ prev_pc = read_pc (); write_pc (DUMMY_INSN_ADDR); if (ARCH64 ()) ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL); else ret = rs6000_ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid), (int *)1, 0, NULL); if (ret != 0) perror ("pt_continue"); do { pid = wait (&status); } while (pid != PIDGET (inferior_ptid)); write_pc (prev_pc); deprecated_remove_raw_breakpoint (bp); }
static void exec_one_dummy_insn (void) { #define DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200 char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */ int ret, status, pid; CORE_ADDR prev_pc; /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that this address will never be executed again by the real code. */ target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents); /* You might think this could be done with a single ptrace call, and you'd be correct for just about every platform I've ever worked on. However, rs6000-ibm-aix4.1.3 seems to have screwed this up -- the inferior never hits the breakpoint (it's also worth noting powerpc-ibm-aix4.1.3 works correctly). */ prev_pc = read_pc (); write_pc (DUMMY_INSN_ADDR); if (ARCH64 ()) ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL); else ret = rs6000_ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid), (int *)1, 0, NULL); if (ret != 0) perror ("pt_continue"); do { pid = wait (&status); } while (pid != PIDGET (inferior_ptid)); write_pc (prev_pc); target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents); }
void gdb_event_loop(int sigval, unsigned long *registers) { int addr; int length; unsigned char *ptr; ptr = packet_out_buf; DEBUG (1, "In gdb_event_loop"); while (1) { packet_out_buf[0] = 0; getpacket(packet_in_buf); ptr = &packet_in_buf[1]; switch (packet_in_buf[0]) { case '?': /* get the last known signal */ gdb_last_signal(sigval); break; case 'd': /* toggle debug messages from the stub */ gdb_toggle(); break; case 'g': /* return the value of the CPU registers */ target_read_registers(registers); break; case 'G': /* set the value of the CPU registers - return OK */ target_write_registers(registers); break; case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ /* Try to read %x,%x. */ if (hex2int((char **)&ptr, &addr) && *ptr++ == ',' && hex2int((char **)&ptr, &length)) { gdb_read_memory(addr, length); } else { make_return_packet(1); } break; case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ /* Try to read '%x,%x:'. */ if (hex2int((char **)&ptr, &addr) && *ptr++ == ',' && hex2int((char **)&ptr, &length) && *ptr++ == ':') { gdb_write_memory (addr, length, ptr); } else { make_return_packet(2); } break; case 'c': /* cAA..AA Continue at address AA..AA(optional) */ /* try to read optional parameter, pc unchanged if no parm */ if (hex2int((char **)&ptr, &addr)) { write_pc(registers, addr); } /* * we need to flush the instruction cache here, as we may have * deposited a breakpoint, and the icache probably has no way of * knowing that a data ref to some location may have changed * something that is in the instruction cache. */ flush_i_cache(); /* by returning, we pick up execution where we left off */ return; /* kill the program */ case 'k' : gdb_kill(); break; case 'r': /* Reset */ target_reset(); break; } /* switch */ /* reply to the request */ putpacket(packet_out_buf); } DEBUG (1, "Leaving handle_exception()"); }
void write_climate_and_pc () { char fn [70], lfs [7]; int i, j, jj = 0, lf; if (global_monitor) monitor_leaf(1, "write_climate_and_pc"); write_esd(); printf(" Writing: Climate and Plant Community description. \n"); open_files(0); for (i = 0; i < n_lats; i++) { for (j = 0; j < n_lons; j++) { if (earth[i][j] == '1') { read_data(jj); write_climate(); write_pc(); ++jj; } else zero_data(1); } zero_data(0); } close_files(); printf(" Writing: LF FCs. \n"); for (lf = 1; lf <= num_lf; lf++) { printf(" LF = %3d \n", lf); strcpy(fn, "Test/eco_leaf/lf_"); if (lf < 10) strcat(fn, "00"); else if (lf < 100) strcat(fn, "0"); int_to_ascii(lf, lfs); strcat(fn, lfs); write_lf(lf, fn); } if (global_monitor) monitor_leaf(0, "write_climate_and_pc"); }