@@ -13,10 +13,11 @@ SYNOPSIS
13
13
DESCRIPTION
14
14
-----------
15
15
:program: `llvm-debuginfo-analyzer ` parses debug and text sections in
16
- binary object files and prints their contents in a logical view, which
17
- is a human readable representation that closely matches the structure
18
- of the original user source code. Supported object file formats include
19
- ELF, Mach-O, WebAssembly, PDB and COFF.
16
+ binary object files and textual IR representations and prints their
17
+ contents in a logical view, which is a human readable representation
18
+ that closely matches the structure of the original user source code.
19
+ Supported object file formats include ELF, Mach-O, WebAssembly, PDB,
20
+ COFF, IR (textual representation and bitcode).
20
21
21
22
The **logical view ** abstracts the complexity associated with the
22
23
different low-level representations of the debugging information that
@@ -2124,6 +2125,138 @@ layout and given the number of matches.
2124
2125
-----------------------------
2125
2126
Total 71 8
2126
2127
2128
+ IR (Textual representation and bitcode) SUPPORT
2129
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2130
+ The below example is used to show the IR output generated by
2131
+ :program: `llvm-debuginfo-analyzer `. We compiled the example for a
2132
+ IR 64-bit target with Clang (-O0 -g --target=x86_64-linux):
2133
+
2134
+ .. code-block :: c++
2135
+
2136
+ 1 using INTPTR = const int *;
2137
+ 2 int foo(INTPTR ParamPtr, unsigned ParamUnsigned, bool ParamBool) {
2138
+ 3 if (ParamBool) {
2139
+ 4 typedef int INTEGER;
2140
+ 5 const INTEGER CONSTANT = 7;
2141
+ 6 return CONSTANT;
2142
+ 7 }
2143
+ 8 return ParamUnsigned;
2144
+ 9 }
2145
+
2146
+ PRINT BASIC DETAILS
2147
+ ^^^^^^^^^^^^^^^^^^^
2148
+ The following command prints basic details for all the logical elements
2149
+ sorted by the debug information internal offset; it includes its lexical
2150
+ level and debug info format.
2151
+
2152
+ .. code-block :: none
2153
+
2154
+ llvm-debuginfo-analyzer --attribute=level,format
2155
+ --output-sort=offset
2156
+ --print=scopes,symbols,types,lines,instructions
2157
+ test-clang.ll
2158
+
2159
+ or
2160
+
2161
+ .. code-block :: none
2162
+
2163
+ llvm-debuginfo-analyzer --attribute=level,format
2164
+ --output-sort=offset
2165
+ --print=elements
2166
+ test-clang.ll
2167
+
2168
+ Each row represents an element that is present within the debug
2169
+ information. The first column represents the scope level, followed by
2170
+ the associated line number (if any), and finally the description of
2171
+ the element.
2172
+
2173
+ .. code-block :: none
2174
+
2175
+ Logical View:
2176
+ [000] {File} 'test-clang.ll' -> Textual IR
2177
+
2178
+ [001] {CompileUnit} 'test.cpp'
2179
+ [002] 2 {Function} extern not_inlined 'foo' -> 'int'
2180
+ [003] {Block}
2181
+ [004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'
2182
+ [004] 5 {Line}
2183
+ [004] {Code} 'store i32 7, ptr %CONSTANT, align 4, !dbg !32'
2184
+ [004] 6 {Line}
2185
+ [004] {Code} 'store i32 7, ptr %retval, align 4, !dbg !33'
2186
+ [004] 6 {Line}
2187
+ [004] {Code} 'br label %return, !dbg !33'
2188
+ [003] 2 {Parameter} 'ParamPtr' -> 'INTPTR'
2189
+ [003] 2 {Parameter} 'ParamUnsigned' -> 'unsigned int'
2190
+ [003] 2 {Parameter} 'ParamBool' -> 'bool'
2191
+ [003] 4 {TypeAlias} 'INTEGER' -> 'int'
2192
+ [003] 2 {Line}
2193
+ [003] {Code} '%retval = alloca i32, align 4'
2194
+ [003] {Code} '%ParamPtr.addr = alloca ptr, align 8'
2195
+ [003] {Code} '%ParamUnsigned.addr = alloca i32, align 4'
2196
+ [003] {Code} '%ParamBool.addr = alloca i8, align 1'
2197
+ [003] {Code} '%CONSTANT = alloca i32, align 4'
2198
+ [003] {Code} 'store ptr %ParamPtr, ptr %ParamPtr.addr, align 8'
2199
+ [003] {Code} 'store i32 %ParamUnsigned, ptr %ParamUnsigned.addr, align 4'
2200
+ [003] {Code} '%storedv = zext i1 %ParamBool to i8'
2201
+ [003] {Code} 'store i8 %storedv, ptr %ParamBool.addr, align 1'
2202
+ [003] 8 {Line}
2203
+ [003] {Code} '%1 = load i32, ptr %ParamUnsigned.addr, align 4, !dbg !34'
2204
+ [003] 8 {Line}
2205
+ [003] {Code} 'store i32 %1, ptr %retval, align 4, !dbg !35'
2206
+ [003] 8 {Line}
2207
+ [003] {Code} 'br label %return, !dbg !35'
2208
+ [003] 9 {Line}
2209
+ [003] {Code} '%2 = load i32, ptr %retval, align 4, !dbg !36'
2210
+ [003] 9 {Line}
2211
+ [003] {Code} 'ret i32 %2, !dbg !36'
2212
+ [003] 3 {Line}
2213
+ [003] 3 {Line}
2214
+ [003] 3 {Line}
2215
+ [003] {Code} 'br i1 %loadedv, label %if.then, label %if.end, !dbg !26'
2216
+ [002] 1 {TypeAlias} 'INTPTR' -> '* const int'
2217
+
2218
+ SELECT LOGICAL ELEMENTS
2219
+ ^^^^^^^^^^^^^^^^^^^^^^^
2220
+ The following prints all *instructions *, *symbols * and *types * that
2221
+ contain **'block' ** or **'.store' ** in their names or types, using a tab
2222
+ layout and given the number of matches.
2223
+
2224
+ .. code-block :: none
2225
+
2226
+ llvm-debuginfo-analyzer --attribute=level
2227
+ --select-nocase --select-regex
2228
+ --select=LOAD --select=store
2229
+ --report=list
2230
+ --print=symbols,types,instructions,summary
2231
+ test-clang.ll
2232
+
2233
+ Logical View:
2234
+ [000] {File} 'test-clang.ll'
2235
+
2236
+ [001] {CompileUnit} 'test.cpp'
2237
+ [003] {Code} '%0 = load i8, ptr %ParamBool.addr, align 1, !dbg !26'
2238
+ [003] {Code} '%1 = load i32, ptr %ParamUnsigned.addr, align 4, !dbg !34'
2239
+ [003] {Code} '%2 = load i32, ptr %retval, align 4, !dbg !36'
2240
+ [004] {Code} '%loadedv = trunc i8 %0 to i1, !dbg !26'
2241
+ [003] {Code} '%storedv = zext i1 %ParamBool to i8'
2242
+ [003] {Code} 'br i1 %loadedv, label %if.then, label %if.end, !dbg !26'
2243
+ [003] {Code} 'store i32 %1, ptr %retval, align 4, !dbg !35'
2244
+ [003] {Code} 'store i32 %ParamUnsigned, ptr %ParamUnsigned.addr, align 4'
2245
+ [004] {Code} 'store i32 7, ptr %CONSTANT, align 4, !dbg !32'
2246
+ [004] {Code} 'store i32 7, ptr %retval, align 4, !dbg !33'
2247
+ [003] {Code} 'store i8 %storedv, ptr %ParamBool.addr, align 1'
2248
+ [003] {Code} 'store ptr %ParamPtr, ptr %ParamPtr.addr, align 8'
2249
+
2250
+ -----------------------------
2251
+ Element Total Printed
2252
+ -----------------------------
2253
+ Scopes 5 0
2254
+ Symbols 4 0
2255
+ Types 2 0
2256
+ Lines 22 12
2257
+ -----------------------------
2258
+ Total 33 12
2259
+
2127
2260
COMPARISON MODE
2128
2261
^^^^^^^^^^^^^^^
2129
2262
Given the previous example we found the above debug information issue
@@ -2197,6 +2330,34 @@ giving more context by swapping the reference and target object files.
2197
2330
The output shows the merging view path (reference and target) with the
2198
2331
missing and added elements.
2199
2332
2333
+ .. code-block :: none
2334
+
2335
+ llvm-debuginfo-analyzer --attribute=level,format
2336
+ --compare=types
2337
+ --report=view
2338
+ --print=symbols,types
2339
+ test-clang.bc test-dwarf-gcc.o
2340
+
2341
+ Reference: 'test-clang.bc'
2342
+ Target: 'test-dwarf-gcc.o'
2343
+
2344
+ Logical View:
2345
+ [000] {File} 'test-clang.bc' -> Bitcode IR
2346
+
2347
+ [001] {CompileUnit} 'test.cpp'
2348
+ [002] 1 {TypeAlias} 'INTPTR' -> '* const int'
2349
+ [002] 2 {Function} extern not_inlined 'foo' -> 'int'
2350
+ [003] {Block}
2351
+ [004] 5 {Variable} 'CONSTANT' -> 'const INTEGER'
2352
+ +[004] 4 {TypeAlias} 'INTEGER' -> 'int'
2353
+ [003] 2 {Parameter} 'ParamBool' -> 'bool'
2354
+ [003] 2 {Parameter} 'ParamPtr' -> 'INTPTR'
2355
+ [003] 2 {Parameter} 'ParamUnsigned' -> 'unsigned int'
2356
+ -[003] 4 {TypeAlias} 'INTEGER' -> 'int'
2357
+
2358
+ The same output but this time comparing the Clang bitcode with the
2359
+ binary object (DWARF) generated by GCC.
2360
+
2200
2361
LOGICAL ELEMENTS
2201
2362
""""""""""""""""
2202
2363
It compares individual logical elements without considering if their
0 commit comments