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