From: "Marcin Kościelnicki" <koriakin@0x04.net>
To: uweigand@de.ibm.com
Cc: arnez@linux.vnet.ibm.com, gdb-patches@sourceware.org,
"Marcin Kościelnicki" <koriakin@0x04.net>
Subject: [PATCH 1/2] gdb: Add guess_tracepoint_registers hook to gdbarch.
Date: Thu, 18 Feb 2016 10:35:00 -0000 [thread overview]
Message-ID: <1455791730-28225-1-git-send-email-koriakin@0x04.net> (raw)
In-Reply-To: <20160216182754.CE86C6BEA@oc7340732750.ibm.com>
When we're looking at a tracefile trace frame where registers are not
available, and the tracepoint has only one location, we supply
the location's address as the PC register. However, this only works
if PC is not a pseudo register, and individual architectures may want
to guess more registers. Add a gdbarch hook that will handle that.
gdb/ChangeLog:
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add guess_tracepoint_registers hook, struct tracepoint
declaration, and tracepoint.h include.
* tracefile.c (tracefile_fetch_registers): Use the new gdbarch hook.
* tracepoint.c (default_guess_tracepoint_registers): New function.
* tracepoint.h (default_guess_tracepoint_registers): New prototype.
---
Here comes the updated patches.
gdb/ChangeLog | 10 ++++++++++
gdb/gdbarch.c | 24 +++++++++++++++++++++++
gdb/gdbarch.h | 10 ++++++++++
gdb/gdbarch.sh | 8 ++++++++
gdb/tracefile.c | 60 ++++++++++++++++++++------------------------------------
gdb/tracepoint.c | 23 ++++++++++++++++++++++
gdb/tracepoint.h | 4 ++++
7 files changed, 100 insertions(+), 39 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e507dd1..95afe29 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2016-02-18 Marcin KoÅcielnicki <koriakin@0x04.net>
+
+ * gdbarch.c: Regenerate.
+ * gdbarch.h: Regenerate.
+ * gdbarch.sh: Add guess_tracepoint_registers hook, struct tracepoint
+ declaration, and tracepoint.h include.
+ * tracefile.c (tracefile_fetch_registers): Use the new gdbarch hook.
+ * tracepoint.c (default_guess_tracepoint_registers): New function.
+ * tracepoint.h (default_guess_tracepoint_registers): New prototype.
+
2016-02-17 Gary Benson <gbenson@redhat.com>
* exec.c (exec_file_locate_attach): Add missing cleanup.
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 4143744..532b259 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -47,6 +47,7 @@
#include "observer.h"
#include "regcache.h"
#include "objfiles.h"
+#include "tracepoint.h"
/* Static function declarations */
@@ -312,6 +313,7 @@ struct gdbarch
int has_global_breakpoints;
gdbarch_has_shared_address_space_ftype *has_shared_address_space;
gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at;
+ gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers;
gdbarch_auto_charset_ftype *auto_charset;
gdbarch_auto_wide_charset_ftype *auto_wide_charset;
const char * solib_symbols_extension;
@@ -419,6 +421,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->relocate_instruction = NULL;
gdbarch->has_shared_address_space = default_has_shared_address_space;
gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
+ gdbarch->guess_tracepoint_registers = default_guess_tracepoint_registers;
gdbarch->auto_charset = default_auto_charset;
gdbarch->auto_wide_charset = default_auto_wide_charset;
gdbarch->gen_return_address = default_gen_return_address;
@@ -658,6 +661,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of has_global_breakpoints, invalid_p == 0 */
/* Skip verify of has_shared_address_space, invalid_p == 0 */
/* Skip verify of fast_tracepoint_valid_at, invalid_p == 0 */
+ /* Skip verify of guess_tracepoint_registers, invalid_p == 0 */
/* Skip verify of auto_charset, invalid_p == 0 */
/* Skip verify of auto_wide_charset, invalid_p == 0 */
/* Skip verify of has_dos_based_file_system, invalid_p == 0 */
@@ -1024,6 +1028,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: gnu_triplet_regexp = <%s>\n",
host_address_to_string (gdbarch->gnu_triplet_regexp));
fprintf_unfiltered (file,
+ "gdbarch_dump: guess_tracepoint_registers = <%s>\n",
+ host_address_to_string (gdbarch->guess_tracepoint_registers));
+ fprintf_unfiltered (file,
"gdbarch_dump: half_bit = %s\n",
plongest (gdbarch->half_bit));
fprintf_unfiltered (file,
@@ -4450,6 +4457,23 @@ set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
gdbarch->fast_tracepoint_valid_at = fast_tracepoint_valid_at;
}
+void
+gdbarch_guess_tracepoint_registers (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->guess_tracepoint_registers != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_guess_tracepoint_registers called\n");
+ gdbarch->guess_tracepoint_registers (gdbarch, regcache, addr);
+}
+
+void
+set_gdbarch_guess_tracepoint_registers (struct gdbarch *gdbarch,
+ gdbarch_guess_tracepoint_registers_ftype guess_tracepoint_registers)
+{
+ gdbarch->guess_tracepoint_registers = guess_tracepoint_registers;
+}
+
const char *
gdbarch_auto_charset (struct gdbarch *gdbarch)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 3fadcd1..be0e7e3 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -64,6 +64,7 @@ struct elf_internal_linux_prpsinfo;
struct mem_range;
struct syscalls_info;
struct thread_info;
+struct tracepoint;
#include "regcache.h"
@@ -1327,6 +1328,15 @@ typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, C
extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg);
extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
+/* Guess register state based on tracepoint location. Used for tracepoints
+ where no registers have been collected, but there's only one location,
+ allowing us to guess the PC value, and perhaps some other registers.
+ On entry, regcache has all registers marked as unavailable. */
+
+typedef void (gdbarch_guess_tracepoint_registers_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr);
+extern void gdbarch_guess_tracepoint_registers (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr);
+extern void set_gdbarch_guess_tracepoint_registers (struct gdbarch *gdbarch, gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers);
+
/* Return the "auto" target charset. */
typedef const char * (gdbarch_auto_charset_ftype) (void);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 4ac6b90..f3d8aa5 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -1028,6 +1028,12 @@ m:int:has_shared_address_space:void:::default_has_shared_address_space::0
# True if a fast tracepoint can be set at an address.
m:int:fast_tracepoint_valid_at:CORE_ADDR addr, char **msg:addr, msg::default_fast_tracepoint_valid_at::0
+# Guess register state based on tracepoint location. Used for tracepoints
+# where no registers have been collected, but there's only one location,
+# allowing us to guess the PC value, and perhaps some other registers.
+# On entry, regcache has all registers marked as unavailable.
+m:void:guess_tracepoint_registers:struct regcache *regcache, CORE_ADDR addr:regcache, addr::default_guess_tracepoint_registers::0
+
# Return the "auto" target charset.
f:const char *:auto_charset:void::default_auto_charset:default_auto_charset::0
# Return the "auto" target wide charset.
@@ -1251,6 +1257,7 @@ struct elf_internal_linux_prpsinfo;
struct mem_range;
struct syscalls_info;
struct thread_info;
+struct tracepoint;
#include "regcache.h"
@@ -1599,6 +1606,7 @@ cat <<EOF
#include "observer.h"
#include "regcache.h"
#include "objfiles.h"
+#include "tracepoint.h"
/* Static function declarations */
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
index de42165..609b7e5 100644
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -388,7 +388,8 @@ void
tracefile_fetch_registers (struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int regn, pc_regno;
+ struct tracepoint *tp = get_tracepoint (get_tracepoint_number ());
+ int regn;
/* We get here if no register data has been found. Mark registers
as unavailable. */
@@ -397,48 +398,29 @@ tracefile_fetch_registers (struct regcache *regcache, int regno)
/* We can often usefully guess that the PC is going to be the same
as the address of the tracepoint. */
- pc_regno = gdbarch_pc_regnum (gdbarch);
-
- /* XXX This guessing code below only works if the PC register isn't
- a pseudo-register. The value of a pseudo-register isn't stored
- in the (non-readonly) regcache -- instead it's recomputed
- (probably from some other cached raw register) whenever the
- register is read. This guesswork should probably move to some
- higher layer. */
- if (pc_regno < 0 || pc_regno >= gdbarch_num_regs (gdbarch))
+ if (tp == NULL || tp->base.loc == NULL)
return;
- if (regno == -1 || regno == pc_regno)
+ /* But don't try to guess if tracepoint is multi-location... */
+ if (tp->base.loc->next)
{
- struct tracepoint *tp = get_tracepoint (get_tracepoint_number ());
- gdb_byte *regs;
-
- if (tp && tp->base.loc)
- {
- /* But don't try to guess if tracepoint is multi-location... */
- if (tp->base.loc->next)
- {
- warning (_("Tracepoint %d has multiple "
- "locations, cannot infer $pc"),
- tp->base.number);
- return;
- }
- /* ... or does while-stepping. */
- if (tp->step_count > 0)
- {
- warning (_("Tracepoint %d does while-stepping, "
- "cannot infer $pc"),
- tp->base.number);
- return;
- }
-
- regs = (gdb_byte *) alloca (register_size (gdbarch, pc_regno));
- store_unsigned_integer (regs, register_size (gdbarch, pc_regno),
- gdbarch_byte_order (gdbarch),
- tp->base.loc->address);
- regcache_raw_supply (regcache, pc_regno, regs);
- }
+ warning (_("Tracepoint %d has multiple "
+ "locations, cannot infer $pc"),
+ tp->base.number);
+ return;
+ }
+ /* ... or does while-stepping. */
+ else if (tp->step_count > 0)
+ {
+ warning (_("Tracepoint %d does while-stepping, "
+ "cannot infer $pc"),
+ tp->base.number);
+ return;
}
+
+ /* Guess what we can from the tracepoint location. */
+ gdbarch_guess_tracepoint_registers (gdbarch, regcache,
+ tp->base.loc->address);
}
/* This is the implementation of target_ops method to_has_all_memory. */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 8b393db..198fc65 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -4341,6 +4341,29 @@ traceframe_available_memory (VEC(mem_range_s) **result,
return 0;
}
+void
+default_guess_tracepoint_registers (struct gdbarch *gdbarch,
+ struct regcache *regcache,
+ CORE_ADDR addr)
+{
+ int pc_regno = gdbarch_pc_regnum (gdbarch);
+ gdb_byte *regs;
+
+ /* This guessing code below only works if the PC register isn't
+ a pseudo-register. The value of a pseudo-register isn't stored
+ in the (non-readonly) regcache -- instead it's recomputed
+ (probably from some other cached raw register) whenever the
+ register is read. In this case, a custom method implementation
+ should be used by the architecture. */
+ if (pc_regno < 0 || pc_regno >= gdbarch_num_regs (gdbarch))
+ return;
+
+ regs = (gdb_byte *) alloca (register_size (gdbarch, pc_regno));
+ store_unsigned_integer (regs, register_size (gdbarch, pc_regno),
+ gdbarch_byte_order (gdbarch), addr);
+ regcache_raw_supply (regcache, pc_regno, regs);
+}
+
/* Implementation of `sdata' variable. */
static const struct internalvar_funcs sdata_funcs =
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 8985394..2cff32a 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -353,4 +353,8 @@ extern struct traceframe_info *get_traceframe_info (void);
extern struct bp_location *get_traceframe_location (int *stepping_frame_p);
+extern void default_guess_tracepoint_registers (struct gdbarch *gdbarch,
+ struct regcache *regcache,
+ CORE_ADDR addr);
+
#endif /* TRACEPOINT_H */
--
2.7.0
next prev parent reply other threads:[~2016-02-18 10:35 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-24 12:12 [PATCH 0/8] gdb/s390: Add regular and fast tracepoint support Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 7/8] gdb.trace: Bump tspeed.exp timeout to 600 seconds Marcin Kościelnicki
2016-01-26 18:17 ` Andreas Arnez
2016-01-29 9:53 ` [PATCH] " Marcin Kościelnicki
2016-02-12 11:20 ` Yao Qi
2016-02-18 18:54 ` Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 8/8] gdbserver/s390: Add support for compiled agent expressions Marcin Kościelnicki
2016-03-04 10:41 ` [PATCH v2] " Marcin Kościelnicki
2016-03-14 16:19 ` Andreas Arnez
2016-01-24 12:12 ` [PATCH 2/8] gdb/s390: Fill write_guessed_tracepoint_pc hook Marcin Kościelnicki
2016-01-26 18:12 ` Andreas Arnez
2016-01-26 19:26 ` Marcin Kościelnicki
2016-01-29 18:57 ` Andreas Arnez
2016-02-07 14:00 ` [PATCH 2/8] gdb/s390: Fill supply_pseudo_pc hook Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 3/8] gdb/s390: Fill pseudo register agent expression hooks Marcin Kościelnicki
2016-02-07 14:01 ` Marcin Kościelnicki
2016-02-25 19:23 ` Marcin Kościelnicki
2016-03-04 10:42 ` Marcin Kościelnicki
2016-03-11 2:20 ` Marcin Kościelnicki
2016-03-11 9:58 ` Andreas Arnez
2016-03-11 10:04 ` Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 1/8] gdb: Add write_guessed_tracepoint_pc hook to gdbarch Marcin Kościelnicki
2016-01-26 14:58 ` Andreas Arnez
2016-02-07 13:59 ` [PATCH 1/8] gdb: Add supply_pseudo_pc " Marcin Kościelnicki
2016-02-16 18:28 ` Ulrich Weigand
2016-02-16 21:32 ` Marcin Kościelnicki
2016-02-18 10:35 ` Marcin Kościelnicki [this message]
2016-02-18 10:35 ` [PATCH 2/2] gdb/s390: Fill guess_tracepoint_registers hook Marcin Kościelnicki
2016-02-18 16:03 ` Ulrich Weigand
2016-02-18 16:36 ` [PATCH] " Marcin Kościelnicki
2016-02-18 16:48 ` Ulrich Weigand
2016-02-18 16:58 ` Marcin Kościelnicki
2016-02-18 11:38 ` [PATCH 1/2] gdb: Add guess_tracepoint_registers hook to gdbarch Luis Machado
2016-02-18 11:39 ` Marcin Kościelnicki
2016-02-18 11:45 ` [PATCH] " Marcin Kościelnicki
2016-02-18 15:40 ` Ulrich Weigand
2016-02-18 15:41 ` Marcin Kościelnicki
2016-02-18 15:58 ` Ulrich Weigand
2016-02-18 16:01 ` Marcin Kościelnicki
2016-02-18 16:06 ` Ulrich Weigand
2016-02-18 16:11 ` Marcin Kościelnicki
2016-02-18 16:13 ` Ulrich Weigand
2016-02-18 16:22 ` Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 4/8] gdb/s390: Fill gen_return_address hook Marcin Kościelnicki
2016-02-07 14:02 ` Marcin Kościelnicki
2016-02-25 19:23 ` Marcin Kościelnicki
2016-03-04 10:42 ` Marcin Kościelnicki
2016-03-11 11:20 ` Andreas Arnez
2016-03-11 11:35 ` Marcin Kościelnicki
2016-03-11 12:18 ` Andreas Arnez
2016-03-11 12:26 ` Marcin Kościelnicki
2016-03-11 15:31 ` Andreas Arnez
2016-03-11 15:44 ` Pedro Alves
2016-03-11 16:45 ` Andreas Arnez
2016-03-11 17:02 ` Pedro Alves
2016-03-11 18:17 ` Eli Zaretskii
2016-03-11 18:37 ` Pedro Alves
2016-03-11 19:34 ` Eli Zaretskii
2016-03-15 11:11 ` Pedro Alves
2016-03-15 11:23 ` Andreas Arnez
2016-03-15 11:30 ` Pedro Alves
2016-03-11 18:07 ` Eli Zaretskii
2016-03-13 9:53 ` Marcin Kościelnicki
2016-03-14 10:07 ` Andreas Arnez
2016-01-24 12:12 ` [PATCH 5/8] gdbserver/s390: Switch on tracepoint support Marcin Kościelnicki
2016-02-07 14:04 ` Marcin Kościelnicki
2016-02-22 7:38 ` [PATCH] " Marcin Kościelnicki
2016-03-04 10:39 ` [PATCH v3] " Marcin Kościelnicki
2016-03-15 18:41 ` [PATCH v4] " Marcin Kościelnicki
2016-03-22 9:16 ` Marcin Kościelnicki
2016-03-23 15:25 ` Andreas Arnez
2016-03-24 1:15 ` Marcin Kościelnicki
2016-03-29 18:31 ` Ulrich Weigand
2016-03-29 21:40 ` Marcin Kościelnicki
2016-03-29 21:40 ` [PATCH obv] gdb/NEWS: Add mention of s390*-linux tracepoints Marcin Kościelnicki
2016-03-30 2:49 ` Eli Zaretskii
2016-01-24 12:13 ` [PATCH 6/8] gdbserver/s390: Add fast tracepoint support Marcin Kościelnicki
2016-01-25 14:34 ` Antoine Tremblay
2016-02-19 13:41 ` Marcin Kościelnicki
2016-02-19 14:41 ` Antoine Tremblay
2016-03-04 10:40 ` [PATCH v2] " Marcin Kościelnicki
2016-03-14 16:19 ` Andreas Arnez
2016-03-14 16:25 ` Marcin Kościelnicki
2016-01-25 13:27 ` [PATCH 0/8] gdb/s390: Add regular and " Antoine Tremblay
2016-01-25 13:56 ` Pedro Alves
2016-01-25 14:28 ` Marcin Kościelnicki
2016-01-25 15:57 ` Pedro Alves
2016-01-25 16:03 ` Marcin Kościelnicki
2016-02-12 11:04 ` Marcin Kościelnicki
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=1455791730-28225-1-git-send-email-koriakin@0x04.net \
--to=koriakin@0x04.net \
--cc=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.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