From 2567c7d9ccb27053278c7bca0c911a817ab21b47 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 19 May 2009 00:23:49 +0000 Subject: [PATCH] * breakpoint.c (insert_breakpoints, breakpoint_init_inferior) (update_global_location_list): Use gdbarch_has_global_breakpoints instead of gdbarch_has_global_solist and target_supports_multi_process. * dicos-tdep.c (dicos_init_abi): Set gdbarch_has_global_breakpoints. * gdbarch.sh (has_global_solist): Update comment. (has_global_breakpoints): New. * remote.c (remote_start_remote): Use gdbarch_has_global_breakpoints instead of gdbarch_has_global_solist. * target.c (target_detach): Use gdbarch_has_global_breakpoints instead of gdbarch_has_global_solist. * infcmd.c (attach_command): Use gdbarch_has_global_solist instead of target_supports_multi_process. --- gdb/breakpoint.c | 8 +++----- gdb/dicos-tdep.c | 7 ++++++- gdb/gdbarch.c | 23 +++++++++++++++++++++++ gdb/gdbarch.h | 14 +++++++++++--- gdb/gdbarch.sh | 12 +++++++++--- gdb/infcmd.c | 5 +++-- gdb/remote.c | 5 ++--- gdb/target.c | 2 +- 8 files changed, 58 insertions(+), 18 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 34618247b05..e36429da92f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1290,8 +1290,7 @@ insert_breakpoints (void) if (!breakpoints_always_inserted_mode () && (target_has_execution - || (gdbarch_has_global_solist (target_gdbarch) - && target_supports_multi_process ()))) + || gdbarch_has_global_breakpoints (target_gdbarch))) /* update_global_location_list does not insert breakpoints when always_inserted_mode is not enabled. Explicitly insert them now. */ @@ -1780,7 +1779,7 @@ breakpoint_init_inferior (enum inf_context context) /* If breakpoint locations are shared across processes, then there's nothing to do. */ - if (gdbarch_has_global_solist (target_gdbarch)) + if (gdbarch_has_global_breakpoints (target_gdbarch)) return; ALL_BP_LOCATIONS (bpt) @@ -7200,8 +7199,7 @@ update_global_location_list (int should_insert) if (breakpoints_always_inserted_mode () && should_insert && (target_has_execution - || (gdbarch_has_global_solist (target_gdbarch) - && target_supports_multi_process ()))) + || (gdbarch_has_global_breakpoints (target_gdbarch)))) insert_breakpoint_locations (); do_cleanups (cleanups); diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c index d64efe56aaf..fe5f853947b 100644 --- a/gdb/dicos-tdep.c +++ b/gdb/dicos-tdep.c @@ -33,9 +33,14 @@ dicos_init_abi (struct gdbarch *gdbarch) set_solib_ops (gdbarch, &solib_target_so_ops); /* Every process, although has its own address space, sees the same - list of shared libraries. */ + list of shared libraries. There's no "main executable" in DICOS, + so this accounts for all code. */ set_gdbarch_has_global_solist (gdbarch, 1); + /* The DICOS breakpoint API takes care of magically making + breakpoints visible to all inferiors. */ + set_gdbarch_has_global_breakpoints (gdbarch, 1); + /* There's no (standard definition of) entry point or a guaranteed text location with a symbol where to place the call dummy, so we put it on the stack. */ diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index cc137157384..0f0edd41cb8 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -245,6 +245,7 @@ struct gdbarch gdbarch_get_siginfo_type_ftype *get_siginfo_type; gdbarch_record_special_symbol_ftype *record_special_symbol; int has_global_solist; + int has_global_breakpoints; }; @@ -381,6 +382,7 @@ struct gdbarch startup_gdbarch = 0, /* get_siginfo_type */ 0, /* record_special_symbol */ 0, /* has_global_solist */ + 0, /* has_global_breakpoints */ /* startup_gdbarch() */ }; @@ -638,6 +640,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of get_siginfo_type, has predicate */ /* Skip verify of record_special_symbol, has predicate */ /* Skip verify of has_global_solist, invalid_p == 0 */ + /* Skip verify of has_global_breakpoints, invalid_p == 0 */ buf = ui_file_xstrdup (log, &dummy); make_cleanup (xfree, buf); if (strlen (buf) > 0) @@ -861,6 +864,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: get_siginfo_type = <%s>\n", host_address_to_string (gdbarch->get_siginfo_type)); + fprintf_unfiltered (file, + "gdbarch_dump: has_global_breakpoints = %s\n", + plongest (gdbarch->has_global_breakpoints)); fprintf_unfiltered (file, "gdbarch_dump: has_global_solist = %s\n", plongest (gdbarch->has_global_solist)); @@ -3382,6 +3388,23 @@ set_gdbarch_has_global_solist (struct gdbarch *gdbarch, gdbarch->has_global_solist = has_global_solist; } +int +gdbarch_has_global_breakpoints (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Skip verify of has_global_breakpoints, invalid_p == 0 */ + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_has_global_breakpoints called\n"); + return gdbarch->has_global_breakpoints; +} + +void +set_gdbarch_has_global_breakpoints (struct gdbarch *gdbarch, + int has_global_breakpoints) +{ + gdbarch->has_global_breakpoints = has_global_breakpoints; +} + /* Keep a registry of per-architecture data-pointers required by GDB modules. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index e844f52d638..6f9c90045c7 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -863,13 +863,21 @@ extern void set_gdbarch_record_special_symbol (struct gdbarch *gdbarch, gdbarch_ /* True if the list of shared libraries is one and only for all processes, as opposed to a list of shared libraries per inferior. - When this property is true, GDB assumes that since shared libraries - are shared across processes, so is all code. Hence, GDB further - assumes an inserted breakpoint location is visible to all processes. */ + This usually means that all processes, although may or may not share + an address space, will see the same set of symbols at the same + addresses. */ extern int gdbarch_has_global_solist (struct gdbarch *gdbarch); extern void set_gdbarch_has_global_solist (struct gdbarch *gdbarch, int has_global_solist); +/* On some targets, even though each inferior has its own private + address space, the debug interface takes care of making breakpoints + visible to all address spaces automatically. For such cases, + this property should be set to true. */ + +extern int gdbarch_has_global_breakpoints (struct gdbarch *gdbarch); +extern void set_gdbarch_has_global_breakpoints (struct gdbarch *gdbarch, int has_global_breakpoints); + extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 7e0d657dc7d..2075a77a64a 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -732,10 +732,16 @@ M:void:record_special_symbol:struct objfile *objfile, asymbol *sym:objfile, sym # True if the list of shared libraries is one and only for all # processes, as opposed to a list of shared libraries per inferior. -# When this property is true, GDB assumes that since shared libraries -# are shared across processes, so is all code. Hence, GDB further -# assumes an inserted breakpoint location is visible to all processes. +# This usually means that all processes, although may or may not share +# an address space, will see the same set of symbols at the same +# addresses. v:int:has_global_solist:::0:0::0 + +# On some targets, even though each inferior has its own private +# address space, the debug interface takes care of making breakpoints +# visible to all address spaces automatically. For such cases, +# this property should be set to true. +v:int:has_global_breakpoints:::0:0::0 EOF } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index ec83e3422fc..fcb0f911f2e 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2220,8 +2220,9 @@ attach_command (char *args, int from_tty) dont_repeat (); /* Not for the faint of heart */ - if (target_supports_multi_process ()) - /* Don't complain if we can be attached to multiple processes. */ + if (gdbarch_has_global_solist (target_gdbarch)) + /* Don't complain if all processes share the same symbol + space. */ ; else if (target_has_execution) { diff --git a/gdb/remote.c b/gdb/remote.c index bec99f0b533..60d32048667 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2824,9 +2824,8 @@ remote_start_remote (struct ui_out *uiout, void *opaque) remote_check_symbols (symfile_objfile); } - /* If code is shared between processes, then breakpoints are global - too; Insert them now. */ - if (gdbarch_has_global_solist (target_gdbarch) + /* If breakpoints are global, insert them now. */ + if (gdbarch_has_global_breakpoints (target_gdbarch) && breakpoints_always_inserted_mode ()) insert_breakpoints (); } diff --git a/gdb/target.c b/gdb/target.c index d0df43083b7..506fce710d7 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1788,7 +1788,7 @@ target_detach (char *args, int from_tty) { struct target_ops* t; - if (gdbarch_has_global_solist (target_gdbarch)) + if (gdbarch_has_global_breakpoints (target_gdbarch)) /* Don't remove global breakpoints here. They're removed on disconnection from the target. */ ; -- 2.30.2