mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-07 08:25:41 +00:00
simplified dwarf parsing checkpoint: pull out form value reading, line table header parsing
This commit is contained in:
@@ -37,23 +37,27 @@ struct DW2_AbbrevMap
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tag Parsing Context
|
||||
//~ rjf: Parsing Context Bundle
|
||||
|
||||
typedef struct DW2_TagParseCtx DW2_TagParseCtx;
|
||||
struct DW2_TagParseCtx
|
||||
typedef struct DW2_ParseCtx DW2_ParseCtx;
|
||||
struct DW2_ParseCtx
|
||||
{
|
||||
DW_Raw *raw;
|
||||
// NOTE(rjf): all subsequent fields optional - top-level code fills out whatever
|
||||
// it can from context.
|
||||
DW_Version version;
|
||||
DW_Format format;
|
||||
U64 addr_size;
|
||||
String8 abbrev_data;
|
||||
DW2_AbbrevMap *abbrev_map;
|
||||
String8 unit_dir;
|
||||
String8 unit_file;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tag Attributes
|
||||
|
||||
typedef struct DW2_AttribVal DW2_AttribVal;
|
||||
struct DW2_AttribVal
|
||||
typedef struct DW2_FormVal DW2_FormVal;
|
||||
struct DW2_FormVal
|
||||
{
|
||||
DW_SectionKind section_kind;
|
||||
U128 u128;
|
||||
@@ -64,7 +68,7 @@ struct DW2_Attrib
|
||||
{
|
||||
DW_AttribKind attrib_kind;
|
||||
DW_FormKind form_kind;
|
||||
DW2_AttribVal val;
|
||||
DW2_FormVal val;
|
||||
};
|
||||
|
||||
typedef struct DW2_AttribNode DW2_AttribNode;
|
||||
@@ -93,6 +97,63 @@ struct DW2_Tag
|
||||
DW2_AttribList attribs;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Line Info
|
||||
|
||||
typedef struct DW2_LineTableFile DW2_LineTableFile;
|
||||
struct DW2_LineTableFile
|
||||
{
|
||||
String8 file_name;
|
||||
U64 dir_idx;
|
||||
U64 modify_time;
|
||||
U64 file_size;
|
||||
MD5 md5;
|
||||
String8 source;
|
||||
};
|
||||
|
||||
typedef struct DW2_LineTableFileNode DW2_LineTableFileNode;
|
||||
struct DW2_LineTableFileNode
|
||||
{
|
||||
DW2_LineTableFileNode *next;
|
||||
DW2_LineTableFile v;
|
||||
};
|
||||
|
||||
typedef struct DW2_LineTableFileList DW2_LineTableFileList;
|
||||
struct DW2_LineTableFileList
|
||||
{
|
||||
DW2_LineTableFileNode *first;
|
||||
DW2_LineTableFileNode *last;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct DW2_LineTableFileArray DW2_LineTableFileArray;
|
||||
struct DW2_LineTableFileArray
|
||||
{
|
||||
DW2_LineTableFile *v;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct DW2_LineTableHeader DW2_LineTableHeader;
|
||||
struct DW2_LineTableHeader
|
||||
{
|
||||
U64 unit_length;
|
||||
DW_Format format;
|
||||
DW_Version version;
|
||||
U8 addr_size;
|
||||
U8 segment_selector_size;
|
||||
U64 header_length;
|
||||
U8 min_inst_length;
|
||||
U8 max_ops_per_inst;
|
||||
U8 default_is_stmt;
|
||||
S8 line_base;
|
||||
U8 line_range;
|
||||
U8 opcode_base;
|
||||
U64 opcode_lengths_count;
|
||||
U8 *opcode_lengths;
|
||||
DW2_LineTableFileArray dirs;
|
||||
DW2_LineTableFileArray files;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Parsing Helpers
|
||||
|
||||
@@ -109,9 +170,20 @@ internal U64 dw2_read_unit_header(String8 data, U64 off, DW2_UnitHeader *out);
|
||||
|
||||
internal DW2_AbbrevMap dw2_abbrev_map_from_data(Arena *arena, String8 data, U64 off);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Form Value Parsing
|
||||
|
||||
internal U64 dw2_read_form_val(DW2_ParseCtx *ctx, String8 data, U64 off, DW_FormKind form_kind, U64 implicit_const, DW2_FormVal *out);
|
||||
internal String8 dw2_string_from_form_val(DW2_ParseCtx *ctx, DW2_FormVal val);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tag Parsing
|
||||
|
||||
internal U64 dw2_read_tag(Arena *arena, DW2_TagParseCtx *ctx, String8 data, U64 off, DW2_Tag *tag_out);
|
||||
internal U64 dw2_read_tag(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 off, DW2_Tag *tag_out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Line Table Parsing
|
||||
|
||||
internal U64 dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 off, DW2_LineTableHeader *out);
|
||||
|
||||
#endif // DWARF_PARSE_2_H
|
||||
|
||||
Reference in New Issue
Block a user