Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aleksandar Ristovski <ARistovski@qnx.com>
To: Aleksandar Ristovski <ARistovski@qnx.com>
Cc: Daniel Jacobowitz <drow@false.org>,
	GDB Patches 	 <gdb-patches@sourceware.org>
Subject: Re: PR 2343 fix: signal number mismatch
Date: Tue, 22 Apr 2008 15:56:00 -0000	[thread overview]
Message-ID: <480DEE05.3020505@qnx.com> (raw)

[-- 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);
+}

             reply	other threads:[~2008-04-22 13:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22 15:56 Aleksandar Ristovski [this message]
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

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=480DEE05.3020505@qnx.com \
    --to=aristovski@qnx.com \
    --cc=drow@false.org \
    --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