[llvm-dev] Dumping debug information from BC files

Robinson, Paul via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 18 11:39:02 PST 2018


A .bc file contains a form of LLVM IR (internal representation), it does not contain machine code.  You cannot use debug information in IR to find variables on the stack, because variables have not been assigned stack locations or registers until after you finish compiling or JIT the IR.
The JIT will translate IR instructions to machine instructions, assigning stack locations and so forth as it does so.  I don't know whether the JIT also translates the IR debug info into DWARF or CodeView, but that would be the kind of translation you need in order to debug the code produced by the JIT.
--paulr

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of via llvm-dev
Sent: Thursday, January 18, 2018 12:04 AM
To: Reid Kleckner
Cc: LLVM Developers Mailing List
Subject: Re: [llvm-dev] Dumping debug information from BC files

Thank you for your reply.

When I'm running "llvm-readobj" on an .obj file I get a result like shown in my attachment. This is very easy to read. I don't know if this is the codeview format. I would like to get this kind of debug information form a .bc file too, because I JIT them and wanted to try to build a debugger. With the file from "llvm-readobj" I see no problem - but when using the metadata I have no clue how to find variables on the stack - there are only this intrinsics, but I don't know how to handle them.
Maybe I asked the wrong question :/



From:        Reid Kleckner <rnk at google.com<mailto:rnk at google.com>>
To:        陳韋任 <chenwj.cs97g at g2.nctu.edu.tw<mailto:chenwj.cs97g at g2.nctu.edu.tw>>
Cc:        bjoern.gaier at horiba.com<mailto:bjoern.gaier at horiba.com>, LLVM Developers Mailing List <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>
Date:        17.01.2018 18:29
Subject:        Re: [llvm-dev] Dumping debug information from BC files
________________________________



The debug information is actually still in a different format in the .bc file, it is LLVM metadata. I think the best reference for it is here: https://llvm.org/docs/SourceLevelDebugging.html#ccxx-frontend

You can dump it just by disassembling the .bc file to textual IR using llvm-dis and examining the !DI* metadata nodes. You will have to run the file through llc to generate an object file to generate actual CodeView or DWARF.

On Wed, Jan 17, 2018 at 5:09 AM, 陳韋任 via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:
3.) Then I used clang-cl to generate a .bc file - but now I'm not able to use "llvm-readobj" anymore. Is there any tool available which can dump this debug information too?

​.bc is LLVM bitcode [1], not the usual object file. `llvm-readobj` should works only on the latter.

​[1] https://llvm.org/docs/BitCodeFormat.html

--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj

_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev




Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180118/4ae66b6e/attachment-0001.html>


More information about the llvm-dev mailing list