From: Pedro Alves <palves@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 5/7 take 3] Improved linker-debugger interface
Date: Thu, 30 May 2013 17:18:00 -0000 [thread overview]
Message-ID: <51A789CF.2000302@redhat.com> (raw)
In-Reply-To: <20130530104346.GA6217@blade.nx>
On 05/30/2013 11:43 AM, Gary Benson wrote:
> Pedro Alves wrote:
>> On 05/24/2013 09:30 AM, Gary Benson wrote:
>>> +static int
>>> +svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg)
>>> +{
>>> + struct svr4_info *info = get_svr4_info ();
>>> + struct bp_location *loc;
>>> +
>> ...
>>
>>> + for (loc = b->loc; loc; loc = loc->next)
>>> + {
>>> + struct probe_and_action *pa = solib_event_probe_at (info, loc->address);
>>
>> There's no relation between INFO and the locations' inferior/program
>> space. IOW, I believe this is doing the wrong thing for multi-process.
>
> It took me a while to figure out what you meant here, but I think I
> see what you mean.
Sorry. :-/
For those following along at home, the issue is that
get_svr4_info () returns the svr4 state object corresponding
to the current program space, while here we're walking over
all locations of all breakpoints, including
breakpoints/locations of all inferiors. So in
the 'solib_event_probe_at (info, loc->address)' call, we need
to pass it the 'info' of the program space of 'loc'.
> I've attached an updated patch with this function
> reworked. Could you let me know if it looks correct?
...
+/* Helper function for svr4_update_solib_event_breakpoints. */
+
+static int
+svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg)
+{
+ struct bp_location *loc;
+
+ if (b->type != bp_shlib_event)
+ {
+ /* Continue iterating. */
+ return 0;
+ }
+
+ for (loc = b->loc; loc != NULL; loc = loc->next)
+ {
+ struct svr4_info *info;
+ struct probe_and_action *pa;
+
+ info = program_space_data (loc->pspace, solib_svr4_pspace_data);
+ if (info == NULL || info->probes_table == NULL)
+ continue;
Exactly. Excellent, looks great now.
On 05/30/2013 11:43 AM, Gary Benson wrote:> + {
> + char name[32] = { '\0' };
> +
> + /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4
> + shipped with an early version of the probes code in
> + which the probes' names were prefixed with "rtld_"
> + and the "map_failed" probe did not exist. The
> + locations of the probes are otherwise the same, so
> + we check for probes with prefixed names if probes
> + with unprefixed names are not present. */
> +
> + if (with_prefix)
> + strncat (name, "rtld_", sizeof (name) - strlen (name) - 1);
> +
> + strncat (name, probe_info[i].name,
> + sizeof (name) - strlen (name) - 1);
> +
BTW, I'd rather this was written as something like:
char name[32];
if (with_prefix)
xsnprintf (name, sizeof (name), "rtld_%s", probe_info[i].name);
else
xsnprintf (name, sizeof (name), "%s", probe_info[i].name);
strncat like that is really not future proof, as we'll just get get a silently
truncated string if a new probe appears with a name that is too big.
xsnprintf OTOH gdb_asserts the string fits in the buffer. Granted, whoever
added such a probe would probably notice this, but it's a style best avoided.
(Witness how so few strncat calls there are in gdb. There are more strcat calls,
but that only shows that whenever we _do_ care about string overruns, we tend
to use something else, not strncat.)
Plus, it looks more readable to me that way. :-)
Alternatively, we could add a xstrncat that asserts truncation never happens,
though xsnprintf in this case still looks a bit more readable to me :-)
--
Pedro Alves
next prev parent reply other threads:[~2013-05-30 17:18 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 14:43 [RFA 0/7] " Gary Benson
2013-05-16 14:47 ` [RFA 1/7] Probes API convenience patch Gary Benson
2013-05-16 14:48 ` [RFA 3/7] New gdbserver functionality Gary Benson
2013-05-16 18:18 ` Tom Tromey
2013-05-24 7:46 ` [RFA 3/7 take 2] " Gary Benson
2013-05-25 21:05 ` Jan Kratochvil
2013-05-26 2:45 ` Eli Zaretskii
2013-05-29 18:50 ` Pedro Alves
2013-05-30 9:38 ` Gary Benson
2013-05-30 10:40 ` Pedro Alves
2013-05-30 10:54 ` Gary Benson
2013-05-30 16:31 ` Eli Zaretskii
2013-05-30 17:22 ` Gary Benson
2013-05-16 14:48 ` [RFA 2/7] API for inhibiting section map updates Gary Benson
2013-05-20 14:22 ` Tom Tromey
2013-05-24 7:47 ` [RFA 2/7 take 2] " Gary Benson
2013-05-24 14:18 ` Tom Tromey
2013-05-29 17:18 ` Pedro Alves
2013-05-30 9:12 ` Gary Benson
2013-05-16 14:48 ` [RFA 4/7] GDB support for new gdbserver functionality Gary Benson
2013-05-16 14:55 ` [RFA 6/7] Linker-debugger interface tests by Jan Gary Benson
2013-05-29 19:06 ` Pedro Alves
2013-05-30 9:19 ` Gary Benson
2013-05-16 14:55 ` [RFA 5/7] Improved linker-debugger interface Gary Benson
2013-05-17 19:05 ` Jan Kratochvil
2013-05-24 8:30 ` [RFA 5/7 take 2] " Gary Benson
2013-05-25 21:05 ` Jan Kratochvil
2013-05-29 18:51 ` Pedro Alves
2013-05-30 10:43 ` [RFA 5/7 take 3] " Gary Benson
2013-05-30 17:18 ` Pedro Alves [this message]
2013-05-31 13:22 ` [RFA 5/7 take 4] " Gary Benson
2013-05-31 13:27 ` Pedro Alves
2013-06-03 10:31 ` Pedro Alves
2013-06-03 16:37 ` Jan Kratochvil
2013-06-03 17:28 ` Pedro Alves
2013-06-04 11:33 ` Gary Benson
2013-05-16 14:55 ` [RFA 7/7] Linker-debugger interface tests Gary Benson
2013-05-19 13:45 ` Jan Kratochvil
2013-05-19 16:43 ` Jan Kratochvil
2013-05-24 8:38 ` [RFA 7/7 take 2] " Gary Benson
2013-05-24 8:58 ` Jan Kratochvil
2013-05-24 14:05 ` [obv] Fix excessive backslashes in testsuite Gary Benson
2013-05-25 21:06 ` [RFA 7/7 take 2] Linker-debugger interface tests Jan Kratochvil
2013-05-16 17:33 ` [RFA 0/7] Improved linker-debugger interface Tom Tromey
2013-05-16 18:53 ` Gary Benson
2013-06-06 9:00 ` Gary Benson
2013-05-19 13:46 ` Jan Kratochvil
2013-05-29 19:08 ` Pedro Alves
2013-06-04 13:38 ` [commit] " Gary Benson
2013-06-25 21:04 ` Joel Brobecker
2013-06-25 22:03 ` Sergio Durigan Junior
2013-06-26 0:49 ` Joel Brobecker
2013-07-09 8:41 ` Gary Benson
[not found] ` <20130708104719.GA11176@blade.nx>
2013-07-09 14:45 ` Joel Brobecker
2013-06-26 15:38 ` Tom Tromey
2013-06-26 17:23 ` Sergio Durigan Junior
2013-06-26 19:15 ` Joel Brobecker
2013-06-27 23:33 ` Tom Tromey
2013-06-30 3:12 ` Sergio Durigan Junior
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=51A789CF.2000302@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.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