Skip to content

Commit 08642d2

Browse files
committed
next checkpoint on dwarf cleanup
1 parent f396b2e commit 08642d2

File tree

9 files changed

+385
-401
lines changed

9 files changed

+385
-401
lines changed

src/base/base_core.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -611,19 +611,19 @@ typedef enum Arch
611611
Arch_arm64,
612612
Arch_arm32,
613613
Arch_COUNT,
614+
}
615+
Arch;
614616
#if ARCH_X64
615-
Arch_CURRENT = Arch_x64,
617+
# define Arch_CURRENT Arch_x64
616618
#elif ARCH_X86
617-
Arch_CURRENT = Arch_x86,
619+
# define Arch_CURRENT Arch_x86
618620
#elif ARCH_ARM64
619-
Arch_CURRENT = Arch_arm64,
621+
# define Arch_CURRENT Arch_arm64
620622
#elif ARCH_ARM32
621-
Arch_CURRENT = Arch_arm32,
623+
# define Arch_CURRENT Arch_arm32
622624
#else
623-
Arch_CURRENT = Arch_Null,
625+
# define Arch_CURRENT Arch_Null
624626
#endif
625-
}
626-
Arch;
627627

628628
typedef enum Compiler
629629
{
@@ -632,17 +632,17 @@ typedef enum Compiler
632632
Compiler_gcc,
633633
Compiler_clang,
634634
Compiler_COUNT,
635+
}
636+
Compiler;
635637
#if COMPILER_MSVC
636-
Compiler_CURRENT = Compiler_msvc,
638+
# define Compiler_CURRENT Compiler_msvc
637639
#elif COMPILER_GCC
638-
Compiler_CURRENT = Compiler_gcc,
640+
# define Compiler_CURRENT Compiler_gcc
639641
#elif COMPILER_CLANG
640-
Compiler_CURRENT = Compiler_clang,
642+
# define Compiler_CURRENT Compiler_clang
641643
#else
642-
Compiler_CURRENT = Compiler_Null,
644+
# define Compiler_CURRENT Compiler_Null
643645
#endif
644-
}
645-
Compiler;
646646

647647
////////////////////////////////
648648
//~ rjf: Text 2D Coordinates & Ranges

src/dwarf/dwarf.c

Lines changed: 72 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ internal U64
7373
dw_reg_count_from_arch(Arch arch)
7474
{
7575
switch (arch) {
76-
default: { NotImplemented; } // fall-through
77-
case Arch_Null: return 0;
78-
case Arch_x86: return DW_RegX86_Last;
79-
case Arch_x64: return DW_RegX64_Last;
76+
default: { NotImplemented; } // fall-through
77+
case Arch_Null: return 0;
78+
case Arch_x86: return DW_RegX86_Last;
79+
case Arch_x64: return DW_RegX64_Last;
8080
}
8181
}
8282

@@ -98,10 +98,10 @@ internal U64
9898
dw_sp_from_arch(Arch arch)
9999
{
100100
switch (arch) {
101-
default: NotImplemented;
102-
case Arch_Null: return 0;
103-
case Arch_x86: return DW_RegX86_Esp;
104-
case Arch_x64: return DW_RegX64_Rsp;
101+
default: NotImplemented;
102+
case Arch_Null: return 0;
103+
case Arch_x86: return DW_RegX86_Esp;
104+
case Arch_x64: return DW_RegX64_Rsp;
105105
}
106106
}
107107

@@ -278,58 +278,64 @@ internal B32
278278
dw_are_attrib_class_and_form_kind_compatible(DW_Version ver, DW_AttribClass attrib_class, DW_FormKind form_kind)
279279
{
280280
DW_AttribClass compat_flags = dw_attrib_class_from_form_kind(ver, form_kind);
281-
B32 are_compat = (attrib_class & compat_flags) != 0;
281+
B32 are_compat = (attrib_class & compat_flags) != 0;
282282
return are_compat;
283283
}
284284

285285
internal String8
286286
dw_name_string_from_section_kind(DW_SectionKind k)
287287
{
288-
switch (k) {
289-
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L);
288+
String8 result = {0};
289+
switch(k)
290+
{
291+
#define X(_N,_L,_M,_D) case DW_Section_##_N:{result = str8_lit(_L);}break;
290292
DW_SectionKind_XList(X)
291293
#undef X
292294
}
293-
return str8_zero();
295+
return result;
294296
}
295297

296298
internal String8
297299
dw_mach_name_string_from_section_kind(DW_SectionKind k)
298300
{
299-
switch (k) {
300-
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M);
301+
String8 result = {0};
302+
switch(k)
303+
{
304+
#define X(_N,_L,_M,_D) case DW_Section_##_N:{result = str8_lit(_M);}break;
301305
DW_SectionKind_XList(X)
302306
#undef X
303307
}
304-
return str8_zero();
308+
return result;
305309
}
306310

307311
internal String8
308312
dw_dwo_name_string_from_section_kind(DW_SectionKind k)
309313
{
310-
switch (k) {
311-
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D);
314+
String8 result = {0};
315+
switch(k)
316+
{
317+
#define X(_N,_L,_M,_D) case DW_Section_##_N:{result = str8_lit(_D);}break;
312318
DW_SectionKind_XList(X)
313319
#undef X
314320
}
315-
return str8_zero();
321+
return result;
316322
}
317323

318324
internal U64
319325
dw_size_from_format(DW_Format format)
320326
{
321327
U64 result = 0;
322-
switch (format) {
323-
case DW_Format_Null: break;
328+
switch(format)
329+
{
330+
default:{}break;
324331
case DW_Format_32Bit: result = 4; break;
325332
case DW_Format_64Bit: result = 8; break;
326-
default: InvalidPath; break;
327333
}
328334
return result;
329335
}
330336

331337
internal DW_AttribClass
332-
dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKind attrib_kind, DW_FormKind form_kind)
338+
dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, DW_AttribKind attrib_kind, DW_FormKind form_kind)
333339
{
334340
// NOTE(rjf): DWARF's spec specifies two mappings:
335341
// (DW_AttribKind) => List(DW_AttribClass)
@@ -340,14 +346,10 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin
340346

341347
DW_AttribClass attrib_class = dw_attrib_class_from_attrib(ver, ext, attrib_kind);
342348
DW_AttribClass form_class = dw_attrib_class_from_form_kind(ver, form_kind);
343-
344-
if(relaxed)
349+
if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null)
345350
{
346-
if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null)
347-
{
348-
attrib_class = dw_attrib_class_from_attrib(DW_Version_Last, ext, attrib_kind);
349-
form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind);
350-
}
351+
attrib_class = dw_attrib_class_from_attrib(DW_Version_Last, ext, attrib_kind);
352+
form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind);
351353
}
352354

353355
DW_AttribClass result = DW_AttribClass_Null;
@@ -428,11 +430,11 @@ dw_operand_count_from_expr_op(DW_ExprOp op)
428430
switch (op) {
429431
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _OPER_COUNT;
430432
DW_Expr_V3_XList(X)
431-
DW_Expr_V4_XList(X)
432-
DW_Expr_V5_XList(X)
433-
DW_Expr_GNU_XList(X)
433+
DW_Expr_V4_XList(X)
434+
DW_Expr_V5_XList(X)
435+
DW_Expr_GNU_XList(X)
434436
#undef X
435-
default: { NotImplemented; } break;
437+
default: { NotImplemented; } break;
436438
}
437439
return 0;
438440
}
@@ -443,11 +445,11 @@ dw_pop_count_from_expr_op(DW_ExprOp op)
443445
switch (op) {
444446
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _POP_COUNT;
445447
DW_Expr_V3_XList(X)
446-
DW_Expr_V4_XList(X)
447-
DW_Expr_V5_XList(X)
448-
DW_Expr_GNU_XList(X)
448+
DW_Expr_V4_XList(X)
449+
DW_Expr_V5_XList(X)
450+
DW_Expr_GNU_XList(X)
449451
#undef X
450-
default: { NotImplemented; } break;
452+
default: { NotImplemented; } break;
451453
}
452454
return 0;
453455
}
@@ -458,11 +460,11 @@ dw_push_count_from_expr_op(DW_ExprOp op)
458460
switch (op) {
459461
#define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT) case _ID: return _PUSH_COUNT;
460462
DW_Expr_V3_XList(X)
461-
DW_Expr_V4_XList(X)
462-
DW_Expr_V5_XList(X)
463-
DW_Expr_GNU_XList(X)
463+
DW_Expr_V4_XList(X)
464+
DW_Expr_V5_XList(X)
465+
DW_Expr_GNU_XList(X)
464466
#undef X
465-
default: { NotImplemented; } break;
467+
default: { NotImplemented; } break;
466468
}
467469
return 0;
468470
}
@@ -474,7 +476,7 @@ dw_operand_count_from_cfa_opcode(DW_CFA_Opcode opcode)
474476
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return ArrayCount(t)-1; }
475477
DW_CFA_Kind_XList(X)
476478
#undef X
477-
default: { NotImplemented; } break;
479+
default: { NotImplemented; } break;
478480
}
479481
return 0;
480482
}
@@ -484,21 +486,21 @@ dw_is_cfa_expr_opcode_invalid(DW_ExprOp opcode)
484486
{
485487
B32 is_invalid = 0;
486488
switch (opcode) {
487-
case DW_ExprOp_Addrx:
488-
case DW_ExprOp_Call2:
489-
case DW_ExprOp_Call4:
490-
case DW_ExprOp_CallRef:
491-
case DW_ExprOp_ConstType:
492-
case DW_ExprOp_Constx:
493-
case DW_ExprOp_Convert:
494-
case DW_ExprOp_DerefType:
495-
case DW_ExprOp_RegvalType:
496-
case DW_ExprOp_Reinterpret:
497-
case DW_ExprOp_PushObjectAddress:
498-
case DW_ExprOp_CallFrameCfa: {
499-
is_invalid = 1;
500-
} break;
501-
default: break;
489+
case DW_ExprOp_Addrx:
490+
case DW_ExprOp_Call2:
491+
case DW_ExprOp_Call4:
492+
case DW_ExprOp_CallRef:
493+
case DW_ExprOp_ConstType:
494+
case DW_ExprOp_Constx:
495+
case DW_ExprOp_Convert:
496+
case DW_ExprOp_DerefType:
497+
case DW_ExprOp_RegvalType:
498+
case DW_ExprOp_Reinterpret:
499+
case DW_ExprOp_PushObjectAddress:
500+
case DW_ExprOp_CallFrameCfa: {
501+
is_invalid = 1;
502+
} break;
503+
default: break;
502504
}
503505
return is_invalid;
504506
}
@@ -508,14 +510,14 @@ dw_is_new_row_cfa_opcode(DW_CFA_Opcode opcode)
508510
{
509511
B32 is_new_row_op = 0;
510512
switch (opcode) {
511-
case DW_CFA_SetLoc:
512-
case DW_CFA_AdvanceLoc:
513-
case DW_CFA_AdvanceLoc1:
514-
case DW_CFA_AdvanceLoc2:
515-
case DW_CFA_AdvanceLoc4: {
516-
is_new_row_op = 1;
517-
} break;
518-
default: break;
513+
case DW_CFA_SetLoc:
514+
case DW_CFA_AdvanceLoc:
515+
case DW_CFA_AdvanceLoc1:
516+
case DW_CFA_AdvanceLoc2:
517+
case DW_CFA_AdvanceLoc4: {
518+
is_new_row_op = 1;
519+
} break;
520+
default: break;
519521
}
520522
return is_new_row_op;
521523
}
@@ -527,7 +529,7 @@ dw_operand_types_from_cfa_op(DW_CFA_Opcode opcode)
527529
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return &t[0] + 1; }
528530
DW_CFA_Kind_XList(X)
529531
#undef X
530-
default: { NotImplemented; } break;
532+
default: { NotImplemented; } break;
531533
}
532534
return 0;
533535
}
@@ -539,9 +541,9 @@ internal String8
539541
dw_string_from_format(DW_Format format)
540542
{
541543
switch (format) {
542-
case DW_Format_Null: return str8_zero();
543-
case DW_Format_32Bit: return str8_lit("DWARF32");
544-
case DW_Format_64Bit: return str8_lit("DWARF64");
544+
case DW_Format_Null: return str8_zero();
545+
case DW_Format_32Bit: return str8_lit("DWARF32");
546+
case DW_Format_64Bit: return str8_lit("DWARF64");
545547
}
546548
return str8_zero();
547549
}
@@ -824,7 +826,7 @@ dw_string_from_cfa_opcode(DW_CFA_Opcode opcode)
824826
#define X(_NAME, _ID, ...) case _ID: return str8_lit(Stringify(_NAME));
825827
DW_CFA_Kind_XList(X)
826828
#undef X
827-
default: InvalidPath; break;
829+
default: InvalidPath; break;
828830
}
829831
return str8_zero();
830832
}

src/dwarf/dwarf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ internal U64 dw_size_from_format(DW_Format format);
17821782

17831783
////////////////////////////////
17841784

1785-
internal DW_AttribClass dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKind attrib, DW_FormKind form_kind);
1785+
internal DW_AttribClass dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, DW_AttribKind attrib, DW_FormKind form_kind);
17861786

17871787
internal U64 dw_pick_default_lower_bound(DW_Language lang);
17881788

0 commit comments

Comments
 (0)