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 fails to skip prologue with clang generated PDB #56288

Open
omjavaid opened this issue Jun 29, 2022 · 7 comments
Open

LLDB fails to skip prologue with clang generated PDB #56288

omjavaid opened this issue Jun 29, 2022 · 7 comments
Labels
clang Clang issues not falling into any other category lldb platform:windows

Comments

@omjavaid
Copy link
Contributor

omjavaid commented Jun 29, 2022

LLDB is expected to skip prologue and advance to the breakpoint location to the first source line in the function when you have debug information. For example consider following code:

#include <string.h>

int
product (int x, int y)
{
    int result = x * y;
    return result;
}

int
main(int argc, char const *argv[])
{
    int array[4];
    memset(array, 0, 4 * sizeof(int));

    array[0] = product (1238, 78392);
    array[1] = product (379265, 23674);
    array[2] = product (872934, 234);
    array[3] = product (1238, 78392);

    return 0;
}

Compile with clang-cl /Zi skip_prolog.cpp. Clang will generate PDB debug info by default.
Start LLDB and set breakpoint on main. LLDB is expected to stop at line memset which is the first executable line of the function main. However LLDB stops at first assembly instruction stopping at main brace without skipping the prologue.

This is architecture independent so it happens on both x86_64 and AArch64.
This works fine when PDB is generated by cl.exe.
Also works fine when clang compiles with dwarf debug info.

@omjavaid omjavaid added clang Clang issues not falling into any other category lldb platform:windows labels Jun 29, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 29, 2022

@llvm/issue-subscribers-lldb

@ZequanWu
Copy link
Contributor

What's your lldb version?

I tried it on trunk lldb, and it stops at the memset line.

* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff6da656ec4 a.exe`main(argc=1, argv=0x00000254cf3510e0) at a.cpp:14
   11   main(int argc, char const *argv[])
   12   {
   13       int array[4];
-> 14       memset(array, 0, 4 * sizeof(int));
   15
   16       array[0] = product (1238, 78392);
   17       array[1] = product (379265, 23674);

@omjavaid
Copy link
Contributor Author

What's your lldb version?

I tried it on trunk lldb, and it stops at the memset line.

* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff6da656ec4 a.exe`main(argc=1, argv=0x00000254cf3510e0) at a.cpp:14
   11   main(int argc, char const *argv[])
   12   {
   13       int array[4];
-> 14       memset(array, 0, 4 * sizeof(int));
   15
   16       array[0] = product (1238, 78392);
   17       array[1] = product (379265, 23674);

I have tried it with TOT LLVM built using clang-cl 14.0.0. Verfied on both Arm and x86_64 Windows platform. This PDB/Windows specific issue.

@omjavaid
Copy link
Contributor Author

What's your lldb version?

I tried it on trunk lldb, and it stops at the memset line.

* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x00007ff6da656ec4 a.exe`main(argc=1, argv=0x00000254cf3510e0) at a.cpp:14
   11   main(int argc, char const *argv[])
   12   {
   13       int array[4];
-> 14       memset(array, 0, 4 * sizeof(int));
   15
   16       array[0] = product (1238, 78392);
   17       array[1] = product (379265, 23674);

Kindly share compiler commandline used to build this above code.

@ZequanWu
Copy link
Contributor

I used the same command line: clang-cl /Zi a.cpp.

@omjavaid
Copy link
Contributor Author

Are you using LLDB_USE_NATIVE_PDB_READER=1 ? Because it is specific to MS DIA SDK and works fine when LLDB's native pdb reader is used.

@ZequanWu
Copy link
Contributor

Oh, I'm using native pdb reader. Probably it's better to just use native pdb reader rather than DIA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category lldb platform:windows
Projects
None yet
Development

No branches or pull requests

3 participants