36
36
#include " llvm/Support/LEB128.h"
37
37
#include " llvm/Support/Path.h"
38
38
#include " llvm/Support/ThreadPool.h"
39
- #include < iostream>
40
39
#include < vector>
41
40
42
41
namespace llvm {
@@ -2184,9 +2183,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2184
2183
if (const DWARFDebugLine::LineTable *LT =
2185
2184
ObjFile.Dwarf ->getLineTableForUnit (&Unit.getOrigUnit ())) {
2186
2185
// Search through Prologue
2187
- StringRef ObjName = ObjFile.FileName ;
2188
- llvm::outs () << " ObjName: " << ObjName << " \n " ;
2189
- bool ShouldDebug = ObjName.contains (" METAAppGroup.m" );
2190
2186
2191
2187
DWARFDebugLine::LineTable LineTable;
2192
2188
@@ -2212,18 +2208,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2212
2208
for (size_t i = 0 ; i < LT->Rows .size (); i++)
2213
2209
InputRows.emplace_back (TrackedRow{LT->Rows [i], i, false });
2214
2210
2215
- if (ShouldDebug) {
2216
- llvm::outs () << " DEBUG: InputRows setup:\n " ;
2217
- for (size_t i = 0 ; i < InputRows.size (); i++) {
2218
- llvm::outs () << " [" << i << " ] OriginalRowIndex: "
2219
- << InputRows[i].OriginalRowIndex << " , Address: 0x"
2220
- << llvm::format_hex (InputRows[i].Row .Address .Address , 16 )
2221
- << " , Line: " << InputRows[i].Row .Line
2222
- << " , EndSequence: " << InputRows[i].Row .EndSequence
2223
- << " \n " ;
2224
- }
2225
- }
2226
-
2227
2211
// This vector is the output line table (still in TrackedRow form).
2228
2212
std::vector<TrackedRow> OutputRows;
2229
2213
OutputRows.reserve (InputRows.size ());
@@ -2291,20 +2275,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2291
2275
insertLineSequence (Seq, OutputRows);
2292
2276
}
2293
2277
2294
- if (ShouldDebug) {
2295
- llvm::outs () << " DEBUG: OutputRows after processing:\n " ;
2296
- for (size_t i = 0 ; i < OutputRows.size (); i++) {
2297
- llvm::outs () << " [" << i << " ] OriginalRowIndex: "
2298
- << OutputRows[i].OriginalRowIndex << " , Address: 0x"
2299
- << llvm::format_hex (OutputRows[i].Row .Address .Address ,
2300
- 16 )
2301
- << " , Line: " << OutputRows[i].Row .Line
2302
- << " , EndSequence: " << OutputRows[i].Row .EndSequence
2303
- << " , isStartSeqInOutput: "
2304
- << OutputRows[i].isStartSeqInOutput << " \n " ;
2305
- }
2306
- }
2307
-
2308
2278
// Materialize the tracked rows into final DWARFDebugLine::Row objects.
2309
2279
LineTable.Rows .clear ();
2310
2280
LineTable.Rows .reserve (OutputRows.size ());
@@ -2339,15 +2309,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2339
2309
LineTableMapping[Seq.StmtSeqOffset ] = Seq.FirstRowIndex ;
2340
2310
}
2341
2311
2342
- if (ShouldDebug) {
2343
- llvm::outs () << " DEBUG: LineTableMapping from parser:\n " ;
2344
- for (const auto &Entry : LineTableMapping) {
2345
- llvm::outs () << " StmtSeqOffset: 0x"
2346
- << llvm::format_hex (Entry.first , 8 )
2347
- << " -> FirstRowIndex: " << Entry.second << " \n " ;
2348
- }
2349
- }
2350
-
2351
2312
// Second, manually find sequence boundaries and match them to the
2352
2313
// sorted attributes to handle sequences the parser might have missed.
2353
2314
auto StmtAttrs = Unit.getStmtSeqListAttributes ();
@@ -2356,27 +2317,12 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2356
2317
return A.get () < B.get ();
2357
2318
});
2358
2319
2359
- if (ShouldDebug) {
2360
- llvm::outs () << " DEBUG: Sorted StmtAttrs:\n " ;
2361
- for (const auto &Attr : StmtAttrs) {
2362
- llvm::outs () << " StmtSeqOffset: 0x"
2363
- << llvm::format_hex (Attr.get (), 8 ) << " \n " ;
2364
- }
2365
- }
2366
-
2367
2320
std::vector<size_t > SeqStartRows;
2368
2321
SeqStartRows.push_back (0 );
2369
2322
for (size_t i = 0 ; i < LT->Rows .size () - 1 ; ++i)
2370
2323
if (LT->Rows [i].EndSequence )
2371
2324
SeqStartRows.push_back (i + 1 );
2372
2325
2373
- if (ShouldDebug) {
2374
- llvm::outs () << " DEBUG: SeqStartRows:\n " ;
2375
- for (size_t i = 0 ; i < SeqStartRows.size (); ++i) {
2376
- llvm::outs () << " [" << i << " ]: " << SeqStartRows[i] << " \n " ;
2377
- }
2378
- }
2379
-
2380
2326
// While SeqOffToOrigRow parsed from CU could be the ground truth,
2381
2327
// e.g.
2382
2328
//
@@ -2438,44 +2384,22 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2438
2384
SeqStartIdxValidAndSmallerThanNext ()) {
2439
2385
SeqOffToOrigRow[StmtAttrs[StmtAttrIdx].get ()] =
2440
2386
SeqStartRows[SeqStartIdx];
2441
- if (ShouldDebug) {
2442
- llvm::outs ()
2443
- << " DEBUG: Adding dummy mapping: StmtSeqOffset 0x"
2444
- << llvm::format_hex (StmtAttrs[StmtAttrIdx].get (), 8 )
2445
- << " -> OrigRowIndex " << SeqStartRows[SeqStartIdx] << " \n " ;
2446
- }
2447
2387
++StmtAttrIdx;
2448
2388
++SeqStartIdx;
2449
2389
}
2450
2390
// One of the pointer points to the value at or past Next in the
2451
2391
// LineTableMapping, We move the pointer to re-align with the
2452
2392
// LineTableMapping
2453
2393
while (StmtIdxValidAndSmallerThanNext ()) {
2454
- if (ShouldDebug) {
2455
- llvm::outs ()
2456
- << " DEBUG: Skipping StmtAttr: 0x"
2457
- << llvm::format_hex (StmtAttrs[StmtAttrIdx].get (), 8 )
2458
- << " \n " ;
2459
- }
2460
2394
++StmtAttrIdx;
2461
2395
}
2462
2396
while (SeqStartIdxValidAndSmallerThanNext ()) {
2463
- if (ShouldDebug) {
2464
- llvm::outs () << " DEBUG: Skipping SeqStartRow: "
2465
- << SeqStartRows[SeqStartIdx] << " \n " ;
2466
- }
2467
2397
++SeqStartIdx;
2468
2398
}
2469
2399
// Use the LineTableMapping's result as the ground truth and move
2470
2400
// on.
2471
2401
if (NextSeqOff != DummyKey) {
2472
2402
SeqOffToOrigRow[NextSeqOff] = NextRow;
2473
- if (ShouldDebug) {
2474
- llvm::outs ()
2475
- << " DEBUG: Adding ground truth mapping: StmtSeqOffset 0x"
2476
- << llvm::format_hex (NextSeqOff, 8 ) << " -> OrigRowIndex "
2477
- << NextRow << " \n " ;
2478
- }
2479
2403
}
2480
2404
// It is possible that the first StmtAttrIdx/SeqStartIdx point to
2481
2405
// later entries in LineTableMapping. Therefore we only increment
@@ -2498,82 +2422,38 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
2498
2422
}
2499
2423
}
2500
2424
2501
- if (ShouldDebug) {
2502
- llvm::outs () << " DEBUG: Final SeqOffToOrigRow map:\n " ;
2503
- for (const auto &Entry : SeqOffToOrigRow) {
2504
- llvm::outs () << " StmtSeqOffset: 0x"
2505
- << llvm::format_hex (Entry.first , 8 )
2506
- << " -> OrigRowIndex: " << Entry.second << " \n " ;
2507
- }
2508
- }
2509
-
2510
2425
// Create a map of original row indices to new row indices.
2511
2426
DenseMap<size_t , size_t > OrigRowToNewRow;
2512
2427
for (size_t i = 0 ; i < OutputRows.size (); ++i)
2513
2428
OrigRowToNewRow[OutputRows[i].OriginalRowIndex ] = i;
2514
2429
2515
- if (ShouldDebug) {
2516
- llvm::outs () << " DEBUG: OrigRowToNewRow map:\n " ;
2517
- for (const auto &Entry : OrigRowToNewRow) {
2518
- llvm::outs () << " OrigRowIndex: " << Entry.first
2519
- << " -> NewRowIndex: " << Entry.second << " \n " ;
2520
- }
2521
- }
2522
-
2523
2430
// Patch DW_AT_LLVM_stmt_sequence attributes in the compile unit DIE
2524
2431
// with the correct offset into the .debug_line section.
2525
2432
for (const auto &StmtSeq : Unit.getStmtSeqListAttributes ()) {
2526
2433
uint64_t OrigStmtSeq = StmtSeq.get ();
2527
- if (ShouldDebug) {
2528
- llvm::outs () << " DEBUG: Processing StmtSeq attribute with offset 0x"
2529
- << llvm::format_hex (OrigStmtSeq, 8 ) << " \n " ;
2530
- }
2531
-
2532
2434
// 1. Get the original row index from the stmt list offset.
2533
2435
auto OrigRowIter = SeqOffToOrigRow.find (OrigStmtSeq);
2534
2436
// Check whether we have an output sequence for the StmtSeq offset.
2535
2437
// Some sequences are discarded by the DWARFLinker if they are invalid
2536
2438
// (empty).
2537
2439
if (OrigRowIter == SeqOffToOrigRow.end ()) {
2538
- if (ShouldDebug) {
2539
- llvm::outs () << " DEBUG: StmtSeq 0x"
2540
- << llvm::format_hex (OrigStmtSeq, 8 )
2541
- << " not found in SeqOffToOrigRow, setting to "
2542
- " OrigOffsetMissing\n " ;
2543
- }
2544
- StmtSeq.set (OrigOffsetMissing);
2440
+ StmtSeq.set (UINT64_MAX);
2545
2441
continue ;
2546
2442
}
2547
2443
size_t OrigRowIndex = OrigRowIter->second ;
2548
- if (ShouldDebug) {
2549
- llvm::outs () << " DEBUG: Found OrigRowIndex: " << OrigRowIndex
2550
- << " \n " ;
2551
- }
2552
-
2553
2444
// 2. Get the new row index from the original row index.
2554
2445
auto NewRowIter = OrigRowToNewRow.find (OrigRowIndex);
2555
2446
if (NewRowIter == OrigRowToNewRow.end ()) {
2556
2447
// If the original row index is not found in the map, update the
2557
2448
// stmt_sequence attribute to the 'invalid offset' magic value.
2558
- if (ShouldDebug) {
2559
- llvm::outs () << " DEBUG: OrigRowIndex " << OrigRowIndex
2560
- << " not found in OrigRowToNewRow, setting to "
2561
- " NewOffsetMissing\n " ;
2562
- }
2563
- StmtSeq.set (NewOffsetMissing);
2449
+ StmtSeq.set (UINT64_MAX);
2564
2450
continue ;
2565
2451
}
2566
2452
2567
2453
// 3. Get the offset of the new row in the output .debug_line section.
2568
2454
assert (NewRowIter->second < OutputRowOffsets.size () &&
2569
2455
" New row index out of bounds" );
2570
2456
uint64_t NewStmtSeqOffset = OutputRowOffsets[NewRowIter->second ];
2571
- if (ShouldDebug) {
2572
- llvm::outs () << " DEBUG: Found NewRowIndex: " << NewRowIter->second
2573
- << " , setting to new offset 0x"
2574
- << llvm::format_hex (NewStmtSeqOffset, 8 ) << " \n " ;
2575
- }
2576
-
2577
2457
// 4. Patch the stmt_list attribute with the new offset.
2578
2458
StmtSeq.set (NewStmtSeqOffset);
2579
2459
}
0 commit comments