X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fgdbserver%2Fserver.c;h=9bf4f3dbd00189b82c1706856057103c11e682e2;hb=cdbfd4198ec38a42766a578d4058bd752d25011c;hp=423427c356eadcdef61d1825bab225db5424b100;hpb=e09875d41026beb03eae1a65510ca40ed3a5d6c1;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 423427c356..9bf4f3dbd0 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -51,6 +51,9 @@ static char **program_argv, **wrapper_argv; was originally used to debug LinuxThreads support. */ int debug_threads; +/* Enable debugging of h/w breakpoint/watchpoint support. */ +int debug_hw_points; + int pass_signals[TARGET_SIGNAL_LAST]; jmp_buf toplevel; @@ -495,6 +498,8 @@ monitor_show_help (void) monitor_output ("The following monitor commands are supported:\n"); monitor_output (" set debug <0|1>\n"); monitor_output (" Enable general debugging messages\n"); + monitor_output (" set debug-hw-points <0|1>\n"); + monitor_output (" Enable h/w breakpoint/watchpoint debugging messages\n"); monitor_output (" set remote-debug <0|1>\n"); monitor_output (" Enable remote protocol debugging messages\n"); monitor_output (" exit\n"); @@ -655,6 +660,53 @@ handle_search_memory (char *own_buf, int packet_len) return; \ } +/* Handle monitor commands not handled by target-specific handlers. */ + +static void +handle_monitor_command (char *mon) +{ + if (strcmp (mon, "set debug 1") == 0) + { + debug_threads = 1; + monitor_output ("Debug output enabled.\n"); + } + else if (strcmp (mon, "set debug 0") == 0) + { + debug_threads = 0; + monitor_output ("Debug output disabled.\n"); + } + else if (strcmp (mon, "set debug-hw-points 1") == 0) + { + debug_hw_points = 1; + monitor_output ("H/W point debugging output enabled.\n"); + } + else if (strcmp (mon, "set debug-hw-points 0") == 0) + { + debug_hw_points = 0; + monitor_output ("H/W point debugging output disabled.\n"); + } + else if (strcmp (mon, "set remote-debug 1") == 0) + { + remote_debug = 1; + monitor_output ("Protocol debug output enabled.\n"); + } + else if (strcmp (mon, "set remote-debug 0") == 0) + { + remote_debug = 0; + monitor_output ("Protocol debug output disabled.\n"); + } + else if (strcmp (mon, "help") == 0) + monitor_show_help (); + else if (strcmp (mon, "exit") == 0) + exit_requested = 1; + else + { + monitor_output ("Unknown monitor command.\n\n"); + monitor_show_help (); + write_enn (own_buf); + } +} + /* Handle all of the extended 'q' packets. */ void handle_query (char *own_buf, int packet_len, int *new_packet_len_p) @@ -1074,9 +1126,13 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) p != NULL; p = strtok (NULL, ";")) { - /* Record if GDB knows about multiprocess support. */ if (strcmp (p, "multiprocess+") == 0) - multi_process = 1; + { + /* GDB supports and wants multi-process support if + possible. */ + if (target_supports_multi_process ()) + multi_process = 1; + } } sprintf (own_buf, "PacketSize=%x;QPassSignals+", PBUFSIZ - 1); @@ -1106,7 +1162,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) if (the_target->qxfer_osdata != NULL) strcat (own_buf, ";qXfer:osdata:read+"); - strcat (own_buf, ";multiprocess+"); + if (target_supports_multi_process ()) + strcat (own_buf, ";multiprocess+"); if (target_supports_non_stop ()) strcat (own_buf, ";QNonStop+"); @@ -1201,36 +1258,10 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) write_ok (own_buf); - if (strcmp (mon, "set debug 1") == 0) - { - debug_threads = 1; - monitor_output ("Debug output enabled.\n"); - } - else if (strcmp (mon, "set debug 0") == 0) - { - debug_threads = 0; - monitor_output ("Debug output disabled.\n"); - } - else if (strcmp (mon, "set remote-debug 1") == 0) - { - remote_debug = 1; - monitor_output ("Protocol debug output enabled.\n"); - } - else if (strcmp (mon, "set remote-debug 0") == 0) - { - remote_debug = 0; - monitor_output ("Protocol debug output disabled.\n"); - } - else if (strcmp (mon, "help") == 0) - monitor_show_help (); - else if (strcmp (mon, "exit") == 0) - exit_requested = 1; - else - { - monitor_output ("Unknown monitor command.\n\n"); - monitor_show_help (); - write_enn (own_buf); - } + if (the_target->handle_monitor_command == NULL + || (*the_target->handle_monitor_command) (mon) == 0) + /* Default processing. */ + handle_monitor_command (mon); free (mon); return; @@ -1518,8 +1549,10 @@ handle_v_kill (char *own_buf) { int pid; char *p = &own_buf[6]; - - pid = strtol (p, NULL, 16); + if (multi_process) + pid = strtol (p, NULL, 16); + else + pid = signal_pid; if (pid != 0 && kill_inferior (pid) == 0) { last_status.kind = TARGET_WAITKIND_SIGNALLED; @@ -2366,66 +2399,44 @@ process_serial_event (void) signal = 0; myresume (own_buf, 1, signal); break; - case 'Z': + case 'Z': /* insert_ ... */ + /* Fallthrough. */ + case 'z': /* remove_ ... */ { char *lenptr; char *dataptr; CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16); int len = strtol (lenptr + 1, &dataptr, 16); char type = own_buf[1]; + int res; + const int insert = ch == 'Z'; - if (the_target->insert_watchpoint == NULL - || (type < '2' || type > '4')) - { - /* No watchpoint support or not a watchpoint command; - unrecognized either way. */ - own_buf[0] = '\0'; - } - else + /* Default to unrecognized/unsupported. */ + res = 1; + switch (type) { - int res; - + case '0': /* software-breakpoint */ + case '1': /* hardware-breakpoint */ + case '2': /* write watchpoint */ + case '3': /* read watchpoint */ + case '4': /* access watchpoint */ require_running (own_buf); - res = (*the_target->insert_watchpoint) (type, addr, len); - if (res == 0) - write_ok (own_buf); - else if (res == 1) - /* Unsupported. */ - own_buf[0] = '\0'; - else - write_enn (own_buf); + if (insert && the_target->insert_point != NULL) + res = (*the_target->insert_point) (type, addr, len); + else if (!insert && the_target->remove_point != NULL) + res = (*the_target->remove_point) (type, addr, len); + break; + default: + break; } - break; - } - case 'z': - { - char *lenptr; - char *dataptr; - CORE_ADDR addr = strtoul (&own_buf[3], &lenptr, 16); - int len = strtol (lenptr + 1, &dataptr, 16); - char type = own_buf[1]; - if (the_target->remove_watchpoint == NULL - || (type < '2' || type > '4')) - { - /* No watchpoint support or not a watchpoint command; - unrecognized either way. */ - own_buf[0] = '\0'; - } + if (res == 0) + write_ok (own_buf); + else if (res == 1) + /* Unsupported. */ + own_buf[0] = '\0'; else - { - int res; - - require_running (own_buf); - res = (*the_target->remove_watchpoint) (type, addr, len); - if (res == 0) - write_ok (own_buf); - else if (res == 1) - /* Unsupported. */ - own_buf[0] = '\0'; - else - write_enn (own_buf); - } + write_enn (own_buf); break; } case 'k':