Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Gary Benson <gbenson@redhat.com>
Cc: gdb-patches@sourceware.org,    Pedro Alves <palves@redhat.com>,
	   Tom Tromey <tromey@redhat.com>
Subject: Re: [PATCH 05/11 v5] Add target/target.h
Date: Wed, 06 Aug 2014 17:49:00 -0000	[thread overview]
Message-ID: <21474.27284.80140.944680@ruffy.mtv.corp.google.com> (raw)
In-Reply-To: <1406888377-25795-6-git-send-email-gbenson@redhat.com>

Gary Benson writes:
 > This adds target/target.h.  This file declares some functions that
 > the shared code can use and that the clients must implement.  It
 > also changes some shared code to use these functions.
 > 
 > gdb/
 > 2014-08-01  Tom Tromey  <tromey@redhat.com>
 > 	    Gary Benson  <gbenson@redhat.com>
 > 
 > 	* target/target.h: New file.
 > 	* Makefile.in (HFILES_NO_SRCDIR): Add target/target.h.
 > 	* target.h: Include target/target.h.
 > 	(target_resume, target_wait, target_stop, target_read_memory)
 > 	(target_write_memory, non_stop): Don't declare.
 > 	* target.c (target_read_uint32): New function.
 > 	* common/agent.c: Include target/target.h.
 > 	[!GDBSERVER]: Don't include target.h or infrun.h.
 > 	(agent_get_helper_thread_id): Use target_read_uint32.
 > 	(agent_run_command): Always use target_resume, target_stop,
 > 	target_wait, target_write_memory, and target_read_memory.
 > 	(agent_capability_check): Use target_read_uint32.
 > 
 > gdb/gdbserver/
 > 2014-08-01  Tom Tromey  <tromey@redhat.com>
 > 	    Gary Benson  <gbenson@redhat.com>
 > 
 > 	* target.c (target_wait, target_stop, target_resume)
 > 	(target_read_memory, target_read_uint32)
 > 	(target_write_memory): New functions.
 > ---
 >  gdb/ChangeLog           |   16 ++++++++
 >  gdb/Makefile.in         |    2 +-
 >  gdb/common/agent.c      |   76 +++---------------------------------
 >  gdb/gdbserver/ChangeLog |    7 +++
 >  gdb/gdbserver/target.c  |   58 ++++++++++++++++++++++++++++
 >  gdb/target.c            |   16 ++++++++
 >  gdb/target.h            |   38 +------------------
 >  gdb/target/target.h     |   98 +++++++++++++++++++++++++++++++++++++++++++++++
 >  8 files changed, 204 insertions(+), 107 deletions(-)
 >  create mode 100644 gdb/target/target.h
 > 
 > diff --git a/gdb/Makefile.in b/gdb/Makefile.in
 > index 8429ebc..090c912 100644
 > --- a/gdb/Makefile.in
 > +++ b/gdb/Makefile.in
 > @@ -936,7 +936,7 @@ ctf.h nat/i386-cpuid.h nat/i386-gcc-cpuid.h target/resume.h \
 >  target/wait.h target/waitstatus.h nat/linux-nat.h nat/linux-waitpid.h \
 >  common/print-utils.h common/rsp-low.h nat/i386-dregs.h x86-linux-nat.h \
 >  i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
 > -common/common-debug.h
 > +common/common-debug.h target/target.h
 >  
 >  # Header files that already have srcdir in them, or which are in objdir.
 >  
 > diff --git a/gdb/common/agent.c b/gdb/common/agent.c
 > index 7071ce6..5c19454 100644
 > --- a/gdb/common/agent.c
 > +++ b/gdb/common/agent.c
 > @@ -21,10 +21,9 @@
 >  #include "server.h"
 >  #else
 >  #include "defs.h"
 > -#include "target.h"
 > -#include "infrun.h"
 >  #include "objfiles.h"
 >  #endif
 > +#include "target/target.h"
 >  #include <unistd.h>
 >  #include "agent.h"
 >  #include "filestuff.h"
 > @@ -126,23 +125,9 @@ agent_get_helper_thread_id (void)
 >  {
 >    if  (helper_thread_id == 0)
 >      {
 > -#ifdef GDBSERVER
 > -      if (read_inferior_memory (ipa_sym_addrs.addr_helper_thread_id,
 > -				(unsigned char *) &helper_thread_id,
 > -				sizeof helper_thread_id))
 > -#else
 > -      enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
 > -      gdb_byte buf[4];
 > -
 > -      if (target_read_memory (ipa_sym_addrs.addr_helper_thread_id,
 > -			      buf, sizeof buf) == 0)
 > -	helper_thread_id = extract_unsigned_integer (buf, sizeof buf,
 > -						     byte_order);
 > -      else
 > -#endif
 > -	{
 > -	  warning (_("Error reading helper thread's id in lib"));
 > -	}
 > +      if (target_read_uint32 (ipa_sym_addrs.addr_helper_thread_id,
 > +			      &helper_thread_id))
 > +	warning (_("Error reading helper thread's id in lib"));
 >      }
 >  
 >    return helper_thread_id;
 > @@ -220,13 +205,8 @@ agent_run_command (int pid, const char *cmd, int len)
 >    int tid = agent_get_helper_thread_id ();
 >    ptid_t ptid = ptid_build (pid, tid, 0);
 >  
 > -#ifdef GDBSERVER
 > -  int ret = write_inferior_memory (ipa_sym_addrs.addr_cmd_buf,
 > -				   (const unsigned char *) cmd, len);
 > -#else
 >    int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf,
 >  				 (gdb_byte *) cmd, len);
 > -#endif
 >  
 >    if (ret != 0)
 >      {
 > @@ -237,18 +217,7 @@ agent_run_command (int pid, const char *cmd, int len)
 >    DEBUG_AGENT ("agent: resumed helper thread\n");
 >  
 >    /* Resume helper thread.  */
 > -#ifdef GDBSERVER
 > -{
 > -  struct thread_resume resume_info;
 > -
 > -  resume_info.thread = ptid;
 > -  resume_info.kind = resume_continue;
 > -  resume_info.sig = GDB_SIGNAL_0;
 > -  (*the_target->resume) (&resume_info, 1);
 > -}
 > -#else
 > - target_resume (ptid, 0, GDB_SIGNAL_0);
 > -#endif
 > +  target_resume (ptid, 0, GDB_SIGNAL_0);
 >  
 >    fd = gdb_connect_sync_socket (pid);
 >    if (fd >= 0)
 > @@ -284,37 +253,18 @@ agent_run_command (int pid, const char *cmd, int len)
 >        int was_non_stop = non_stop;
 >        /* Stop thread PTID.  */
 >        DEBUG_AGENT ("agent: stop helper thread\n");
 > -#ifdef GDBSERVER
 > -      {
 > -	struct thread_resume resume_info;
 > -
 > -	resume_info.thread = ptid;
 > -	resume_info.kind = resume_stop;
 > -	resume_info.sig = GDB_SIGNAL_0;
 > -	(*the_target->resume) (&resume_info, 1);

I certainly welcome replacing that with target_stop(). :-)

 > -      }
 > -
 > -      non_stop = 1;
 > -      mywait (ptid, &status, 0, 0);

The old gdbserver code set non_stop = 1 *after* asking
the target to stop, whereas now it'll be done before (right?).
Just checking that that's ok.
E.g., I see a test for non_stop in linux_resume (which feels weird to be
using in this context given that we're talking about target_stop :-)).

 > -#else
 >        non_stop = 1;
 >        target_stop (ptid);
 >  
 >        memset (&status, 0, sizeof (status));
 >        target_wait (ptid, &status, 0);
 > -#endif
 >        non_stop = was_non_stop;
 >      }
 >  
 >    if (fd >= 0)
 >      {
 > -#ifdef GDBSERVER
 > -      if (read_inferior_memory (ipa_sym_addrs.addr_cmd_buf,
 > -				(unsigned char *) cmd, IPA_CMD_BUF_SIZE))
 > -#else
 >        if (target_read_memory (ipa_sym_addrs.addr_cmd_buf, (gdb_byte *) cmd,
 >  			      IPA_CMD_BUF_SIZE))
 > -#endif
 >  	{
 >  	  warning (_("Error reading command response"));
 >  	  return -1;
 > @@ -334,20 +284,8 @@ agent_capability_check (enum agent_capa agent_capa)
 >  {
 >    if (agent_capability == 0)
 >      {
 > -#ifdef GDBSERVER
 > -      if (read_inferior_memory (ipa_sym_addrs.addr_capability,
 > -				(unsigned char *) &agent_capability,
 > -				sizeof agent_capability))
 > -#else
 > -      enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
 > -      gdb_byte buf[4];
 > -
 > -      if (target_read_memory (ipa_sym_addrs.addr_capability,
 > -			      buf, sizeof buf) == 0)
 > -	agent_capability = extract_unsigned_integer (buf, sizeof buf,
 > -						     byte_order);
 > -      else
 > -#endif
 > +      if (target_read_uint32 (ipa_sym_addrs.addr_capability,
 > +			      &agent_capability))
 >  	warning (_("Error reading capability of agent"));
 >      }
 >    return agent_capability & agent_capa;
 > [...]

LGTM with the above question resolved.


  reply	other threads:[~2014-08-06 17:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-01 10:19 [PATCH 00/11 v5] Common code cleanups Gary Benson
2014-08-01 10:19 ` [PATCH 03/11 v5] Move print-utils.h to common-defs.h Gary Benson
2014-08-06 16:51   ` Doug Evans
2014-08-06 17:05     ` Gary Benson
2014-08-01 10:19 ` [PATCH 02/11 v5] Introduce common-types.h Gary Benson
2014-08-06 16:34   ` Doug Evans
2014-08-01 10:19 ` [PATCH 04/11 v5] Introduce and use debug_printf and debug_vprintf Gary Benson
2014-08-06 17:08   ` Doug Evans
2014-08-07  9:22     ` Gary Benson
2014-08-01 10:22 ` [PATCH 09/11 v5] Remove GDBSERVER uses from linux-btrace.c Gary Benson
2014-08-06 18:27   ` Doug Evans
2014-08-01 10:22 ` [PATCH 07/11 v5] Introduce get_thread_regcache_for_ptid Gary Benson
2014-08-06 18:15   ` Doug Evans
2014-08-01 10:27 ` [PATCH 10/11 v5] Remove GDBSERVER uses from i386-dregs.c Gary Benson
2014-08-06 18:32   ` Doug Evans
2014-08-07 12:28     ` Gary Benson
2014-08-01 10:27 ` [PATCH 08/11 v5] Include common-defs.h instead of defs.h/server.h in shared code Gary Benson
2014-08-06 18:16   ` Doug Evans
2014-08-01 10:28 ` [PATCH 05/11 v5] Add target/target.h Gary Benson
2014-08-06 17:49   ` Doug Evans [this message]
2014-08-07 13:48     ` Gary Benson
2014-08-20 14:49       ` Pedro Alves
2014-08-20 15:01         ` Gary Benson
2014-08-20 15:08           ` Pedro Alves
2014-08-20 12:00   ` Pedro Alves
2014-08-20 12:01   ` Pedro Alves
2014-08-20 13:38     ` Gary Benson
2014-08-01 10:28 ` [PATCH 06/11 v5] Add target/symbol.h Gary Benson
2014-08-06 18:08   ` Doug Evans
2014-08-07 10:42     ` Gary Benson
2014-08-20 11:16   ` Pedro Alves
2014-08-20 12:14     ` Gary Benson
2014-08-20 14:17       ` Pedro Alves
2014-08-01 10:30 ` [PATCH 01/11 v5] Introduce common/errors.h Gary Benson
2014-08-06 16:20   ` Doug Evans
2014-08-06 16:29     ` Gary Benson
2014-08-06 16:40       ` Doug Evans
2014-08-01 10:41 ` [PATCH 11/11 v5] Remove one GDBSERVER use from linux-waitpid.c Gary Benson
2014-08-06 18:35   ` Doug Evans
2014-08-07 12:39     ` Gary Benson
2014-08-20 15:04       ` Pedro Alves

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=21474.27284.80140.944680@ruffy.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=tromey@redhat.com \
    /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