Re: [RFC] Make solib_add regex-free

Jan Kratochvil
2011-08-09T20:41:16Z

On Tue, 09 Aug 2011 20:09:54 +0200, Sergio Durigan Junior wrote:
> Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> >> /* Walk the list of currently loaded shared libraries, and read
> >> symbols for any that match the pattern --- or any whose symbols
> >> aren't already loaded, if no pattern was given. */
> >> {
> >> - int any_matches = 0;
> >
> > Removal of this variable/functionality is a regression, discussed below.
>
> I'm not sure I understood why, after reading the entire message. Is it
> because of the `(null)' string being printed in the error message?

Yes, it is related to the error message with `(null)' (although it is not
related to the `(null)' problem itself), I think one can skip this variable,
the problem was described enough with the error message.

> Ok, I was just studying how `update_solib_list' does, and decided to do
> the same. I will update it then.

Yes but this is really a different case.

> >> - if (from_tty && pattern && ! any_matches)
> >> - printf_unfiltered
> >> - ("No loaded shared libraries match the pattern `%s'.\n", pattern);
> >
> > This useful error message is no longer ever produced, maybe solib_add_1 could
> > have some return value.
>
> I decided to drop this error message because, the way it's written, it
> only makes sense when using regex.

That may be true but still the final GDB as whole should print it IMO.

> Also, I couldn't come up with a decent replacement for it. Now
> `solib_add' uses a so_list in order to decided what to load. So IMO the
> error message should contain which shared libraries are present in the
> so_list. I don't know if I'm overcomplicating things here...

I guess I suggest it in the last paragraph.

> >> @@ -1285,8 +1371,19 @@ in_solib_dynsym_resolve_code (CORE_ADDR pc)
> >> static void
> >> sharedlibrary_command (char *args, int from_tty)
> >> {
> >> + struct cleanup *c;
> >> + VEC(so_list_p) *solist;
> >> +
> >> dont_repeat ();
> >> - solib_add (args, from_tty, (struct target_ops *) 0, 1);
> >> +
> >> + solist = solib_match_regex_solist (args, (struct target_ops *) 0,
> >> + from_tty);
> >> + if (!solist)
> >> + error (_("No shared library matched the pattern `%s'."), args);
> >
> > If you do with FSF GDB `nosharedlibrary' symbols for libraries are unloaded,
> > then `sharedlibrary' loads symbols for all the libraries. Your patches GDB
> > writes an error message.
> >
> > Also `args' can be NULL which prints:
> > No shared library matched the pattern `(null)'.
> > But NULL %s is not portable.
>
> Ok, I'll fix that.

Just changing it to:

if (from_tty && args && !solist)
error (_("No shared library matched the pattern `%s'."), args);

should do the right - no behavior change (I hope).

Thanks,
Jan