* [PATCH v2] Update btrace data in maintenance btrace commands
@ 2021-08-16 8:21 Stephen Röttger
2021-08-27 17:14 ` Tom Tromey
2021-09-15 10:38 ` Metzger, Markus T
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Röttger @ 2021-08-16 8:21 UTC (permalink / raw)
To: gdb-patches; +Cc: markus.t.metzger, Stephen Roettger
From: Stephen Roettger <sroettger@google.com>
When calling `maintenance btrace packet-history` or `maintenance info btrace`,
the commands wouldn't show any data unless it was updated previously by some
other means, for example by running `info record`.
To fix this, use the require_btrace function from record-brace.h which
will update the data before returning the btrace_thread_info pointer.
Change to v1: moved the require_btrace comment to record-btrace.h
---
gdb/btrace.c | 13 ++-----------
gdb/record-btrace.c | 8 ++------
gdb/record-btrace.h | 7 +++++++
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index c697f37f46c..177e818f0cf 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -3231,12 +3231,8 @@ maint_btrace_packet_history_cmd (const char *arg, int from_tty)
struct btrace_thread_info *btinfo;
unsigned int size, begin, end, from, to;
- thread_info *tp = find_thread_ptid (current_inferior (), inferior_ptid);
- if (tp == NULL)
- error (_("No thread."));
-
+ btinfo = require_btrace ();
size = 10;
- btinfo = &tp->btrace;
btrace_maint_update_packets (btinfo, &begin, &end, &from, &to);
if (begin == end)
@@ -3372,12 +3368,7 @@ maint_info_btrace_cmd (const char *args, int from_tty)
if (args != NULL && *args != 0)
error (_("Invalid argument."));
- if (inferior_ptid == null_ptid)
- error (_("No thread."));
-
- thread_info *tp = inferior_thread ();
-
- btinfo = &tp->btrace;
+ btinfo = require_btrace ();
conf = btrace_conf (btinfo);
if (conf == NULL)
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index b7b3c91f85d..8945eb73277 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -263,13 +263,9 @@ require_btrace_thread (void)
return tp;
}
-/* Update the branch trace for the current thread and return a pointer to its
- branch trace information struct.
-
- Throws an error if there is no thread or no trace. This function never
- returns NULL. */
+/* See record-btrace.h. */
-static struct btrace_thread_info *
+struct btrace_thread_info *
require_btrace (void)
{
struct thread_info *tp;
diff --git a/gdb/record-btrace.h b/gdb/record-btrace.h
index 8e7bbd90e60..b56e720e5a5 100644
--- a/gdb/record-btrace.h
+++ b/gdb/record-btrace.h
@@ -29,4 +29,11 @@ extern void record_btrace_push_target (void);
NULL if the cpu was configured as auto. */
extern const struct btrace_cpu *record_btrace_get_cpu (void);
+/* Update the branch trace for the current thread and return a pointer to its
+ branch trace information struct.
+
+ Throws an error if there is no thread or no trace. This function never
+ returns NULL. */
+extern struct btrace_thread_info * require_btrace (void);
+
#endif /* RECORD_BTRACE_H */
--
2.33.0.rc1.237.g0d66db33f3-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] Update btrace data in maintenance btrace commands
2021-08-16 8:21 [PATCH v2] Update btrace data in maintenance btrace commands Stephen Röttger
@ 2021-08-27 17:14 ` Tom Tromey
2021-09-15 10:38 ` Metzger, Markus T
1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2021-08-27 17:14 UTC (permalink / raw)
To: Stephen Röttger via Gdb-patches; +Cc: Stephen Röttger
>>>>> ">" == Stephen Röttger via Gdb-patches <gdb-patches@sourceware.org> writes:
>> From: Stephen Roettger <sroettger@google.com>
>> When calling `maintenance btrace packet-history` or `maintenance info btrace`,
>> the commands wouldn't show any data unless it was updated previously by some
>> other means, for example by running `info record`.
>> To fix this, use the require_btrace function from record-brace.h which
>> will update the data before returning the btrace_thread_info pointer.
Hi. Thanks for the patch.
I have a couple of nits, but nothing serious.
You can check it in with these changed.
>> +extern struct btrace_thread_info * require_btrace (void);
No space after the "*" in GNU style.
Also the "void" can be removed, that's a leftover C-ism.
thanks,
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] Update btrace data in maintenance btrace commands
2021-08-16 8:21 [PATCH v2] Update btrace data in maintenance btrace commands Stephen Röttger
2021-08-27 17:14 ` Tom Tromey
@ 2021-09-15 10:38 ` Metzger, Markus T
1 sibling, 0 replies; 3+ messages in thread
From: Metzger, Markus T @ 2021-09-15 10:38 UTC (permalink / raw)
To: Stephen Röttger; +Cc: gdb-patches
>When calling `maintenance btrace packet-history` or `maintenance info btrace`,
>the commands wouldn't show any data unless it was updated previously by some
>other means, for example by running `info record`.
>To fix this, use the require_btrace function from record-brace.h which
>will update the data before returning the btrace_thread_info pointer.
>
>Change to v1: moved the require_btrace comment to record-btrace.h
>---
> gdb/btrace.c | 13 ++-----------
> gdb/record-btrace.c | 8 ++------
> gdb/record-btrace.h | 7 +++++++
> 3 files changed, 11 insertions(+), 17 deletions(-)
LGTM with Tom's style comments addressed.
Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-15 10:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 8:21 [PATCH v2] Update btrace data in maintenance btrace commands Stephen Röttger
2021-08-27 17:14 ` Tom Tromey
2021-09-15 10:38 ` Metzger, Markus T
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).