* Re: PR 2343 fix: signal number mismatch
@ 2008-04-22 15:56 Aleksandar Ristovski
2008-05-01 19:07 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Aleksandar Ristovski @ 2008-04-22 15:56 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: Daniel Jacobowitz, GDB Patches
[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]
Aleksandar Ristovski wrote:
> Daniel Jacobowitz wrote:
>> gdbarch.h and gdbarch.c are generated files (see the big comment at
>> the top of them). You need to add the new function to the list in
>> gdbarch.sh instead.
>>
>
> Hello Daniel,
>
> I have made changes to gdbarch.sh. The attached patch is not complete (and
> the generated gdbarch.c would not produce linkable gdb) but I just wanted
to
> double-check if this is correct. After you confirm I will add other
> necessary changes.
Added other changes anyway. The attached patch contains complete proposed
patch. Typically, targets would install their own signal translation
functions during the osabi registration. For gdb configured for the same
host and target, no translation is needed, but for other cases, in general,
it is.
This patch effectively deprecates functions "target_signal_from_host" and
"target_signal_to_host".
2008-04-22 Aleksandar Ristovski <aristovski@qnx.com>
PR gdb/2343
* corelow.c (core_open): Use gdbarch_target_signal_from_host to
translate signal numeric value from the target to GDB's enum
target_signal.
* gdbarch.c (gdbarch_target_signal_from_host,
gdbarch_target_signal_to_host, set_gdbarch_target_signal_from_host,
set_gdbarch_target_signal_to_host): New functions. Generated by
gdbarch.sh.
* gdbarch.h: Likewise.
* gdbarch.sh: Added two new functions target_signal_from_host and
target_signal_to_host.
* target.h (default_target_signal_from_host,
default_target_signal_to_host): New functions - declarations.
* signals/signals.c (struct gdbarch): New declaration.
(default_target_signal_to_host, default_target_signal_from_host):
New
functions.
[-- Attachment #2: gdbarch.sh.target_signal.diff --]
[-- Type: text/plain, Size: 9004 bytes --]
Index: gdb/corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.73
diff -u -p -r1.73 corelow.c
--- gdb/corelow.c 9 Feb 2008 13:45:33 -0000 1.73
+++ gdb/corelow.c 22 Apr 2008 13:33:30 -0000
@@ -359,7 +359,8 @@ core_open (char *filename, int from_tty)
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)));
+ target_signal_to_string (
+ gdbarch_target_signal_from_host (core_gdbarch, siggy)));
/* Build up thread list from BFD sections. */
Index: gdb/gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.422
diff -u -p -r1.422 gdbarch.c
--- gdb/gdbarch.c 22 Apr 2008 11:03:41 -0000 1.422
+++ gdb/gdbarch.c 22 Apr 2008 13:33:30 -0000
@@ -230,6 +230,8 @@ struct gdbarch
gdbarch_core_read_description_ftype *core_read_description;
gdbarch_static_transform_name_ftype *static_transform_name;
int sofun_address_maybe_missing;
+ gdbarch_target_signal_from_host_ftype *target_signal_from_host;
+ gdbarch_target_signal_to_host_ftype *target_signal_to_host;
};
@@ -352,6 +354,8 @@ struct gdbarch startup_gdbarch =
0, /* core_read_description */
0, /* static_transform_name */
0, /* sofun_address_maybe_missing */
+ default_target_signal_from_host, /* target_signal_from_host */
+ default_target_signal_to_host, /* target_signal_to_host */
/* startup_gdbarch() */
};
@@ -431,6 +435,8 @@ gdbarch_alloc (const struct gdbarch_info
gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
gdbarch->name_of_malloc = "malloc";
gdbarch->register_reggroup_p = default_register_reggroup_p;
+ gdbarch->target_signal_from_host = default_target_signal_from_host;
+ gdbarch->target_signal_to_host = default_target_signal_to_host;
/* gdbarch_alloc() */
return gdbarch;
@@ -590,6 +596,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of core_read_description, has predicate */
/* Skip verify of static_transform_name, has predicate */
/* Skip verify of sofun_address_maybe_missing, invalid_p == 0 */
+ /* Skip verify of target_signal_from_host, invalid_p == 0 */
+ /* Skip verify of target_signal_to_host, invalid_p == 0 */
buf = ui_file_xstrdup (log, &dummy);
make_cleanup (xfree, buf);
if (strlen (buf) > 0)
@@ -979,6 +987,12 @@ gdbarch_dump (struct gdbarch *gdbarch, s
"gdbarch_dump: target_desc = %s\n",
paddr_d ((long) gdbarch->target_desc));
fprintf_unfiltered (file,
+ "gdbarch_dump: target_signal_from_host = <0x%lx>\n",
+ (long) gdbarch->target_signal_from_host);
+ fprintf_unfiltered (file,
+ "gdbarch_dump: target_signal_to_host = <0x%lx>\n",
+ (long) gdbarch->target_signal_to_host);
+ fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_unwind_dummy_id_p() = %d\n",
gdbarch_unwind_dummy_id_p (gdbarch));
fprintf_unfiltered (file,
@@ -2981,6 +2995,40 @@ set_gdbarch_sofun_address_maybe_missing
gdbarch->sofun_address_maybe_missing = sofun_address_maybe_missing;
}
+enum target_signal
+gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->target_signal_from_host != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_target_signal_from_host called\n");
+ return gdbarch->target_signal_from_host (gdbarch, signo);
+}
+
+void
+set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch,
+ gdbarch_target_signal_from_host_ftype target_signal_from_host)
+{
+ gdbarch->target_signal_from_host = target_signal_from_host;
+}
+
+int
+gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->target_signal_to_host != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_target_signal_to_host called\n");
+ return gdbarch->target_signal_to_host (gdbarch, ts);
+}
+
+void
+set_gdbarch_target_signal_to_host (struct gdbarch *gdbarch,
+ gdbarch_target_signal_to_host_ftype target_signal_to_host)
+{
+ gdbarch->target_signal_to_host = target_signal_to_host;
+}
+
/* Keep a registry of per-architecture data-pointers required by GDB
modules. */
Index: gdb/gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.376
diff -u -p -r1.376 gdbarch.h
--- gdb/gdbarch.h 22 Apr 2008 11:03:41 -0000 1.376
+++ gdb/gdbarch.h 22 Apr 2008 13:33:30 -0000
@@ -683,6 +683,20 @@ extern void set_gdbarch_static_transform
extern int gdbarch_sofun_address_maybe_missing (struct gdbarch *gdbarch);
extern void set_gdbarch_sofun_address_maybe_missing (struct gdbarch *gdbarch, int sofun_address_maybe_missing);
+/* Signal translation: translate inferior's signal (host's) number into
+ GDB's representation. */
+
+typedef enum target_signal (gdbarch_target_signal_from_host_ftype) (struct gdbarch *gdbarch, int signo);
+extern enum target_signal gdbarch_target_signal_from_host (struct gdbarch *gdbarch, int signo);
+extern void set_gdbarch_target_signal_from_host (struct gdbarch *gdbarch, gdbarch_target_signal_from_host_ftype *target_signal_from_host);
+
+/* Signal translation: translate GDB's signal number into inferior's host
+ signal number. */
+
+typedef int (gdbarch_target_signal_to_host_ftype) (struct gdbarch *gdbarch, enum target_signal ts);
+extern int gdbarch_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts);
+extern void set_gdbarch_target_signal_to_host (struct gdbarch *gdbarch, gdbarch_target_signal_to_host_ftype *target_signal_to_host);
+
extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
Index: gdb/gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.462
diff -u -p -r1.462 gdbarch.sh
--- gdb/gdbarch.sh 22 Apr 2008 11:03:41 -0000 1.462
+++ gdb/gdbarch.sh 22 Apr 2008 13:33:31 -0000
@@ -619,6 +619,13 @@ M:const struct target_desc *:core_read_d
F:char *:static_transform_name:char *name:name
# Set if the address in N_SO or N_FUN stabs may be zero.
v:int:sofun_address_maybe_missing:::0:0::0
+
+# Signal translation: translate inferior's signal (host's) number into
+# GDB's representation.
+m:enum target_signal:target_signal_from_host:int signo:signo::default_target_signal_from_host::0
+# Signal translation: translate GDB's signal number into inferior's host
+# signal number.
+m:int:target_signal_to_host:enum target_signal ts:ts::default_target_signal_to_host::0
EOF
}
Index: gdb/target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.116
diff -u -p -r1.116 target.h
--- gdb/target.h 8 Apr 2008 17:02:23 -0000 1.116
+++ gdb/target.h 22 Apr 2008 13:33:32 -0000
@@ -1233,6 +1233,11 @@ extern int target_signal_to_host_p (enum
extern enum target_signal target_signal_from_host (int);
extern int target_signal_to_host (enum target_signal);
+extern enum target_signal default_target_signal_from_host (struct gdbarch *,
+ int);
+extern int default_target_signal_to_host (struct gdbarch *,
+ enum target_signal);
+
/* Convert from a number used in a GDB command to an enum target_signal. */
extern enum target_signal target_signal_from_command (int);
Index: gdb/signals/signals.c
===================================================================
RCS file: /cvs/src/src/gdb/signals/signals.c,v
retrieving revision 1.17
diff -u -p -r1.17 signals.c
--- gdb/signals/signals.c 1 Jan 2008 22:53:15 -0000 1.17
+++ gdb/signals/signals.c 22 Apr 2008 13:33:34 -0000
@@ -30,6 +30,8 @@
#include <signal.h>
#endif
+struct gdbarch;
+
/* Always use __SIGRTMIN if it's available. SIGRTMIN is the lowest
_available_ realtime signal, not the lowest supported; glibc takes
several for its own use. */
@@ -831,3 +833,15 @@ _initialize_signals (void)
internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
#endif
+
+int
+default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts)
+{
+ return target_signal_to_host (ts);
+}
+
+enum target_signal
+default_target_signal_from_host (struct gdbarch *gdbarch, int signo)
+{
+ return target_signal_from_host (signo);
+}
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: PR 2343 fix: signal number mismatch
2008-04-22 15:56 PR 2343 fix: signal number mismatch Aleksandar Ristovski
@ 2008-05-01 19:07 ` Daniel Jacobowitz
2008-05-01 19:39 ` Aleksandar Ristovski
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-05-01 19:07 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: GDB Patches
On Tue, Apr 22, 2008 at 09:54:13AM -0400, Aleksandar Ristovski wrote:
> Added other changes anyway. The attached patch contains complete proposed
> patch. Typically, targets would install their own signal translation
> functions during the osabi registration. For gdb configured for the same
> host and target, no translation is needed, but for other cases, in general,
> it is.
>
> This patch effectively deprecates functions "target_signal_from_host" and
> "target_signal_to_host".
Only for targets with cross core file support. Native and remote
debugging are not affected.
> 2008-04-22 Aleksandar Ristovski <aristovski@qnx.com>
>
> PR gdb/2343
> * corelow.c (core_open): Use gdbarch_target_signal_from_host to
> translate signal numeric value from the target to GDB's enum
> target_signal.
> * gdbarch.c (gdbarch_target_signal_from_host,
> gdbarch_target_signal_to_host, set_gdbarch_target_signal_from_host,
> set_gdbarch_target_signal_to_host): New functions. Generated by
> gdbarch.sh.
> * gdbarch.h: Likewise.
> * gdbarch.sh: Added two new functions target_signal_from_host and
> target_signal_to_host.
> * target.h (default_target_signal_from_host,
> default_target_signal_to_host): New functions - declarations.
> * signals/signals.c (struct gdbarch): New declaration.
> (default_target_signal_to_host, default_target_signal_from_host):
> New
> functions.
Thanks, this is OK.
You can just write:
* gdbarch.c, gdbarch.sh: Regenerated.
for those two files.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 2343 fix: signal number mismatch
2008-05-01 19:07 ` Daniel Jacobowitz
@ 2008-05-01 19:39 ` Aleksandar Ristovski
0 siblings, 0 replies; 8+ messages in thread
From: Aleksandar Ristovski @ 2008-05-01 19:39 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: GDB Patches
Daniel Jacobowitz wrote:
> On Tue, Apr 22, 2008 at 09:54:13AM -0400, Aleksandar Ristovski wrote:
>> Added other changes anyway. The attached patch contains complete proposed
>> patch. Typically, targets would install their own signal translation
>> functions during the osabi registration. For gdb configured for the same
>> host and target, no translation is needed, but for other cases, in general,
>> it is.
>>
>> This patch effectively deprecates functions "target_signal_from_host" and
>> "target_signal_to_host".
>
>
> Thanks, this is OK.
>
Committed.
Thanks,
Aleksandar
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PR 2343 fix: signal number mismatch
@ 2008-04-21 15:30 Aleksandar Ristovski
0 siblings, 0 replies; 8+ messages in thread
From: Aleksandar Ristovski @ 2008-04-21 15:30 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: GDB Patches
[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]
Daniel Jacobowitz wrote:
>
> gdbarch.h and gdbarch.c are generated files (see the big comment at
> the top of them). You need to add the new function to the list in
> gdbarch.sh instead.
>
Hello Daniel,
I have made changes to gdbarch.sh. The attached patch is not complete (and
the generated gdbarch.c would not produce linkable gdb) but I just wanted to
double-check if this is correct. After you confirm I will add other
necessary changes.
The patch introduces two new functions for translating signal number between
GDB's internal representation and targeted system's signal number.
To give some background to those who are not familiar with the issue: in
multi-arch situations, or in remote debugging situations, target's signal
number and gdb's signal number may not match, e.g. signal number 14 on the
target may mean SIGINT, while it may mean something else on the GDB's host
system. In such cases, GDB will misinterpret the inferior's signal; this can
also easily happen when examining core files on a GDB host other than the
system that generated the core.
Please pay special attention to the naming, it is somewhat confusing: 'enum
target_signal' is GDB's universal representation of signals and is GDB's
host independent. New functions added to gdbarch structure are named as
follows:
target_signal_to_host
and
target_signal_from_host
where 'host' means 'inferior's host' (host where inferior is running).
Thanks,
Aleksandar Ristovski
QNX Software Systems
[-- Attachment #2: gdbarch.sh.target_signal.diff --]
[-- Type: text/plain, Size: 871 bytes --]
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.461
diff -u -p -r1.461 gdbarch.sh
--- gdbarch.sh 20 Feb 2008 14:31:40 -0000 1.461
+++ gdbarch.sh 21 Apr 2008 14:23:11 -0000
@@ -619,6 +619,13 @@ M:const struct target_desc *:core_read_d
F:char *:static_transform_name:char *name:name
# Set if the address in N_SO or N_FUN stabs may be zero.
v:int:sofun_address_maybe_missing:::0:0::0
+
+# Signal translation: translate inferior's signal (host's) number into
+# GDB's representation.
+m:enum target_signal:target_signal_from_host:int signo:signo::default_target_signal_from_host::0
+# Signal translation: translate GDB's signal number into inferior's host
+# signal number.
+m:int:target_signal_to_host:enum target_signal ts:ts::default_target_signal_to_host::0
EOF
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* PR 2343 fix: signal number mismatch
@ 2007-12-16 22:19 Aleksandar Ristovski
2007-12-16 22:25 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Aleksandar Ristovski @ 2007-12-16 22:19 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1509 bytes --]
Hello,
Could you, please, let me know if I need to provide some additional
information for this? I thought the patch was straight forward, but I may be
wrong.
Thank you,
Aleksandar Ristovski
QNX Software Systems
-------
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): 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++)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: PR 2343 fix: signal number mismatch
2007-12-16 22:19 Aleksandar Ristovski
@ 2007-12-16 22:25 ` Daniel Jacobowitz
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-12-16 22:25 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches
On Sun, Dec 16, 2007 at 05:07:38PM -0500, Aleksandar Ristovski wrote:
> Hello,
>
> Could you, please, let me know if I need to provide some additional
> information for this? I thought the patch was straight forward, but I may be
> wrong.
GDB suffers a severe shortage of patch reviewers. As you can see from
today's list traffic, it often takes a month or more to get a response
to a patch. This is unfortunate, but there's nothing more I can do
about it single-handedly than I am already doing - ideas and
assistance welcome. Your patch has not been lost; I will try to
keep catching up this week...
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
* PR 2343 fix: signal number mismatch
@ 2007-12-13 17:05 Aleksandar Ristovski
2008-01-29 17:02 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Aleksandar Ristovski @ 2007-12-13 17:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Ryan Mansfield
[-- 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++)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: PR 2343 fix: signal number mismatch
2007-12-13 17:05 Aleksandar Ristovski
@ 2008-01-29 17:02 ` Daniel Jacobowitz
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2008-01-29 17:02 UTC (permalink / raw)
To: Aleksandar Ristovski; +Cc: gdb-patches, Ryan Mansfield
On Thu, Dec 13, 2007 at 11:11:58AM -0500, Aleksandar Ristovski wrote:
> 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.
gdbarch.h and gdbarch.c are generated files (see the big comment at
the top of them). You need to add the new function to the list in
gdbarch.sh instead.
The old comment:
/* 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(). */
should go above the call to target_signal_from_host in one branch of
the if statement, I think.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-05-01 19:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-22 15:56 PR 2343 fix: signal number mismatch Aleksandar Ristovski
2008-05-01 19:07 ` Daniel Jacobowitz
2008-05-01 19:39 ` Aleksandar Ristovski
-- strict thread matches above, loose matches on Subject: below --
2008-04-21 15:30 Aleksandar Ristovski
2007-12-16 22:19 Aleksandar Ristovski
2007-12-16 22:25 ` Daniel Jacobowitz
2007-12-13 17:05 Aleksandar Ristovski
2008-01-29 17:02 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox