[Lldb-commits] [PATCH] D151497: [lldb] Improve function caller error message

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 25 15:12:59 PDT 2023


mib added a subscriber: kastiglione.
mib added a comment.

In D151497#4374080 <https://reviews.llvm.org/D151497#4374080>, @bulbazord wrote:

> I think it's good to improve the error messaging but I think we can probably do better. "Function caller" is specific to the internals of LLDB and isn't really meaningful for many users. It's also somewhat confusing from a user's perspective when the expression you're running isn't calling a function. For example:
>
>   alex at alangford build % ./bin/lldb ~/tmp/foo
>   (lldb) target create "/Users/alex/tmp/foo"
>   Current executable set to '/Users/alex/tmp/foo' (arm64).
>   (lldb) b main
>   Breakpoint 1: where = foo`main + 28 at foo.c:6:7, address = 0x0000000100003f68
>   (lldb) r
>   Process 44467 launched: '/Users/alex/tmp/foo' (arm64)
>   Process 44467 stopped
>   * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
>       frame #0: 0x0000000100003f68 foo`main at foo.c:6:7
>      1    #include <stdio.h>
>      2
>      3    int g_foo = 5;
>      4
>      5    int main() {
>   -> 6      int val = 7;
>      7      printf("Hello World!: %d\n", val);
>      8      return 0;
>      9    }
>   (lldb) c
>   Process 44467 resuming
>   Hello World!: 7
>   Process 44467 exited with status = 0 (0x00000000)
>   (lldb) p val
>   error: Can't make a function caller while the process is running
>
> If I were an end user who didn't know much about LLDB, I would think "I'm trying to print a variable, what's this about a function?" and "Why is memory allocation involved?". I would suggest changing the error message to something like: "Unable to evaluate expression while the process is $STATE: the process must be running and stopped to evaluate this expression".
>
> What do you think?

I do agree on rephrasing the error message to be more user-friendly. I'd also assume that if the process has exited, may be `dwim-print` would do `target variable` instead of evaluating an expression, am I right @kastiglione ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151497/new/

https://reviews.llvm.org/D151497



More information about the lldb-commits mailing list