@@ -201,7 +201,7 @@ const StringSection = struct {
201
201
};
202
202
203
203
/// A linker section containing a sequence of `Unit`s.
204
- const Section = struct {
204
+ pub const Section = struct {
205
205
dirty : bool ,
206
206
pad_to_ideal : bool ,
207
207
alignment : InternPool.Alignment ,
@@ -287,7 +287,7 @@ const Section = struct {
287
287
return sec .getUnit (unit ).addEntry (sec , dwarf );
288
288
}
289
289
290
- fn getUnit (sec : * Section , unit : Unit.Index ) * Unit {
290
+ pub fn getUnit (sec : * Section , unit : Unit.Index ) * Unit {
291
291
return & sec .units .items [@intFromEnum (unit )];
292
292
}
293
293
@@ -368,7 +368,7 @@ const Unit = struct {
368
368
none = std .math .maxInt (u32 ),
369
369
_ ,
370
370
371
- fn unwrap (uio : Optional ) ? Index {
371
+ pub fn unwrap (uio : Optional ) ? Index {
372
372
return if (uio != .none ) @enumFromInt (@intFromEnum (uio )) else null ;
373
373
}
374
374
};
@@ -415,7 +415,7 @@ const Unit = struct {
415
415
return entry ;
416
416
}
417
417
418
- fn getEntry (unit : * Unit , entry : Entry.Index ) * Entry {
418
+ pub fn getEntry (unit : * Unit , entry : Entry.Index ) * Entry {
419
419
return & unit .entries .items [@intFromEnum (entry )];
420
420
}
421
421
@@ -614,7 +614,7 @@ const Entry = struct {
614
614
none = std .math .maxInt (u32 ),
615
615
_ ,
616
616
617
- fn unwrap (eio : Optional ) ? Index {
617
+ pub fn unwrap (eio : Optional ) ? Index {
618
618
return if (eio != .none ) @enumFromInt (@intFromEnum (eio )) else null ;
619
619
}
620
620
};
@@ -736,7 +736,7 @@ const Entry = struct {
736
736
}
737
737
}
738
738
739
- fn assertNonEmpty (entry : * Entry , unit : * Unit , sec : * Section , dwarf : * Dwarf ) * Entry {
739
+ pub fn assertNonEmpty (entry : * Entry , unit : * Unit , sec : * Section , dwarf : * Dwarf ) * Entry {
740
740
if (entry .len > 0 ) return entry ;
741
741
if (std .debug .runtime_safety ) {
742
742
log .err ("missing {} from {s}" , .{
@@ -1958,11 +1958,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
1958
1958
const loc = tree .tokenLocation (0 , tree .nodes .items (.main_token )[decl_inst .data .declaration .src_node ]);
1959
1959
assert (loc .line == zcu .navSrcLine (nav_index ));
1960
1960
1961
- const unit = try dwarf .getUnit (file .mod );
1962
1961
var wip_nav : WipNav = .{
1963
1962
.dwarf = dwarf ,
1964
1963
.pt = pt ,
1965
- .unit = unit ,
1964
+ .unit = try dwarf . getUnit ( file . mod ) ,
1966
1965
.entry = undefined ,
1967
1966
.any_children = false ,
1968
1967
.func = .none ,
@@ -1981,7 +1980,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
1981
1980
switch (ip .indexToKey (nav_val .toIntern ())) {
1982
1981
.func = > | func | {
1983
1982
if (nav_gop .found_existing ) {
1984
- const unit_ptr = dwarf .debug_info .section .getUnit (unit );
1983
+ const unit_ptr = dwarf .debug_info .section .getUnit (wip_nav . unit );
1985
1984
const entry_ptr = unit_ptr .getEntry (nav_gop .value_ptr .* );
1986
1985
if (entry_ptr .len >= AbbrevCode .decl_bytes ) {
1987
1986
var abbrev_code_buf : [AbbrevCode .decl_bytes ]u8 = undefined ;
@@ -2000,7 +1999,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2000
1999
}
2001
2000
}
2002
2001
entry_ptr .clear ();
2003
- } else nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2002
+ } else nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav . unit );
2004
2003
wip_nav .entry = nav_gop .value_ptr .* ;
2005
2004
2006
2005
const parent_type , const accessibility : u8 = if (nav .analysis_owner .unwrap ()) | cau | parent : {
@@ -2074,8 +2073,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2074
2073
if (type_inst_info .inst != value_inst ) break :decl_struct ;
2075
2074
2076
2075
const type_gop = try dwarf .types .getOrPut (dwarf .gpa , nav_val .toIntern ());
2077
- if (type_gop .found_existing ) nav_gop .value_ptr .* = type_gop .value_ptr .* else {
2078
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2076
+ if (type_gop .found_existing ) {
2077
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (type_gop .value_ptr .* ).clear ();
2078
+ nav_gop .value_ptr .* = type_gop .value_ptr .* ;
2079
+ } else {
2080
+ if (nav_gop .found_existing )
2081
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2082
+ else
2083
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2079
2084
type_gop .value_ptr .* = nav_gop .value_ptr .* ;
2080
2085
}
2081
2086
wip_nav .entry = nav_gop .value_ptr .* ;
@@ -2139,7 +2144,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2139
2144
break :done ;
2140
2145
}
2141
2146
2142
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2147
+ if (nav_gop .found_existing )
2148
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2149
+ else
2150
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2143
2151
wip_nav .entry = nav_gop .value_ptr .* ;
2144
2152
const diw = wip_nav .debug_info .writer (dwarf .gpa );
2145
2153
try uleb128 (diw , @intFromEnum (AbbrevCode .decl_alias ));
@@ -2190,8 +2198,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2190
2198
if (type_inst_info .inst != value_inst ) break :decl_enum ;
2191
2199
2192
2200
const type_gop = try dwarf .types .getOrPut (dwarf .gpa , nav_val .toIntern ());
2193
- if (type_gop .found_existing ) nav_gop .value_ptr .* = type_gop .value_ptr .* else {
2194
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2201
+ if (type_gop .found_existing ) {
2202
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (type_gop .value_ptr .* ).clear ();
2203
+ nav_gop .value_ptr .* = type_gop .value_ptr .* ;
2204
+ } else {
2205
+ if (nav_gop .found_existing )
2206
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2207
+ else
2208
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2195
2209
type_gop .value_ptr .* = nav_gop .value_ptr .* ;
2196
2210
}
2197
2211
wip_nav .entry = nav_gop .value_ptr .* ;
@@ -2215,7 +2229,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2215
2229
break :done ;
2216
2230
}
2217
2231
2218
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2232
+ if (nav_gop .found_existing )
2233
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2234
+ else
2235
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2219
2236
wip_nav .entry = nav_gop .value_ptr .* ;
2220
2237
const diw = wip_nav .debug_info .writer (dwarf .gpa );
2221
2238
try uleb128 (diw , @intFromEnum (AbbrevCode .decl_alias ));
@@ -2264,8 +2281,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2264
2281
if (type_inst_info .inst != value_inst ) break :decl_union ;
2265
2282
2266
2283
const type_gop = try dwarf .types .getOrPut (dwarf .gpa , nav_val .toIntern ());
2267
- if (type_gop .found_existing ) nav_gop .value_ptr .* = type_gop .value_ptr .* else {
2268
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2284
+ if (type_gop .found_existing ) {
2285
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (type_gop .value_ptr .* ).clear ();
2286
+ nav_gop .value_ptr .* = type_gop .value_ptr .* ;
2287
+ } else {
2288
+ if (nav_gop .found_existing )
2289
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2290
+ else
2291
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2269
2292
type_gop .value_ptr .* = nav_gop .value_ptr .* ;
2270
2293
}
2271
2294
wip_nav .entry = nav_gop .value_ptr .* ;
@@ -2328,7 +2351,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2328
2351
break :done ;
2329
2352
}
2330
2353
2331
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2354
+ if (nav_gop .found_existing )
2355
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2356
+ else
2357
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2332
2358
wip_nav .entry = nav_gop .value_ptr .* ;
2333
2359
const diw = wip_nav .debug_info .writer (dwarf .gpa );
2334
2360
try uleb128 (diw , @intFromEnum (AbbrevCode .decl_alias ));
@@ -2377,8 +2403,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2377
2403
if (type_inst_info .inst != value_inst ) break :decl_opaque ;
2378
2404
2379
2405
const type_gop = try dwarf .types .getOrPut (dwarf .gpa , nav_val .toIntern ());
2380
- if (type_gop .found_existing ) nav_gop .value_ptr .* = type_gop .value_ptr .* else {
2381
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2406
+ if (type_gop .found_existing ) {
2407
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (type_gop .value_ptr .* ).clear ();
2408
+ nav_gop .value_ptr .* = type_gop .value_ptr .* ;
2409
+ } else {
2410
+ if (nav_gop .found_existing )
2411
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2412
+ else
2413
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2382
2414
type_gop .value_ptr .* = nav_gop .value_ptr .* ;
2383
2415
}
2384
2416
wip_nav .entry = nav_gop .value_ptr .* ;
@@ -2394,7 +2426,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2394
2426
break :done ;
2395
2427
}
2396
2428
2397
- if (! nav_gop .found_existing ) nav_gop .value_ptr .* = try dwarf .addCommonEntry (unit );
2429
+ if (nav_gop .found_existing )
2430
+ dwarf .debug_info .section .getUnit (wip_nav .unit ).getEntry (nav_gop .value_ptr .* ).clear ()
2431
+ else
2432
+ nav_gop .value_ptr .* = try dwarf .addCommonEntry (wip_nav .unit );
2398
2433
wip_nav .entry = nav_gop .value_ptr .* ;
2399
2434
const diw = wip_nav .debug_info .writer (dwarf .gpa );
2400
2435
try uleb128 (diw , @intFromEnum (AbbrevCode .decl_alias ));
@@ -2412,7 +2447,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2412
2447
},
2413
2448
}
2414
2449
try dwarf .debug_info .section .replaceEntry (wip_nav .unit , wip_nav .entry , dwarf , wip_nav .debug_info .items );
2415
- try dwarf .debug_loclists .section .replaceEntry (wip_nav .unit , wip_nav .entry , dwarf , wip_nav .debug_loclists .items );
2416
2450
try wip_nav .flush ();
2417
2451
}
2418
2452
0 commit comments