This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Rename gdbarch_gdb_signal_from_host => gdbarch_gdb_signal_from_target.
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 22 May 2012 18:58:00 +0100
- Subject: [PATCH] Rename gdbarch_gdb_signal_from_host => gdbarch_gdb_signal_from_target.
Something like this is what I had in mind. See the new comments in
arch-utils.c, corelow.c, and gdbarch.sh. Even without those, I think
this naming makes the target->host fallbacks clearer to the reader.
This applies on top of the target_signal => gdb_signal renaming series.
Find this at:
https://github.com/palves/gdb/tree/gdbarch_gdb_signal_from_target
or:
git clone --branch gdbarch_gdb_signal_from_target git://github.com/palves/gdb.git
2012-05-22 Pedro Alves <palves@redhat.com>
* arch-utils.c (default_gdb_signal_to_host): Rename to ...
(default_gdb_signal_to_target): ... this. Add comment.
(default_gdb_signal_from_host): Rename to ...
(default_gdb_signal_from_target): ... this. Add comment.
* arch-utils.h (default_gdb_signal_to_host): Rename to ...
(default_gdb_signal_to_target): ... this.
(default_gdb_signal_from_host): Rename to ...
(default_gdb_signal_from_target): ... this.
* corelow.c (core_open): Adjust to naming change. Replace comment.
* gdbarch.sh (gdb_signal_from_host): Rename to ...
(gdb_signal_from_target): ... this. Adjust to
default_gdb_signal_from_host naming change. Extend comment.
(gdb_signal_to_host): Rename to ...
(gdb_signal_to_target): ... this. Adjust to
default_gdb_signal_to_host naming change.
* gdbarch.h, gdbarch.c: Renegerate.
---
gdb/arch-utils.c | 10 ++++++++--
gdb/arch-utils.h | 8 ++++----
gdb/corelow.c | 10 ++++------
gdb/gdbarch.c | 52 ++++++++++++++++++++++++++--------------------------
gdb/gdbarch.h | 29 ++++++++++++++++-------------
gdb/gdbarch.sh | 16 ++++++++++------
6 files changed, 68 insertions(+), 57 deletions(-)
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index a69baec..3438c44 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -794,14 +794,20 @@ default_gen_return_address (struct gdbarch *gdbarch,
}
int
-default_gdb_signal_to_host (struct gdbarch *gdbarch, enum gdb_signal ts)
+default_gdb_signal_to_target (struct gdbarch *gdbarch, enum gdb_signal ts)
{
+ /* Lacking a better mapping, assume host signal numbers. If
+ debugging a cross-core, most likely this translation will be
+ incorrect. */
return gdb_signal_to_host (ts);
}
enum gdb_signal
-default_gdb_signal_from_host (struct gdbarch *gdbarch, int signo)
+default_gdb_signal_from_target (struct gdbarch *gdbarch, int signo)
{
+ /* Lacking a better mapping, assume host signal numbers. If
+ debugging a cross-core, most likely this translation will be
+ incorrect. */
return gdb_signal_from_host (signo);
}
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index a22391e..7df761e 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -172,9 +172,9 @@ extern void default_gen_return_address (struct gdbarch *gdbarch,
extern const char *default_auto_charset (void);
extern const char *default_auto_wide_charset (void);
-extern enum gdb_signal default_gdb_signal_from_host (struct gdbarch *,
- int);
-extern int default_gdb_signal_to_host (struct gdbarch *,
- enum gdb_signal);
+extern enum gdb_signal default_gdb_signal_from_target (struct gdbarch *,
+ int);
+extern int default_gdb_signal_to_target (struct gdbarch *,
+ enum gdb_signal);
#endif
diff --git a/gdb/corelow.c b/gdb/corelow.c
index f566b2d..8c3cd5c 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -440,13 +440,11 @@ core_open (char *filename, int from_tty)
siggy = bfd_core_file_failing_signal (core_bfd);
if (siggy > 0)
{
- /* NOTE: gdb_signal_from_host() converts a target signal
- value into gdb's internal signal value. Unfortunately gdb's
- internal value is called ``gdb_signal'' and this function
- got the name ..._from_host(). */
+ /* If we don't have a CORE_GDBARCH to work with, assume a native
+ core. */
enum gdb_signal sig = (core_gdbarch != NULL
- ? gdbarch_gdb_signal_from_host (core_gdbarch,
- siggy)
+ ? gdbarch_gdb_signal_from_target (core_gdbarch,
+ siggy)
: gdb_signal_from_host (siggy));
printf_filtered (_("Program terminated with signal %d, %s.\n"),
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 70d3891..f5f0663 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -260,8 +260,8 @@ struct gdbarch
int sofun_address_maybe_missing;
gdbarch_process_record_ftype *process_record;
gdbarch_process_record_signal_ftype *process_record_signal;
- gdbarch_gdb_signal_from_host_ftype *gdb_signal_from_host;
- gdbarch_gdb_signal_to_host_ftype *gdb_signal_to_host;
+ gdbarch_gdb_signal_from_target_ftype *gdb_signal_from_target;
+ gdbarch_gdb_signal_to_target_ftype *gdb_signal_to_target;
gdbarch_get_siginfo_type_ftype *get_siginfo_type;
gdbarch_record_special_symbol_ftype *record_special_symbol;
gdbarch_get_syscall_number_ftype *get_syscall_number;
@@ -428,8 +428,8 @@ struct gdbarch startup_gdbarch =
0, /* sofun_address_maybe_missing */
0, /* process_record */
0, /* process_record_signal */
- default_gdb_signal_from_host, /* gdb_signal_from_host */
- default_gdb_signal_to_host, /* gdb_signal_to_host */
+ default_gdb_signal_from_target, /* gdb_signal_from_target */
+ default_gdb_signal_to_target, /* gdb_signal_to_target */
0, /* get_siginfo_type */
0, /* record_special_symbol */
0, /* get_syscall_number */
@@ -538,8 +538,8 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->displaced_step_free_closure = NULL;
gdbarch->displaced_step_location = NULL;
gdbarch->relocate_instruction = NULL;
- gdbarch->gdb_signal_from_host = default_gdb_signal_from_host;
- gdbarch->gdb_signal_to_host = default_gdb_signal_to_host;
+ gdbarch->gdb_signal_from_target = default_gdb_signal_from_target;
+ gdbarch->gdb_signal_to_target = default_gdb_signal_to_target;
gdbarch->has_shared_address_space = default_has_shared_address_space;
gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
gdbarch->auto_charset = default_auto_charset;
@@ -730,8 +730,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of sofun_address_maybe_missing, invalid_p == 0 */
/* Skip verify of process_record, has predicate. */
/* Skip verify of process_record_signal, has predicate. */
- /* Skip verify of gdb_signal_from_host, invalid_p == 0 */
- /* Skip verify of gdb_signal_to_host, invalid_p == 0 */
+ /* Skip verify of gdb_signal_from_target, invalid_p == 0 */
+ /* Skip verify of gdb_signal_to_target, invalid_p == 0 */
/* Skip verify of get_siginfo_type, has predicate. */
/* Skip verify of record_special_symbol, has predicate. */
/* Skip verify of get_syscall_number, has predicate. */
@@ -1000,11 +1000,11 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: gcore_bfd_target = %s\n",
pstring (gdbarch->gcore_bfd_target));
fprintf_unfiltered (file,
- "gdbarch_dump: gdb_signal_from_host = <%s>\n",
- host_address_to_string (gdbarch->gdb_signal_from_host));
+ "gdbarch_dump: gdb_signal_from_target = <%s>\n",
+ host_address_to_string (gdbarch->gdb_signal_from_target));
fprintf_unfiltered (file,
- "gdbarch_dump: gdb_signal_to_host = <%s>\n",
- host_address_to_string (gdbarch->gdb_signal_to_host));
+ "gdbarch_dump: gdb_signal_to_target = <%s>\n",
+ host_address_to_string (gdbarch->gdb_signal_to_target));
fprintf_unfiltered (file,
"gdbarch_dump: gen_return_address = <%s>\n",
host_address_to_string (gdbarch->gen_return_address));
@@ -3795,37 +3795,37 @@ set_gdbarch_process_record_signal (struct gdbarch *gdbarch,
}
enum gdb_signal
-gdbarch_gdb_signal_from_host (struct gdbarch *gdbarch, int signo)
+gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, int signo)
{
gdb_assert (gdbarch != NULL);
- gdb_assert (gdbarch->gdb_signal_from_host != NULL);
+ gdb_assert (gdbarch->gdb_signal_from_target != NULL);
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_gdb_signal_from_host called\n");
- return gdbarch->gdb_signal_from_host (gdbarch, signo);
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_gdb_signal_from_target called\n");
+ return gdbarch->gdb_signal_from_target (gdbarch, signo);
}
void
-set_gdbarch_gdb_signal_from_host (struct gdbarch *gdbarch,
- gdbarch_gdb_signal_from_host_ftype gdb_signal_from_host)
+set_gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch,
+ gdbarch_gdb_signal_from_target_ftype gdb_signal_from_target)
{
- gdbarch->gdb_signal_from_host = gdb_signal_from_host;
+ gdbarch->gdb_signal_from_target = gdb_signal_from_target;
}
int
-gdbarch_gdb_signal_to_host (struct gdbarch *gdbarch, enum gdb_signal ts)
+gdbarch_gdb_signal_to_target (struct gdbarch *gdbarch, enum gdb_signal ts)
{
gdb_assert (gdbarch != NULL);
- gdb_assert (gdbarch->gdb_signal_to_host != NULL);
+ gdb_assert (gdbarch->gdb_signal_to_target != NULL);
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_gdb_signal_to_host called\n");
- return gdbarch->gdb_signal_to_host (gdbarch, ts);
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_gdb_signal_to_target called\n");
+ return gdbarch->gdb_signal_to_target (gdbarch, ts);
}
void
-set_gdbarch_gdb_signal_to_host (struct gdbarch *gdbarch,
- gdbarch_gdb_signal_to_host_ftype gdb_signal_to_host)
+set_gdbarch_gdb_signal_to_target (struct gdbarch *gdbarch,
+ gdbarch_gdb_signal_to_target_ftype gdb_signal_to_target)
{
- gdbarch->gdb_signal_to_host = gdb_signal_to_host;
+ gdbarch->gdb_signal_to_target = gdb_signal_to_target;
}
int
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 2e7f61d..31f8109 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -939,19 +939,22 @@ typedef int (gdbarch_process_record_signal_ftype) (struct gdbarch *gdbarch, stru
extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum gdb_signal signal);
extern void set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch_process_record_signal_ftype *process_record_signal);
-/* Signal translation: translate inferior's signal (host's) number into
- GDB's representation. */
-
-typedef enum gdb_signal (gdbarch_gdb_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo);
-extern enum gdb_signal gdbarch_gdb_signal_from_host (struct gdbarch *gdbarch, int signo);
-extern void set_gdbarch_gdb_signal_from_host (struct gdbarch *gdbarch, gdbarch_gdb_signal_from_host_ftype *gdb_signal_from_host);
-
-/* Signal translation: translate GDB's signal number into inferior's host
- signal number. */
-
-typedef int (gdbarch_gdb_signal_to_host_ftype) (struct gdbarch *gdbarch, enum gdb_signal ts);
-extern int gdbarch_gdb_signal_to_host (struct gdbarch *gdbarch, enum gdb_signal ts);
-extern void set_gdbarch_gdb_signal_to_host (struct gdbarch *gdbarch, gdbarch_gdb_signal_to_host_ftype *gdb_signal_to_host);
+/* Signal translation: translate inferior's signal (target's) number
+ into GDB's representation. This is mainly used when cross-debugging
+ core files --- "Live" targets hide the translation behind the target
+ interface (target_wait, target_resume, etc.). The default is to do
+ the translation using host signal numbers. */
+
+typedef enum gdb_signal (gdbarch_gdb_signal_from_target_ftype) (struct gdbarch *gdbarch, int signo);
+extern enum gdb_signal gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, int signo);
+extern void set_gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, gdbarch_gdb_signal_from_target_ftype *gdb_signal_from_target);
+
+/* Signal translation: translate GDB's signal number into inferior's
+ target's signal number. */
+
+typedef int (gdbarch_gdb_signal_to_target_ftype) (struct gdbarch *gdbarch, enum gdb_signal ts);
+extern int gdbarch_gdb_signal_to_target (struct gdbarch *gdbarch, enum gdb_signal ts);
+extern void set_gdbarch_gdb_signal_to_target (struct gdbarch *gdbarch, gdbarch_gdb_signal_to_target_ftype *gdb_signal_to_target);
/* Extra signal info inspection.
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 36288ec..9997abf 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -772,12 +772,16 @@ M:int:process_record:struct regcache *regcache, CORE_ADDR addr:regcache, addr
# Return -1 if something goes wrong, 0 otherwise.
M:int:process_record_signal:struct regcache *regcache, enum gdb_signal signal:regcache, signal
-# Signal translation: translate inferior's signal (host's) number into
-# GDB's representation.
-m:enum gdb_signal:gdb_signal_from_host:int signo:signo::default_gdb_signal_from_host::0
-# Signal translation: translate GDB's signal number into inferior's host
-# signal number.
-m:int:gdb_signal_to_host:enum gdb_signal ts:ts::default_gdb_signal_to_host::0
+# Signal translation: translate inferior's signal (target's) number
+# into GDB's representation. This is mainly used when cross-debugging
+# core files --- "Live" targets hide the translation behind the target
+# interface (target_wait, target_resume, etc.). The default is to do
+# the translation using host signal numbers.
+m:enum gdb_signal:gdb_signal_from_target:int signo:signo::default_gdb_signal_from_target::0
+
+# Signal translation: translate GDB's signal number into inferior's
+# target's signal number.
+m:int:gdb_signal_to_target:enum gdb_signal ts:ts::default_gdb_signal_to_target::0
# Extra signal info inspection.
#