From: Aleksandar Ristovski <ARistovski@qnx.com>
To: gdb-patches@sourceware.org
Cc: Ryan Mansfield <RMansfield@qnx.com>
Subject: PR 2343 fix: signal number mismatch
Date: Thu, 13 Dec 2007 17:05:00 -0000 [thread overview]
Message-ID: <3518719F06577C4F85DA618E3C37AB910DA17A41@nimbus.ott.qnx.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]
Hello,
This patch fixes PR 2343: when host and target system OS differ, there can
be mismatch between signal numeric values. This patch introduces new gdbarch
function to allow different targets define their own mapping to enum
target_signal.
ChangeLog:
2007-12-13 Aleksandar Ristovski <aristovski@qnx.com>
* gdbarch.h: (gdbarch_target_signal_from_target_p): New function.
(gdbarch_target_signal_from_target_ftype): New typedef.
(gdbarch_target_signal_from_target): New function.
(set_gdbarch_target_signal_from_target): New function.
* gdbarch.c: (struct gdbarch): New field -
target_signal_from_target.
(struct gdbarch startup_gdbarch): Initialization for the new field.
(verify_gdbarch): Added comment, 'Skip verify...'.
(gdbarch_dump): Printing debug info for the new field.
(gdbarch_target_signal_from_target_p): New function definition.
(gdbarch_target_signal_from_target_ftype): New typedef definition.
(gdbarch_target_signal_from_target): New function definition.
(set_gdbarch_target_signal_from_target): New function definition.
* corelow.c: (core_open): Added logic for calling new function if
specified.
Thank you,
Aleksandar
------
Attachments are virus free!
This message has been scanned for viruses at the originating end by
Nemx Anti-Virus for MS Exchange Server/IMC
http://www.nemx.com/products/antivirus
[-- Attachment #2: gdbPR2343fix.diff --]
[-- Type: application/octet-stream, Size: 6264 bytes --]
Index: gdb/gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.372
diff -u -3 -p -r1.372 gdbarch.h
--- gdb/gdbarch.h 6 Dec 2007 16:32:59 -0000 1.372
+++ gdb/gdbarch.h 13 Dec 2007 16:07:16 -0000
@@ -664,6 +664,16 @@ typedef const struct target_desc * (gdba
extern const struct target_desc * gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_core_read_description_ftype *core_read_description);
+/* Name rationale: 'target_signal' comes from 'enum target_signal',
+ 'from_target' means from target as in inferior. */
+
+extern int gdbarch_target_signal_from_target_p (struct gdbarch *gdbarch);
+
+typedef enum target_signal (gdbarch_target_signal_from_target_ftype) (int signo);
+extern enum target_signal gdbarch_target_signal_from_target (struct gdbarch *gdbarch, int signo);
+extern void set_gdbarch_target_signal_from_target (struct gdbarch *gdbarch, gdbarch_target_signal_from_target_ftype *target_signal_from_target);
+
+
/* Handle special encoding of static variables in stabs debug info. */
extern int gdbarch_static_transform_name_p (struct gdbarch *gdbarch);
Index: gdb/gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.418
diff -u -3 -p -r1.418 gdbarch.c
--- gdb/gdbarch.c 6 Dec 2007 16:32:59 -0000 1.418
+++ gdb/gdbarch.c 13 Dec 2007 16:07:16 -0000
@@ -227,6 +227,7 @@ struct gdbarch
gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
gdbarch_overlay_update_ftype *overlay_update;
gdbarch_core_read_description_ftype *core_read_description;
+ gdbarch_target_signal_from_target_ftype *target_signal_from_target;
gdbarch_static_transform_name_ftype *static_transform_name;
int sofun_address_maybe_missing;
};
@@ -348,6 +349,7 @@ struct gdbarch startup_gdbarch =
0, /* skip_permanent_breakpoint */
0, /* overlay_update */
0, /* core_read_description */
+ 0, /* target_signal_from_target */
0, /* static_transform_name */
0, /* sofun_address_maybe_missing */
/* startup_gdbarch() */
@@ -584,6 +586,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of skip_permanent_breakpoint, has predicate */
/* Skip verify of overlay_update, has predicate */
/* Skip verify of core_read_description, has predicate */
+ /* Skip verify of target_signal_from_target, has predicate */
/* Skip verify of static_transform_name, has predicate */
/* Skip verify of sofun_address_maybe_missing, invalid_p == 0 */
buf = ui_file_xstrdup (log, &dummy);
@@ -687,6 +690,12 @@ gdbarch_dump (struct gdbarch *gdbarch, s
"gdbarch_dump: core_read_description = <0x%lx>\n",
(long) gdbarch->core_read_description);
fprintf_unfiltered (file,
+ "gdbarch_dump: gdbarch_target_signal_from_target_p() = %d\n",
+ gdbarch_target_signal_from_target_p (gdbarch));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: target_signal_from_target = <0x%lx>\n",
+ (long) gdbarch->target_signal_from_target);
+ fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n",
gdbarch_core_xfer_shared_libraries_p (gdbarch));
fprintf_unfiltered (file,
@@ -2917,6 +2926,32 @@ set_gdbarch_core_read_description (struc
}
int
+gdbarch_target_signal_from_target_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->target_signal_from_target != NULL;
+}
+
+enum target_signal
+gdbarch_target_signal_from_target (struct gdbarch *gdbarch, int signo)
+{
+ gdb_assert (gdbarch != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_target_signal_from_target called\n");
+ gdb_assert (gdbarch_target_signal_from_target_p (gdbarch));
+ return gdbarch->target_signal_from_target (signo);
+}
+
+void
+set_gdbarch_target_signal_from_target (struct gdbarch *gdbarch,
+ gdbarch_target_signal_from_target_ftype target_signal_from_target)
+{
+ gdbarch->target_signal_from_target = target_signal_from_target;
+}
+
+
+int
gdbarch_static_transform_name_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
Index: gdb/corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.70
diff -u -3 -p -r1.70 corelow.c
--- gdb/corelow.c 15 Nov 2007 06:14:26 -0000 1.70
+++ gdb/corelow.c 13 Dec 2007 16:07:17 -0000
@@ -353,12 +353,19 @@ core_open (char *filename, int from_tty)
siggy = bfd_core_file_failing_signal (core_bfd);
if (siggy > 0)
+ {
+ enum target_signal gdb_sig;
+ if (core_gdbarch && gdbarch_target_signal_from_target_p (core_gdbarch))
+ gdb_sig = gdbarch_target_signal_from_target (core_gdbarch, siggy);
+ else
+ gdb_sig = target_signal_from_host (siggy);
/* NOTE: target_signal_from_host() converts a target signal value
into gdb's internal signal value. Unfortunately gdb's internal
value is called ``target_signal'' and this function got the
name ..._from_host(). */
- printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy,
- target_signal_to_string (target_signal_from_host (siggy)));
+ printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy,
+ target_signal_to_string (gdb_sig));
+ }
/* Build up thread list from BFD sections. */
@@ -496,7 +503,7 @@ get_core_registers (struct regcache *reg
get_core_register_section (regcache,
".reg-xfp", 3, "extended floating-point", 0);
get_core_register_section (regcache,
- ".reg-ppc-vmx", 3, "ppc Altivec", 0);
+ ".reg-ppc-vmx", 3, "ppc Altivec", 0);
/* Supply dummy value for all registers not found in the core. */
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
next reply other threads:[~2007-12-13 16:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-13 17:05 Aleksandar Ristovski [this message]
2008-01-29 17:02 ` Daniel Jacobowitz
2007-12-16 22:19 Aleksandar Ristovski
2007-12-16 22:25 ` Daniel Jacobowitz
2008-04-21 15:30 Aleksandar Ristovski
2008-04-22 15:56 Aleksandar Ristovski
2008-05-01 19:07 ` Daniel Jacobowitz
2008-05-01 19:39 ` Aleksandar Ristovski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3518719F06577C4F85DA618E3C37AB910DA17A41@nimbus.ott.qnx.com \
--to=aristovski@qnx.com \
--cc=RMansfield@qnx.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox