Help in generating Debug symbols

Hi all,

  I am new to LLVM. Currently working on adding an embedded target to
LLVM backend.
  I was able to generate the object file for our target using LLVM and
Clang framework.
  The generated object file doesn't contain any debug symbols in it.

  I tried searching documents related to this on web but couldn't find any.
  Can anyone please point some links/documents on generation of dwarf
debug symbols for the generated object file.

Thanks in Advance
Nagaraju

Hi,

Hi Florian,

   Thanks for the reply.

Hi,

Hi all,

   I am new to LLVM. Currently working on adding an embedded target to
LLVM backend.
   I was able to generate the object file for our target using LLVM and
Clang framework.
   The generated object file doesn't contain any debug symbols in it.

What commands are you using?

llvm/bin/clang -g -target xmb -c a.c

Do you get object files with debug info for> other backends?

Yes, for ARM and X86 targets debug symbols are generating fine.

If you pass `clang -g`, debug info should be generated. In> the IR, you should have !dbg metadata.

Yes I can see the !dbg metadata in ll file:

a.c

From: llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] On Behalf Of
Nagaraju Mekala via llvm-dev
Sent: Friday, December 08, 2017 10:06 AM
To: Florian Hahn
Cc: llvm-dev@lists.llvm.org; nd
Subject: Re: [llvm-dev] Help in generating Debug symbols

Hi Florian,

   Thanks for the reply.

> Hi,
>
>>
>> Hi all,
>>
>> I am new to LLVM. Currently working on adding an embedded target to
>> LLVM backend.
>> I was able to generate the object file for our target using LLVM and
>> Clang framework.
>> The generated object file doesn't contain any debug symbols in it.
>>
>
> What commands are you using?
llvm/bin/clang -g -target xmb -c a.c

> Do you get object files with debug info for> other backends?
Yes, for ARM and X86 targets debug symbols are generating fine.

> If you pass `clang -g`, debug info should be generated. In> the IR, you
should have !dbg metadata.
Yes I can see the !dbg metadata in ll file:

That is not surprising, if all you have done is add a new target.

If you use `clang -g -S` to get an asm file, do you see the
.debug_info and other .debug_* sections? Do you see .loc directives?
If not, the problem is somewhere in how your target interacts with
CodeGen. If you see these things in the assembler source, but
assembling to an object file loses the information, then there is
likely some problem with how your target interacts with the MC
layer. Or, if you are not emitting ELF or MachO object files, but
have your own object format, then you might have a problem with how
you have implemented the object file stuff.

I hope this helps narrow down the problem for you.
--paulr

Hi Paulr,

   Thanks for the pointers.
   In my case debug symbols are not getting generated even in asm
file. I will check the target interaction with Codegen.

Thanks,
Nagaraju