From: Pedro Alves <palves@redhat.com>
To: Markus Metzger <markus.t.metzger@intel.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: Re: [PATCH v3 2/5] btrace: allow recording to be started (and stopped) for running threads
Date: Tue, 31 Jan 2017 12:59:00 -0000 [thread overview]
Message-ID: <add8123b-e7c2-7baf-0d81-74b1aefcb036@redhat.com> (raw)
In-Reply-To: <1485770743-6603-3-git-send-email-markus.t.metzger@intel.com>
On 01/30/2017 10:05 AM, Markus Metzger wrote:
> ---
> gdb/btrace.c | 46 ++++++++++++++--
> gdb/testsuite/gdb.btrace/enable-running.c | 47 ++++++++++++++++
> gdb/testsuite/gdb.btrace/enable-running.exp | 85 +++++++++++++++++++++++++++++
> 3 files changed, 174 insertions(+), 4 deletions(-)
> create mode 100644 gdb/testsuite/gdb.btrace/enable-running.c
> create mode 100644 gdb/testsuite/gdb.btrace/enable-running.exp
>
> diff --git a/gdb/btrace.c b/gdb/btrace.c
> index d266af7..fec2cce 100644
> --- a/gdb/btrace.c
> +++ b/gdb/btrace.c
> @@ -141,6 +141,18 @@ ftrace_debug (const struct btrace_function *bfun, const char *prefix)
> prefix, fun, file, level, ibegin, iend);
> }
>
> +/* Validate that we can read PTID's registers. */
> +
> +static void
> +validate_registers_access_ptid (ptid_t ptid)
> +{
> + struct cleanup *cleanup = save_inferior_ptid ();
> +
> + inferior_ptid = ptid;
> + validate_registers_access ();
> + do_cleanups (cleanup);
> +}
> +
Please let's refactor things a bit to avoid the need to frob
inferior_ptid and restore with a cleanup. Change the existing
validate_registers_access like:
static void
-validate_registers_access ()
+validate_registers_access_ptid (ptid_t ptid)
{
/* No selected thread, no registers. */
-if (ptid_equal (inferior_ptid, null_ptid))
+if (ptid_equal (ptid, null_ptid))
error (_("No thread selected."));
[etc.]
and then reimplement it back on top of validate_registers_access_ptid:
validate_registers_access ()
{
return validate_registers_access_ptid (inferior_ptid);
}
> +
> +#include <pthread.h>
> +
> +#define NTHREADS 3
> +
> +static void *
> +test (void *arg)
> +{
> + /* Let's hope this is long enough for GDB to enable tracing and check that
> + everything is working as expected. */
> + sleep (10);
Need to include <unistd.h> for sleep. I got:
..../src/gdb/testsuite/gdb.btrace/enable-running.c: In function 'test':
..../src/gdb/testsuite/gdb.btrace/enable-running.c:27:3: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration]
sleep (10);
^
Otherwise LGTM.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2017-01-31 12:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 10:05 [PATCH v3 0/5] thread, btrace: allow "record btrace" " Markus Metzger
2017-01-30 10:05 ` [PATCH v3 4/5] btrace, testsuite: fix extended-remote non-stop test Markus Metzger
2017-01-31 13:00 ` Pedro Alves
2017-01-30 10:06 ` [PATCH v3 2/5] btrace: allow recording to be started (and stopped) for running threads Markus Metzger
2017-01-31 12:59 ` Pedro Alves [this message]
2017-01-31 16:06 ` Metzger, Markus T
2017-01-31 16:36 ` Pedro Alves
2017-02-01 8:53 ` Metzger, Markus T
2017-02-01 9:08 ` Metzger, Markus T
2017-02-01 10:40 ` Pedro Alves
2017-01-30 10:06 ` [PATCH v3 3/5] btrace: add unsupported/untested messages when skipping tests Markus Metzger
2017-01-31 13:00 ` Pedro Alves
2017-01-30 10:06 ` [PATCH v3 1/5] thread: add can_access_registers_ptid Markus Metzger
2017-01-30 10:06 ` [PATCH v3 5/5] btrace, testsuite: fix extended-remote fail Markus Metzger
2017-01-31 13:00 ` Pedro Alves
2017-01-31 16:06 ` Metzger, Markus T
2017-01-31 16:42 ` 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=add8123b-e7c2-7baf-0d81-74b1aefcb036@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=simon.marchi@ericsson.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