From: Simon Marchi <simark@simark.ca>
To: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>,
gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] gdb/jit: enable tracking multiple jitter objfiles
Date: Sun, 14 Jun 2020 13:09:07 -0400 [thread overview]
Message-ID: <298ca402-f06a-4901-84c3-c8ca58a00cee@simark.ca> (raw)
In-Reply-To: <886ee7b960b7da9ee20ae3c4b889d2b9c3246b33.1590397723.git.tankut.baris.aktemur@intel.com>
On 2020-05-25 5:38 a.m., Tankut Baris Aktemur via Gdb-patches wrote:
> diff --git a/gdb/jit.c b/gdb/jit.c
> index fdb1248ed5b..c689ac3f392 100644
> --- a/gdb/jit.c
> +++ b/gdb/jit.c
> @@ -966,58 +966,53 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch,
The comment above jit_breakpoint_re_set_internal says:
Return 0 if the jit breakpoint has been successfully initialized.
Can you adjust it to the new reality? Something like "Return 0 if one
or more JIT breakpoints were successfully initialized".
I think it would also be good (as a separate cleanup) to make this function
return a bool, returning true when one or more JIT breakpoints were inserted.
> @@ -1357,38 +1352,38 @@ jit_event_handler (struct gdbarch *gdbarch)
>
> jit_program_space_data *ps_data = get_jit_program_space_data ();
>
> - /* Fetch the saved objfile. */
> - objfile *objf = nullptr;
> - if (!ps_data->objfile_and_bps.empty ())
> - objf = (ps_data->objfile_and_bps.begin ())->first;
> -
> - /* Read the descriptor from remote memory. */
> - if (!jit_read_descriptor (gdbarch, &descriptor, objf))
> - return;
> - entry_addr = descriptor.relevant_entry;
> -
> - /* Do the corresponding action. */
> - switch (descriptor.action_flag)
> + for (auto &objf_and_bp : ps_data->objfile_and_bps)
> {
> - case JIT_NOACTION:
> - break;
> - case JIT_REGISTER:
> - jit_read_code_entry (gdbarch, entry_addr, &code_entry);
> - jit_register_code (gdbarch, entry_addr, &code_entry);
> - break;
> - case JIT_UNREGISTER:
> - objf = jit_find_objf_with_entry_addr (entry_addr);
> - if (objf == NULL)
> - printf_unfiltered (_("Unable to find JITed code "
> - "entry at address: %s\n"),
> - paddress (gdbarch, entry_addr));
> - else
> - objf->unlink ();
> + objfile *objf = objf_and_bp.first;
>
> - break;
> - default:
> - error (_("Unknown action_flag value in JIT descriptor!"));
> - break;
> + /* Read the descriptor from remote memory. */
> + if (!jit_read_descriptor (gdbarch, &descriptor, objf))
> + continue;
> + entry_addr = descriptor.relevant_entry;
> +
> + /* Do the corresponding action. */
> + switch (descriptor.action_flag)
> + {
> + case JIT_NOACTION:
> + break;
> + case JIT_REGISTER:
> + jit_read_code_entry (gdbarch, entry_addr, &code_entry);
> + jit_register_code (gdbarch, entry_addr, &code_entry);
> + break;
> + case JIT_UNREGISTER:
> + objf = jit_find_objf_with_entry_addr (entry_addr);
> + if (objf == NULL)
> + printf_unfiltered (_("Unable to find JITed code "
> + "entry at address: %s\n"),
> + paddress (gdbarch, entry_addr));
> + else
> + objf->unlink ();
> +
> + break;
> + default:
> + error (_("Unknown action_flag value in JIT descriptor!"));
> + break;
> + }
I don't think that iterating on all JIT-providing objfiles is the correct thing
to do here. After all, we have hit the __jit_debug_register_code breakpoint of
exactly one of them, so we should only process the jit descriptor of that one.
At the same moment, the other JIT-providing objfiles could have prepared anything
in their descriptor (or there could be junk data), but they have not asked us
to process it.
I haven't tried, but I bet that you could build a test to trigger a bug here:
1. Have two jit-providing objfiles register one jit objfile each
2. Have the two jit-providing objfiles prepare their descriptor with JIT_UNREGISTER
and the address of their jit objfile
3. Have one of them call __jit_debug_register_code.
We would forget about both jit objfiles, when in reality we should forget only about
one.
I think we'll need to know which jit event breakpoint was hit, so we can know which
jit-providing objfile asked us to process its descriptor.
Simon
next prev parent reply other threads:[~2020-06-14 17:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-25 9:38 [PATCH 0/3] Handling multiple JITers Tankut Baris Aktemur
2020-05-25 9:38 ` [PATCH 1/3] gdb/jit: use a map to store objfile and jit breakpoint info Tankut Baris Aktemur
2020-06-14 17:50 ` Simon Marchi
2020-06-16 9:47 ` Aktemur, Tankut Baris
2020-05-25 9:38 ` [PATCH 2/3] gdb/jit: enable tracking multiple jitter objfiles Tankut Baris Aktemur
2020-06-14 17:09 ` Simon Marchi [this message]
2020-06-16 9:48 ` Aktemur, Tankut Baris
2020-05-25 9:38 ` [PATCH 3/3] gdb/testsuite: fix minor things in jit tests Tankut Baris Aktemur
2020-06-14 18:09 ` Simon Marchi
2020-06-15 7:15 ` Aktemur, Tankut Baris
2020-06-12 11:12 ` [PATCH 0/3] Handling multiple JITers Aktemur, Tankut Baris
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=298ca402-f06a-4901-84c3-c8ca58a00cee@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tankut.baris.aktemur@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).