public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <alves.ped@gmail.com>
Cc: gdb-patches@sourceware.org,
	Daniel Jacobowitz <dan@codesourcery.com>,
	       Joel Brobecker <brobecker@adacore.com>,
	Eli Zaretskii <eliz@gnu.org>,
	       Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [patch 1/9]#2 Rename `enum target_signal' to target_signal_t
Date: Tue, 07 Sep 2010 18:59:00 -0000	[thread overview]
Message-ID: <20100907175813.GA27668@host1.dyn.jankratochvil.net> (raw)
In-Reply-To: <20100902193311.GA26746@host1.dyn.jankratochvil.net>

On Thu, 02 Sep 2010 21:33:11 +0200, Jan Kratochvil wrote:
> On Thu, 02 Sep 2010 19:27:52 +0200, Pedro Alves wrote:
> > I don't think it is a good idea to associate the siginfo with a signal
> > and think of it as a single entity.  For many cases, you don't need the
> > siginfo.  Carrying it around would be extra burden, especially for the remote
> > target.
> 
> For the remote part I was thinking about making it lazy, requesting it only
> when retrieved for a different kind of processing than a target resume.

While trying to implement it I found it cannot be done (without C++).

If target_signal_t as returned by remote_wait (=to_wait implementation) is
lazy it can either be passed to remote_resume (=to_resume implementation) or
saved by infrun.c save_inferior_thread_state.  But remote.c can no longer
track where that target_signal_t has been copied without C++.

On Mon, 30 Aug 2010 09:09:55 +0200, Jan Kratochvil wrote:
# I tried to make target_signal a pointer with reference counter.  I have the
# unfinished patch here but I really do not find it viable.  All the assignments
# and passing by value to functions make it difficult to catch all the cases.
# With C++ GDB this patchset could be greatly simplified with fixed performance.
+
Even if the implementation would get finished I find target_signal_t a too
basic type to require explicit reference counting while having no compiler
checks of it.  It could become a large problem similar to all the effort to
manage the GObject reference counting in Gnome/C.

remote.c PASSes with FSF gdbserver even for gdb.base/siginfo-infcall.exp but
without C++ it has to have the back-and-forth siginfo_t transfer overhead.
[attached as a preview]

Therefore going to implement explicit carrying of associated siginfo_t
together with siginfo-less target_signal_t in the middle-end (infrun.c&co.).


Regards,
Jan


--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -176,6 +176,18 @@ static void print_packet (char *);
 
 static void compare_sections_command (char *, int);
 
+struct packet_config;
+
+static LONGEST remote_read_qxfer (struct target_ops *ops,
+				  const char *object_name, const char *annex,
+				  gdb_byte *readbuf, ULONGEST offset,
+				  LONGEST len, struct packet_config *packet);
+
+static LONGEST remote_write_qxfer (struct target_ops *ops,
+				   const char *object_name, const char *annex,
+				   const gdb_byte *writebuf, ULONGEST offset,
+				   LONGEST len, struct packet_config *packet);
+
 static void packet_command (char *, int);
 
 static int stub_unpack_int (char *buff, int fieldlength);
@@ -196,8 +208,6 @@ static int putpkt_binary (char *buf, int cnt);
 
 static void check_binary_download (CORE_ADDR addr);
 
-struct packet_config;
-
 static void show_packet_config_cmd (struct packet_config *config);
 
 static void update_packet_config (struct packet_config *config);
@@ -4446,6 +4456,32 @@ remote_vcont_resume (ptid_t ptid, int step, target_signal_t siggnal)
   if (remote_protocol_packets[PACKET_vCont].support == PACKET_DISABLE)
     return 0;
 
+  if (target_signal_siginfo_p (&siggnal))
+    {
+      ptid_t siggnal_ptid;
+      struct gdbarch *siggnal_ptid_gdbarch;
+      size_t len;
+      gdb_byte *siginfop;
+      LONGEST got;
+
+      if (ptid_equal (ptid, magic_null_ptid)
+          || ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
+	siggnal_ptid = inferior_ptid;
+      else
+	siggnal_ptid = ptid;
+
+      set_general_thread (siggnal_ptid);
+
+      siggnal_ptid_gdbarch = target_thread_architecture (siggnal_ptid);
+      len = target_signal_siginfo_len (siggnal_ptid_gdbarch);
+      siginfop = target_signal_siginfo_get (&siggnal, siggnal_ptid_gdbarch);
+
+      got = remote_write_qxfer (NULL /* unused */, "siginfo", NULL, siginfop,
+				0, len, &remote_protocol_packets
+					 [PACKET_qXfer_siginfo_read]);
+      /* FIXME: Real len.  */
+    }
+
   p = rs->buf;
   endp = rs->buf + get_remote_packet_size ();
 
@@ -4554,6 +4590,34 @@ remote_resume (struct target_ops *ops,
     {
       int siggnal_number = TARGET_SIGNAL_NUMBER (siggnal);
 
+      if (target_signal_siginfo_p (&siggnal))
+	{
+	  ptid_t siggnal_ptid;
+	  struct gdbarch *siggnal_ptid_gdbarch;
+	  size_t len;
+	  gdb_byte *siginfop;
+	  LONGEST got;
+
+	  if (ptid_equal (ptid, magic_null_ptid)
+	      || ptid_equal (ptid, minus_one_ptid) || ptid_is_pid (ptid))
+	    siggnal_ptid = inferior_ptid;
+	  else
+	    siggnal_ptid = ptid;
+
+	  set_general_thread (siggnal_ptid);
+
+	  siggnal_ptid_gdbarch = target_thread_architecture (siggnal_ptid);
+	  len = target_signal_siginfo_len (siggnal_ptid_gdbarch);
+	  siginfop = target_signal_siginfo_get (&siggnal,
+						siggnal_ptid_gdbarch);
+
+	  got = remote_write_qxfer (NULL /* unused */, "siginfo", NULL,
+				    siginfop, 0, len,
+				    &remote_protocol_packets
+				     [PACKET_qXfer_siginfo_read]);
+	  /* FIXME: Real len.  */
+	}
+
       buf[0] = step ? 'S' : 'C';
       buf[1] = tohex ((siggnal_number >> 4) & 0xf);
       buf[2] = tohex (siggnal_number & 0xf);
@@ -5575,6 +5639,37 @@ remote_wait (struct target_ops *ops,
   else
     event_ptid = remote_wait_as (ptid, status, options);
 
+  if (TARGET_WAITKIND_USES_SIG (status->kind))
+    {
+      ptid_t siggnal_ptid;
+      struct gdbarch *siggnal_ptid_gdbarch;
+      size_t len;
+      gdb_byte siginfo[MAX_SIGINFO_SIZE];
+      LONGEST got;
+
+      if (ptid_equal (event_ptid, magic_null_ptid)
+	  || ptid_equal (event_ptid, minus_one_ptid)
+	  || ptid_is_pid (event_ptid))
+	siggnal_ptid = inferior_ptid;
+      else
+	siggnal_ptid = event_ptid;
+
+      siggnal_ptid_gdbarch = target_thread_architecture (siggnal_ptid);
+      len = target_signal_siginfo_len (siggnal_ptid_gdbarch);
+
+      got = remote_read_qxfer (ops, "siginfo", NULL, siginfo, 0, len,
+			       &remote_protocol_packets
+				[PACKET_qXfer_siginfo_read]);
+      if (got >= 0)
+	{
+	  set_general_thread (siggnal_ptid);
+
+	  memset (&siginfo[got], 0, len - got);
+	  target_signal_siginfo_set (&status->value.sig, siggnal_ptid_gdbarch,
+				     siginfo);
+	}
+    }
+
   if (target_can_async_p ())
     {
       /* If there are are events left in the queue tell the event loop

  reply	other threads:[~2010-09-07 17:58 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30  7:11 Jan Kratochvil
2010-08-30  8:14 ` Mark Kettenis
2010-08-30  8:24   ` Jan Kratochvil
2010-08-30 10:09     ` Eli Zaretskii
2010-08-30 11:11       ` Mark Kettenis
2010-08-30 14:08         ` Joel Brobecker
2010-08-31 18:28           ` Jan Kratochvil
2010-08-31 18:45             ` Mark Kettenis
2010-09-01  2:03             ` Joel Brobecker
2010-09-01 18:18             ` Joel Brobecker
2010-09-01 18:30               ` Jan Kratochvil
2010-09-01 18:38                 ` Pedro Alves
2010-09-01 18:45                   ` Jan Kratochvil
2010-09-01 18:40                 ` Joel Brobecker
2010-09-01 18:51                   ` Jan Kratochvil
2010-09-01 19:08                     ` Pedro Alves
2010-09-01 19:28                       ` Jan Kratochvil
2010-09-01 20:06                         ` Pedro Alves
2010-09-01 20:06                           ` Daniel Jacobowitz
2010-09-01 20:10                             ` Pedro Alves
2010-09-02  9:46                               ` Pedro Alves
2010-09-02 14:01                                 ` Jan Kratochvil
2010-09-02 15:36                                   ` Joel Brobecker
2010-09-02 19:02                                   ` Pedro Alves
2010-09-02 20:46                                     ` Jan Kratochvil
2010-09-07 18:59                                       ` Jan Kratochvil [this message]
2010-09-02 16:02                                 ` Joel Brobecker
2010-09-02 17:04                                   ` Jan Kratochvil
2010-09-06  0:29                                 ` Jan Kratochvil
2010-09-06 13:30                                   ` Pedro Alves
2010-09-06 14:52                                     ` Jan Kratochvil
2010-09-08 23:42                                 ` Jan Kratochvil
2010-09-01 20:23                           ` Jan Kratochvil
2010-09-01 20:30                             ` Mark Kettenis
2010-09-01 20:47                             ` Pedro Alves
2010-09-01 21:32                         ` Joseph S. Myers
2010-09-01 19:12                     ` Joel Brobecker
2010-09-01 22:37                     ` Tom Tromey
2010-08-30 14:11         ` Eli Zaretskii
2010-08-30 17:34     ` Michael Snyder

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=20100907175813.GA27668@host1.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=alves.ped@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=dan@codesourcery.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).