Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>, Doug Evans <dje@google.com>
Subject: [PATCH 14/15 v2] Introduce get_thread_regcache_for_ptid
Date: Wed, 16 Jul 2014 16:33:00 -0000	[thread overview]
Message-ID: <1405520243-17282-15-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1405520243-17282-1-git-send-email-gbenson@redhat.com>

This introduces get_thread_regcache_for_ptid so that we can simplify
nat/linux-btrace.c.  A better long term solution would be unify the
regcache code, but this is sufficient for now.

gdb/
2014-07-16  Tom Tromey  <tromey@redhat.com>
	    Gary Benson  <gbenson@redhat.com>

	* common/common-regcache.h: New file.
	* regcache.c: Include the above.
	(get_thread_regcache_for_ptid): New function.
	* nat/linux-btrace.c: Include common-regcache.h.
	(perf_event_read_bts): Use get_thread_regcache_for_ptid.

gdb/gdbserver/
2014-07-16  Tom Tromey  <tromey@redhat.com>
	    Gary Benson  <gbenson@redhat.com>

	* regcache.c: Include common-regcache.h.
	(get_thread_regcache_for_ptid): New function.
---
 gdb/ChangeLog                |    9 +++++++++
 gdb/common/common-regcache.h |   28 ++++++++++++++++++++++++++++
 gdb/gdbserver/ChangeLog      |    6 ++++++
 gdb/gdbserver/regcache.c     |    9 +++++++++
 gdb/nat/linux-btrace.c       |    7 ++-----
 gdb/regcache.c               |    8 ++++++++
 6 files changed, 62 insertions(+), 5 deletions(-)
 create mode 100644 gdb/common/common-regcache.h

diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h
new file mode 100644
index 0000000..2ef7cb1
--- /dev/null
+++ b/gdb/common/common-regcache.h
@@ -0,0 +1,28 @@
+/* Cache and manage the values of registers
+
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef COMMON_REGCACHE_H
+#define COMMON_REGCACHE_H
+
+/* A hack until we have an independent regcache.  This must be
+   provided by the user.  */
+
+extern struct regcache *get_thread_regcache_for_ptid (ptid_t ptid);
+
+#endif /* COMMON_REGCACHE_H */
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index bed10b4..eb72322 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -21,6 +21,7 @@
 #include "gdbthread.h"
 #include "tdesc.h"
 #include "rsp-low.h"
+#include "common-regcache.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -65,6 +66,14 @@ get_thread_regcache (struct thread_info *thread, int fetch)
   return regcache;
 }
 
+/* See common/linux-btrace.h.  */
+
+struct regcache *
+get_thread_regcache_for_ptid (ptid_t ptid)
+{
+  return get_thread_regcache (find_thread_ptid (ptid), 1);
+}
+
 void
 regcache_invalidate_thread (struct thread_info *thread)
 {
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 188220b..3b4180f 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -32,6 +32,7 @@
 #include "gdbthread.h"
 #include "gdb_wait.h"
 #include "i386-cpuid.h"
+#include "common-regcache.h"
 
 #ifdef HAVE_SYS_SYSCALL_H
 #include <sys/syscall.h>
@@ -184,11 +185,7 @@ perf_event_read_bts (struct btrace_target_info* tinfo, const uint8_t *begin,
   gdb_assert (start <= end);
 
   /* The first block ends at the current pc.  */
-#ifdef GDBSERVER
-  regcache = get_thread_regcache (find_thread_ptid (tinfo->ptid), 1);
-#else
-  regcache = get_thread_regcache (tinfo->ptid);
-#endif
+  regcache = get_thread_regcache_for_ptid (tinfo->ptid);
   block.end = regcache_read_pc (regcache);
 
   /* The buffer may contain a partial record as its last entry (i.e. when the
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 5ee90b0..e66a40e 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -30,6 +30,7 @@
 #include "exceptions.h"
 #include "remote.h"
 #include "valprint.h"
+#include "common-regcache.h"
 
 /*
  * DATA STRUCTURE
@@ -537,6 +538,13 @@ get_current_regcache (void)
   return get_thread_regcache (inferior_ptid);
 }
 
+/* See common/linux-btrace.h.  */
+
+struct regcache *
+get_thread_regcache_for_ptid (ptid_t ptid)
+{
+  return get_thread_regcache (ptid);
+}
 
 /* Observer for the target_changed event.  */
 
-- 
1.7.1


  parent reply	other threads:[~2014-07-16 16:33 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-16 16:19 [PATCH 00/15 v2] Common code cleanups Gary Benson
2014-07-16 16:19 ` [PATCH 04/15 v2] Introduce common-types.h Gary Benson
2014-07-17 11:21   ` Doug Evans
2014-07-16 16:19 ` [PATCH 15/15 v2] Finally remove GDBSERVER (mostly) from linux-btrace.c Gary Benson
2014-07-16 16:32 ` [PATCH 09/15 v2] Mostly remove GDBSERVER from linux-waitpid.c Gary Benson
2014-07-16 16:33 ` Gary Benson [this message]
2014-07-16 16:45 ` [PATCH 02/15 v2] Remove some GDBSERVER checks from linux-ptrace Gary Benson
2014-07-17  8:37   ` Doug Evans
2014-07-17 16:40   ` Pedro Alves
2014-07-16 16:45 ` [PATCH 05/15 v2] Introduce and use debug_printf and debug_vprintf Gary Benson
2014-07-16 16:45 ` [PATCH 01/15 v2] Introduce common/errors.h Gary Benson
2014-07-16 18:36   ` Doug Evans
2014-07-17 13:41     ` [PATCH] " Gary Benson
2014-07-17 13:47       ` Gary Benson
2014-07-17 14:05     ` [PATCH 01/15 v3] " Gary Benson
2014-07-17 15:40       ` Pedro Alves
2014-07-17 16:03         ` Gary Benson
2014-07-17 16:19           ` Pedro Alves
2014-07-18  9:20             ` Gary Benson
2014-07-18 10:42               ` Doug Evans
2014-07-18 11:23                 ` Gary Benson
2014-07-18 12:31                   ` Doug Evans
2014-07-18 10:44               ` Pedro Alves
2014-07-16 16:48 ` [PATCH 03/15 v2] Make gdbserver CORE_ADDR unsigned Gary Benson
2014-07-17  9:02   ` Doug Evans
2014-07-17 16:42   ` Pedro Alves
2014-07-18  8:07     ` Maciej W. Rozycki
2014-07-16 16:48 ` [PATCH 06/15 v2] Remove simple GDBSERVER uses from common, nat and target Gary Benson
2014-07-16 17:03 ` [PATCH 11/15 v2] More target unification Gary Benson
2014-07-16 17:03 ` [PATCH 13/15 v2] Finally remove GDBSERVER (mostly) from agent.c Gary Benson
2014-07-16 17:03 ` [PATCH 08/15 v2] Make btrace-common.h not use GDBSERVER Gary Benson
2014-07-16 17:04 ` [PATCH 10/15 v2] Add target/target.h Gary Benson
2014-07-16 17:20 ` [PATCH 12/15 v2] Add target/symbol.h, update users Gary Benson
2014-07-16 17:24 ` [PATCH 07/15 v2] Remove GDBSERVER use from nat/i386-dregs.c Gary Benson

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=1405520243-17282-15-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --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