[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 2 11:43:43 PDT 2023


=?utf-8?q?José?= L. Junior <jljuniorpb at gmail.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/67019/lldb at github.com>


medismailben wrote:

> > You can use `lldb/test/Shell/Commands/command-thread-select.test` as an example to write your own test.
> 
> Using this file as a template, I wrote `command-process-launch-user-entry.test` as shown below:
> 
> ```
> # RUN: %clang_host -g %S/Inputs/main.c -o %t
> # RUN: %lldb %t -s %s -o exit | FileCheck %s
> 
> process launch -m
> # CHECK-LABEL: process launch -m
> # CHECK: Process {{.*}} stopped
> # CHECK: stop reason = one-shot breakpoint 1
> # CHECK:   frame #0: {{.*}}`main at main.c
> ```
> 
> But I wanted to add the check line `# CHECK: Process {{.*}} launched: '{{.*}}' {{.*}}`, but this fails because the following is happening:
> 
> 1. When the command is executed from the `(lldb)` prompt, it correctly shows that the process is launched then stopped.
> 
> ```
> $ ./bin/lldb ~/main.out
> (lldb) target create "/home/jose/main.out"
> Current executable set to '/home/jose/main.out' (x86_64).
> (lldb) process launch -m
> Process 63632 launched: '/home/jose/main.out' (x86_64)
> Process 63632 stopped
> * thread #1, name = 'main.out', stop reason = one-shot breakpoint 1
>     frame #0: 0x0000555555555140 main.out`main at main.c:2
>    1   	int foo() { return 0; }
> -> 2   	int main() { return foo(); }
>    3   	
> (lldb) 
> ```
> 
> 2. When I run like shown below, the `Process launched` message is shown after the stop.
> 
> ```
> $ ./bin/lldb ~/main.out -o 'process launch -m'
> (lldb) target create "/home/jose/main.out"
> Current executable set to '/home/jose/main.out' (x86_64).
> (lldb) process launch -m
> Process 63846 stopped
> * thread #1, name = 'main.out', stop reason = one-shot breakpoint 1
>     frame #0: 0x0000555555555140 main.out`main at main.c:2
>    1   	int foo() { return 0; }
> -> 2   	int main() { return foo(); }
>    3
> Process 63846 launched: '/home/jose/main.out' (x86_64)
> (lldb) 
> ```
> 
> Is this behaviour expected?

I can reproduce it:

```
$ ./bin/lldb /tmp/main -o "b main" -o "r"
(lldb) target create "/tmp/main"
Current executable set to '/tmp/main' (arm64).
(lldb) b main
Breakpoint 1: where = main`main + 12 at main.cpp:2:3, address = 0x0000000100003fa0
(lldb) r
Process 53764 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003fa0 main`main at main.cpp:2:3
   1   	int main() {
-> 2   	  return 0;
   3   	}
Process 53764 launched: '/tmp/main' (arm64)
```

By default the debugger runs in asynchronous mode so the stop events can be handled in a nondetermistic way. However, I think this confusing and we should do something about (in a separate PR). Could you file a new issue describing this behavior and pasting the link here.

Your test looks fine to me, so we can move on with it to merge your PR. I'll update it after we fix that other bug.


https://github.com/llvm/llvm-project/pull/67019


More information about the lldb-commits mailing list