Possibility of Corruption of debug metadata

Hi,
If I convert global variables to thread-local variables or vice versa
at the IR stage do I have to take care of the debug metadata.
I looked at the IR generated and I couldn't find any difference
between the debug metadata generated for global variables and
thread-local variables.

Hi,
If I convert global variables to thread-local variables or vice versa
at the IR stage do I have to take care of the debug metadata.

If you provide an small concrete example then it would help,

Devang

Hi Devang,
I convert all global variables in a file to thread local at the IR level.
i.e. compile example_llvm.c to IR example_llvm.ll and change global
variables to thread-local variables. I also insert a function call just before
access of the global(now thread-local) variable. I also insert a local variable
in main. Does these operations in any way effect the debug metadata ?

I do not face any issues debugging my test case. But while debugging
my application
through gdb I cannot make sense of the call stack. I do not see the
function names in
the call stack (with or without insertion of additional function calls
or local variables).

example_llvm.ll (4.1 KB)

example_llvm_w.ll (4.33 KB)

example_llvm.c (202 Bytes)

In your example, you do not need to update debug info for @global_var at the moment. We are not identifying tls in debug info yet.

Hi Devang,

In your example, you do not need to update debug info for @global_var at the moment. We are not identifying tls in debug info yet.

Does that mean I will not be able to debug applications which use tls
through gdb if they are build with gcc-lllvm or clang.

I do not face any issues debugging my test case. But while debugging
my application
through gdb I cannot make sense of the call stack. I do not see the
function names in
the call stack (with or without insertion of additional function calls
or local variables).

What is the difference between your test case and application ? Is your application compiled using same compiler options ?

   My application is the linux kernel TCP/IP stack layer. There are
few #defines and compiler options which are different. Such as
-D"KBUILD_STR(s)=#s" -D"KBUILD_MODNAME=KBUILD_STR()" -D__KERNEL__,
-fno-common -fno-strict-aliasing.

Are these options in any way responsible for the problems I am facing
while debugging.
At this moment it is not possible for me to run my application
standalone without
modifying it.

Thanks for your help.

Hi Devang,

In your example, you do not need to update debug info for @global_var at the moment. We are not identifying tls in debug info yet.

Does that mean I will not be able to debug applications which use tls
through gdb if they are build with gcc-lllvm or clang.

It should not impact call stack info.

Hi Devang,
Is there any particular reason as to why debug info support for tls
hasn't been implemented.
Is the feature in pipeline ? How hard is it to implement ?

Shankha,

AFAIK, nobody is actively working on debug info for TLS at the moment.

Hi Devang,
Could you please give me some idea as to how difficult it is ? How much time it should take. If it is not very difficult I would like to do it myself.

Thanks for your help.