This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Warn the user about starting the --func-regex parameter with an asterisk
ClosedPublic

Authored by teemperor on Apr 24 2020, 7:36 AM.

Details

Summary

Sometimes users think that setting a function regex for all function that contain the word 'needle' in their
name looks like this: *needle*. However, LLDB only searches the function name and doesn't fully match
it against the regex, so the leading and trailing '*' operators don't do anything and actually just cause the
regex engine to reject the regular expression with "repetition-operator operand invalid".

This patch makes this a bit more obvious to the user by printing a warning that a leading '*' before this
regular expression here doesn't have any purpose (and will cause an error). This doesn't attempt to detect
a case where there is only a trailing '*' as that would involve parsing the regex and it seems the most
common way to end up in this situation is by doing rbreak *needle*.

Diff Detail

Event Timeline

JDevlieghere requested changes to this revision.Apr 24 2020, 10:31 AM

I think you're conflating two problems here:

  1. If you pass breakpoint set --func-regex foo it basically matches .*foo.*. So using a wildcards before or after the function name is redundant.
  2. The regex command takes a regular expression and not a shell glob. Passing .*foo.* instead of *foo* works fine, though it's redundant per (1).

TL;DR I don't think this warning is warranted nor correct.

If we do want to print a warning, we should print something along the lines of "the regex command takes a regular expression and not a shell glob" for a leading *. In addition, as well as for a leading .* we should print another warning saying that lldb, for your convenience, will automatically add wildcards before and after the input as to match everything that contains <input> and so that these wildcards are redundant. For completeness we should do the same for ?.

This revision now requires changes to proceed.Apr 24 2020, 10:31 AM
teemperor updated this revision to Diff 260852.Apr 29 2020, 4:41 AM
  • Now warning for * and ?.
  • Clarified warning a bit.

Yeah, maybe D78808 is already good enough. I'll close this for now unless we hear again that the related error message is confusing

JDevlieghere accepted this revision.Apr 29 2020, 9:58 AM
This revision is now accepted and ready to land.Apr 29 2020, 9:58 AM

@JDevlieghere I actually wanted to abandon this but somehow that didn't go through. You think we should land this or should we wait until we actually get someone that is confused by the new error message?

I think this would improve the user experience so I'm fine with landing this.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2020, 3:44 AM