Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] [windows] operator bool() const on struct not being resolved in breakpoint condition #132179

Open
k4lizen opened this issue Mar 20, 2025 · 3 comments

Comments

@k4lizen
Copy link

k4lizen commented Mar 20, 2025

Using lldb and clang on 01f0425 using windows.

#include <iostream>

struct Boolish {
    operator bool() const { return false; }
};
int main() {
    Boolish bol;
    if (!(bool)bol) {
        puts("operator resolved correctly!");
    }
    puts("break");
    puts("done");
    return 0;
}

Compiling with latest clang++ main.cpp -g3 -o main.exe.
Running ./main.exe gives the expected:

operator resolved correctly!
break
done

But trying the condition in lldb gives:

[snip]
(lldb) breakpoint set -f main.cpp -l 11 --condition "!(bool)bol"
(lldb) run
Process 5476 stopped
* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff7e3e57186 main.exe`main at main.cpp:52
   49       if (!(bool)bol) {
   50           puts("operator resolved correctly!");
   51       }
-> 52       puts("break");
   53       puts("done");
   54       return 0;
   55   }
error: stopped due to an error evaluating condition of breakpoint 1.1: "!(bool)bol"
Couldn't parse conditional expression:
error: Couldn't look up symbols:
  bool Boolish::operator bool(void)
Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.

(lldb)

If we remove the const, everything works as expected.

@llvmbot
Copy link
Member

llvmbot commented Mar 20, 2025

@llvm/issue-subscribers-lldb

Author: None (k4lizen)

Using lldb and clang on 01f0425 . Using windows (haven't tried it on linux but I'd assume it reproduces). ```cpp #include <iostream>

struct Boolish {
operator bool() const { return false; }
};
int main() {
Boolish bol;
if (!(bool)bol) {
puts("operator resolved correctly!");
}
puts("break");
puts("done");
return 0;
}

Compiling with latest `clang++ main.cpp -g3 -o main.exe`.
Running `./main.exe` gives the expected:

operator resolved correctly!
break
done

But trying the condition in lldb gives:

[snip]
(lldb) breakpoint set -f main.cpp -l 11 --condition "!(bool)bol"
(lldb) run
Process 5476 stopped

  • thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff7e3e57186 main.exe`main at main.cpp:52
    49 if (!(bool)bol) {
    50 puts("operator resolved correctly!");
    51 }
    -> 52 puts("break");
    53 puts("done");
    54 return 0;
    55 }
    error: stopped due to an error evaluating condition of breakpoint 1.1: "!(bool)bol"
    Couldn't parse conditional expression:
    error: Couldn't look up symbols:
    bool Boolish::operator bool(void)
    Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.

(lldb)

If we remove the `const`, everything works as expected.
</details>

@Michael137
Copy link
Member

Doesn't repro on macOS for me. Perhaps a pdb plugin issue?

@k4lizen
Copy link
Author

k4lizen commented Mar 20, 2025

@Michael137 oh damn, yeah just tested it on linux and it doesn't reproduce, pdb-related issue would make sense

@k4lizen k4lizen changed the title [lldb] operator bool() const on struct not being resolved in breakpoint condition [lldb] [windows] operator bool() const on struct not being resolved in breakpoint condition Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants