From: "Stephen Röttger" <sroettger@google.com>
To: gdb-patches@sourceware.org
Subject: Re: [PING] [PATCH] Update btrace data in maintenance btrace commands
Date: Tue, 25 May 2021 15:06:53 +0200 [thread overview]
Message-ID: <CAEAAPHb9Bh8-jyFu0jbLsh2GEsuxmTW0myqCJu8-gxbvKoP_Aw@mail.gmail.com> (raw)
In-Reply-To: <20210412140128.296921-1-sroettger@google.com>
[-- Attachment #1: Type: text/plain, Size: 3720 bytes --]
On Mon, Apr 12, 2021 at 4:01 PM Stephen Röttger <sroettger@google.com>
wrote:
> 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.
>
> Here's an example of the issue:
> ```
> $ gdb -nx /usr/bin/ls
> (gdb) break malloc
> Breakpoint 1 at 0x46c8
> (gdb) run
> Starting program: /usr/bin/ls
>
> Breakpoint 1, 0x00007ffff7fec240 in malloc () from
> /lib64/ld-linux-x86-64.so.2
> (gdb) record btrace bts
> (gdb) c
> Continuing.
>
> Breakpoint 1, 0x00007ffff7fec240 in malloc () from
> /lib64/ld-linux-x86-64.so.2
> (gdb) maintenance btrace packet-history
> No trace.
> (gdb) maintenance info btrace
> Format: Branch Trace Store.
> Aborted
> ```
>
> gdb/ChangeLog:
>
> * btrace.c (maint_btrace_packet_history_cmd): use require_btrace
> (maint_info_btrace_cmd): use require_btrace
> * record-btrace.c (struct btrace_thread_info): mark non-static
> * record-btrace.h (require_btrace): export function
>
> ---
> gdb/btrace.c | 13 ++-----------
> gdb/record-btrace.c | 2 +-
> gdb/record-btrace.h | 7 +++++++
> 3 files changed, 10 insertions(+), 12 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..79a6e47a4a6 100644
> --- a/gdb/record-btrace.c
> +++ b/gdb/record-btrace.c
> @@ -269,7 +269,7 @@ require_btrace_thread (void)
> Throws an error if there is no thread or no trace. This function never
> returns NULL. */
>
> -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.31.1.295.g9ea45b61b8-goog
>
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4002 bytes --]
next prev parent reply other threads:[~2021-05-25 13:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 14:01 Stephen Röttger
2021-05-25 13:06 ` Stephen Röttger [this message]
2021-05-29 2:13 ` Simon Marchi
2021-06-08 14:05 ` Metzger, Markus T
2021-06-09 9:41 ` Stephen Röttger
2021-08-03 8:49 ` Stephen Röttger
2021-08-03 10:05 ` Metzger, Markus T
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=CAEAAPHb9Bh8-jyFu0jbLsh2GEsuxmTW0myqCJu8-gxbvKoP_Aw@mail.gmail.com \
--to=sroettger@google.com \
--cc=gdb-patches@sourceware.org \
/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).