C/C++ source file information
-----------------------------
-Given the source files ``MySource.cpp`` and ``MyHeader.h`` located in the
-directory ``/Users/mine/sources``, the following code:
-
-.. code-block:: c
-
- #include "MyHeader.h"
-
- int main(int argc, char *argv[]) {
- return 0;
- }
-
-a C/C++ front-end would generate the following descriptors:
-
-.. code-block:: llvm
-
- ...
- ;;
- ;; Define the compile unit for the main source file "/Users/mine/sources/MySource.cpp".
- ;;
- !0 = metadata !{
- i32 786449, ;; Tag
- metadata !1, ;; File/directory name
- i32 4, ;; Language Id
- metadata !"clang version 3.4 ",
- i1 false, ;; Optimized compile unit
- metadata !"", ;; Compiler flags
- i32 0, ;; Runtime version
- metadata !2, ;; Enumeration types
- metadata !2, ;; Retained types
- metadata !3, ;; Subprograms
- metadata !2, ;; Global variables
- metadata !2, ;; Imported entities (declarations and namespaces)
- metadata !"" ;; Split debug filename
- 1, ;; Full debug info
- }
-
- ;;
- ;; Define the file for the file "/Users/mine/sources/MySource.cpp".
- ;;
- !1 = metadata !{
- metadata !"MySource.cpp",
- metadata !"/Users/mine/sources"
- }
- !5 = metadata !{
- i32 786473, ;; Tag
- metadata !1
- }
-
- ;;
- ;; Define the file for the file "/Users/mine/sources/Myheader.h"
- ;;
- !14 = metadata !{
- i32 786473, ;; Tag
- metadata !15
- }
- !15 = metadata !{
- metadata !"./MyHeader.h",
- metadata !"/Users/mine/sources",
- }
-
- ...
-
``llvm::Instruction`` provides easy access to metadata attached with an
instruction. One can extract line number information encoded in LLVM IR using
``Instruction::getMetadata()`` and ``DILocation::getLineNumber()``.
;;
;; Define the global itself.
;;
- %MyGlobal = global int 100
+ @MyGlobal = global i32 100, align 4
...
;;
;; List of debug info of globals
;;
!4 = metadata !{
; Header(
- ; i32 52, ;; Tag
- ; metadata !"MyGlobal", ;; Name
- ; metadata !"MyGlobal", ;; Display Name
- ; metadata !"", ;; Linkage Name
- ; i32 1, ;; Line
- ; i32 0, ;; IsLocalToUnit
- ; i32 1 ;; IsDefinition
+ ; i32 52, ;; Tag
+ ; metadata !"MyGlobal", ;; Name
+ ; metadata !"MyGlobal", ;; Display Name
+ ; metadata !"", ;; Linkage Name
+ ; i32 1, ;; Line
+ ; i32 0, ;; IsLocalToUnit
+ ; i32 1 ;; IsDefinition
; )
metadata !"0x34\00MyGlobal\00MyGlobal\00\001\000\001",
null, ;; Unused
;; Define the file
;;
!5 = metadata !{
- Header(
- i32 41 ;; Tag
- ), ;; metadata !"0x29"
+ ; Header(
+ ; i32 41 ;; Tag
+ ; )
+ metadata !"0x29",
metadata !1 ;; File/directory pair
} ; [ DW_TAG_file_type ]
;;
!6 = metadata !{
; Header(
- ; i32 36, ;; Tag
- ; metadata !"int", ;; Name
- ; i32 0, ;; Line
- ; i64 32, ;; Size in Bits
- ; i64 32, ;; Align in Bits
- ; i64 0, ;; Offset
- ; i32 0, ;; Flags
- ; i32 5 ;; Encoding
+ ; i32 36, ;; Tag
+ ; metadata !"int", ;; Name
+ ; i32 0, ;; Line
+ ; i64 32, ;; Size in Bits
+ ; i64 32, ;; Align in Bits
+ ; i64 0, ;; Offset
+ ; i32 0, ;; Flags
+ ; i32 5 ;; Encoding
; )
metadata !"0x24\00int\000\0032\0032\000\000\005",
null, ;; Unused
;;
!6 = metadata !{
; Header(
- ; i32 46, ;; Tag
- ; metadata !"main", ;; Name
- ; metadata !"main", ;; Display name
- ; metadata !"", ;; Linkage name
- ; i32 1, ;; Line number
- ; i1 false, ;; Is local
- ; i1 true, ;; Is definition
- ; i32 0, ;; Virtuality attribute, e.g. pure virtual function
- ; i32 0, ;; Index into virtual table for C++ methods
- ; i32 256, ;; Flags
- ; i1 0, ;; True if this function is optimized
- ; 1 ;; Line number of the opening '{' of the function
+ ; i32 46, ;; Tag
+ ; metadata !"main", ;; Name
+ ; metadata !"main", ;; Display name
+ ; metadata !"", ;; Linkage name
+ ; i32 1, ;; Line number
+ ; i1 false, ;; Is local
+ ; i1 true, ;; Is definition
+ ; i32 0, ;; Virtuality attribute, e.g. pure virtual function
+ ; i32 0, ;; Index into virtual table for C++ methods
+ ; i32 256, ;; Flags
+ ; i1 0, ;; True if this function is optimized
+ ; 1 ;; Line number of the opening '{' of the function
; )
metadata !"0x2e\00main\00main\00\001\000\001\000\000\00256\000\001",
metadata !1, ;; File
New DWARF Constants
^^^^^^^^^^^^^^^^^^^
-+--------------------------------+-------+
-| Name | Value |
-+================================+=======+
-| DW_AT_APPLE_PROPERTY_readonly | 0x1 |
-+--------------------------------+-------+
-| DW_AT_APPLE_PROPERTY_readwrite | 0x2 |
-+--------------------------------+-------+
-| DW_AT_APPLE_PROPERTY_assign | 0x4 |
-+--------------------------------+-------+
-| DW_AT_APPLE_PROPERTY_retain | 0x8 |
-+--------------------------------+-------+
-| DW_AT_APPLE_PROPERTY_copy | 0x10 |
-+--------------------------------+-------+
-| DW_AT_APPLE_PROPERTY_nonatomic | 0x20 |
-+--------------------------------+-------+
++--------------------------------------+-------+
+| Name | Value |
++======================================+=======+
+| DW_APPLE_PROPERTY_readonly | 0x01 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_getter | 0x02 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_assign | 0x04 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_readwrite | 0x08 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_retain | 0x10 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_copy | 0x20 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_nonatomic | 0x40 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_setter | 0x80 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_atomic | 0x100 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_weak | 0x200 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_strong | 0x400 |
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_unsafe_unretained | 0x800 |
++--------------------------------+-----+-------+
Name Accelerator Tables
-----------------------
* DW_TAG_subrange_type
* DW_TAG_base_type
* DW_TAG_const_type
-* DW_TAG_constant
* DW_TAG_file_type
* DW_TAG_namelist
* DW_TAG_packed_type