eliminate separate path layer, merge into base strings layer

This commit is contained in:
Ryan Fleury
2025-06-19 07:38:34 -07:00
parent f2dc9a7d4a
commit f590e9b6d5
15 changed files with 402 additions and 410 deletions
+222
View File
@@ -1497,6 +1497,228 @@ str8_txt_pt_pair_from_string(String8 string)
return pair; return pair;
} }
////////////////////////////////
//~ rjf: Relative <-> Absolute Path
internal String8
path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src)
{
Temp scratch = scratch_begin(&arena, 1);
// rjf: gather path parts
String8 dst_name = str8_skip_last_slash(dst);
String8 src_folder = src;
String8 dst_folder = str8_chop_last_slash(dst);
String8List src_folders = str8_split_path(scratch.arena, src_folder);
String8List dst_folders = str8_split_path(scratch.arena, dst_folder);
// rjf: count # of backtracks to get from src -> dest
U64 num_backtracks = src_folders.node_count;
for(String8Node *src_n = src_folders.first, *bp_n = dst_folders.first;
src_n != 0 && bp_n != 0;
src_n = src_n->next, bp_n = bp_n->next)
{
if(str8_match(src_n->string, bp_n->string, path_match_flags_from_os(operating_system_from_context())))
{
num_backtracks -= 1;
}
else
{
break;
}
}
// rjf: only build relative string if # of backtracks is not the entire `src`.
// if getting to `dst` from `src` requires erasing the entire `src`, then the
// only possible way to get to `dst` from `src` is via absolute path.
String8 dst_path = {0};
if(num_backtracks >= src_folders.node_count)
{
dst_path = dst;
}
else
{
// rjf: build backtrack parts
String8List dst_path_strs = {0};
for(U64 idx = 0; idx < num_backtracks; idx += 1)
{
str8_list_push(scratch.arena, &dst_path_strs, str8_lit(".."));
}
// rjf: build parts of dst which are unique from src
{
B32 unique_from_src = 0;
for(String8Node *src_n = src_folders.first, *bp_n = dst_folders.first;
bp_n != 0;
bp_n = bp_n->next)
{
if(!unique_from_src && (src_n == 0 || !str8_match(src_n->string, bp_n->string, path_match_flags_from_os(operating_system_from_context()))))
{
unique_from_src = 1;
}
if(unique_from_src)
{
str8_list_push(scratch.arena, &dst_path_strs, bp_n->string);
}
if(src_n != 0)
{
src_n = src_n->next;
}
}
}
// rjf: build file name
str8_list_push(scratch.arena, &dst_path_strs, dst_name);
// rjf: join
StringJoin join = {0};
{
join.sep = str8_lit("/");
}
dst_path = str8_list_join(arena, &dst_path_strs, &join);
}
scratch_end(scratch);
return dst_path;
}
internal String8
path_absolute_dst_from_relative_dst_src(Arena *arena, String8 dst, String8 src)
{
String8 result = dst;
PathStyle dst_style = path_style_from_str8(dst);
if(dst.size != 0 && dst_style == PathStyle_Relative)
{
Temp scratch = scratch_begin(&arena, 1);
String8 dst_from_src_absolute = push_str8f(scratch.arena, "%S/%S", src, dst);
String8List dst_from_src_absolute_parts = str8_split_path(scratch.arena, dst_from_src_absolute);
PathStyle dst_from_src_absolute_style = path_style_from_str8(src);
str8_path_list_resolve_dots_in_place(&dst_from_src_absolute_parts, dst_from_src_absolute_style);
result = str8_path_list_join_by_style(arena, &dst_from_src_absolute_parts, dst_from_src_absolute_style);
scratch_end(scratch);
}
return result;
}
////////////////////////////////
//~ rjf: Path Normalization
internal String8List
path_normalized_list_from_string(Arena *arena, String8 path_string, PathStyle *style_out)
{
// rjf: analyze path
PathStyle path_style = path_style_from_str8(path_string);
String8List path = str8_split_path(arena, path_string);
// rjf: resolve dots
str8_path_list_resolve_dots_in_place(&path, path_style);
// rjf: return
if(style_out != 0)
{
*style_out = path_style;
}
return path;
}
internal String8
path_normalized_from_string(Arena *arena, String8 path_string)
{
Temp scratch = scratch_begin(&arena, 1);
PathStyle style = PathStyle_Relative;
String8List path = path_normalized_list_from_string(scratch.arena, path_string, &style);
String8 result = str8_path_list_join_by_style(arena, &path, style);
scratch_end(scratch);
return result;
}
internal B32
path_match_normalized(String8 left, String8 right)
{
Temp scratch = scratch_begin(0, 0);
String8 left_normalized = path_normalized_from_string(scratch.arena, left);
String8 right_normalized = path_normalized_from_string(scratch.arena, right);
B32 result = str8_match(left_normalized, right_normalized, StringMatchFlag_CaseInsensitive);
scratch_end(scratch);
return result;
}
////////////////////////////////
//~ rjf: Misc. Path Helpers
internal PathStyle
path_style_from_string(String8 string)
{
for (U64 i = 0; i < ArrayCount(g_path_style_map); ++i)
{
if(str8_match(g_path_style_map[i].string, string, StringMatchFlag_CaseInsensitive))
{
return g_path_style_map[i].path_style;
}
}
return PathStyle_Null;
}
internal String8
string_from_path_style(PathStyle style)
{
Assert(style < ArrayCount(g_path_style_map));
return g_path_style_map[style].string;
}
internal String8
path_separator_string_from_style(PathStyle style)
{
String8 result = str8_zero();
switch (style)
{
case PathStyle_Null: break;
case PathStyle_Relative: break;
case PathStyle_WindowsAbsolute: result = str8_lit("\\"); break;
case PathStyle_UnixAbsolute: result = str8_lit("/"); break;
}
return result;
}
internal StringMatchFlags
path_match_flags_from_os(OperatingSystem os)
{
StringMatchFlags flags = StringMatchFlag_SlashInsensitive;
switch(os)
{
default:{}break;
case OperatingSystem_Windows:
{
flags |= StringMatchFlag_CaseInsensitive;
}break;
case OperatingSystem_Linux:
case OperatingSystem_Mac:
{
// NOTE(rjf): no-op
}break;
}
return flags;
}
internal String8
path_convert_slashes(Arena *arena, String8 path, PathStyle path_style)
{
Temp scratch = scratch_begin(&arena, 1);
String8List list = str8_split_path(scratch.arena, path);
StringJoin join = {0};
join.sep = path_separator_string_from_style(path_style);
String8 result = str8_list_join(arena, &list, &join);
scratch_end(scratch);
return result;
}
internal String8
path_replace_file_extension(Arena *arena, String8 file_name, String8 ext)
{
String8 file_name_no_ext = str8_chop_last_dot(file_name);
String8 result = push_str8f(arena, "%S.%S", file_name_no_ext, ext);
return result;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: UTF-8 & UTF-16 Decoding/Encoding //~ rjf: UTF-8 & UTF-16 Decoding/Encoding
+23
View File
@@ -328,6 +328,29 @@ internal String8 str8_path_list_join_by_style(Arena *arena, String8List *pat
internal String8TxtPtPair str8_txt_pt_pair_from_string(String8 string); internal String8TxtPtPair str8_txt_pt_pair_from_string(String8 string);
////////////////////////////////
//~ rjf: Relative <-> Absolute Path
internal String8 path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src);
internal String8 path_absolute_dst_from_relative_dst_src(Arena *arena, String8 dst, String8 src);
////////////////////////////////
//~ rjf: Path Normalization
internal String8List path_normalized_list_from_string(Arena *arena, String8 path, PathStyle *style_out);
internal String8 path_normalized_from_string(Arena *arena, String8 path);
internal B32 path_match_normalized(String8 left, String8 right);
////////////////////////////////
//~ rjf: Misc. Path Helpers
internal PathStyle path_style_from_string(String8 string);
internal String8 string_from_path_style(PathStyle style);
internal String8 path_separator_string_from_style(PathStyle style);
internal StringMatchFlags path_match_flags_from_os(OperatingSystem os);
internal String8 path_convert_slashes(Arena *arena, String8 path, PathStyle path_style);
internal String8 path_replace_file_extension(Arena *arena, String8 file_name, String8 ext);
//////////////////////////////// ////////////////////////////////
//~ rjf: UTF-8 & UTF-16 Decoding/Encoding //~ rjf: UTF-8 & UTF-16 Decoding/Encoding
+1 -1
View File
@@ -6,7 +6,7 @@ dw_string_from_reg_off(Arena *arena, Arch arch, U64 reg_idx, S64 reg_off)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
String8 reg_str = dw_string_from_register(scratch.arena, arch, reg_idx); String8 reg_str = dw_string_from_register(scratch.arena, arch, reg_idx);
String8 result = rd_string_from_reg_off(arena, reg_str, reg_off); String8 result = push_str8f(arena, "%S%+lld", reg_str, reg_off);
scratch_end(scratch); scratch_end(scratch);
return result; return result;
} }
+10
View File
@@ -0,0 +1,10 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#include "dwarf/dwarf.c"
#include "dwarf/dwarf_expr.c"
#include "dwarf/dwarf_parse.c"
#include "dwarf/dwarf_coff.c"
#include "dwarf/dwarf_elf.c"
#include "dwarf/dwarf_unwind.c"
#include "dwarf/dwarf_dump.c"
+15
View File
@@ -0,0 +1,15 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef DWARF_INC_H
#define DWARF_INC_H
#include "dwarf/dwarf.h"
#include "dwarf/dwarf_expr.h"
#include "dwarf/dwarf_parse.h"
#include "dwarf/dwarf_coff.h"
#include "dwarf/dwarf_elf.h"
#include "dwarf/dwarf_unwind.h"
#include "dwarf/dwarf_dump.h"
#endif // DWARF_INC_H
-2
View File
@@ -33,7 +33,6 @@
#include "base/base_inc.h" #include "base/base_inc.h"
#include "os/os_inc.h" #include "os/os_inc.h"
#include "path/path.h"
#include "coff/coff.h" #include "coff/coff.h"
#include "coff/coff_parse.h" #include "coff/coff_parse.h"
#include "pe/pe.h" #include "pe/pe.h"
@@ -46,7 +45,6 @@
#include "base/base_inc.c" #include "base/base_inc.c"
#include "os/os_inc.c" #include "os/os_inc.c"
#include "path/path.c"
#include "coff/coff.c" #include "coff/coff.c"
#include "coff/coff_parse.c" #include "coff/coff_parse.c"
#include "pe/pe.c" #include "pe/pe.c"
-224
View File
@@ -1,224 +0,0 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Relative <-> Absolute Path
internal String8
path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src)
{
Temp scratch = scratch_begin(&arena, 1);
// rjf: gather path parts
String8 dst_name = str8_skip_last_slash(dst);
String8 src_folder = src;
String8 dst_folder = str8_chop_last_slash(dst);
String8List src_folders = str8_split_path(scratch.arena, src_folder);
String8List dst_folders = str8_split_path(scratch.arena, dst_folder);
// rjf: count # of backtracks to get from src -> dest
U64 num_backtracks = src_folders.node_count;
for(String8Node *src_n = src_folders.first, *bp_n = dst_folders.first;
src_n != 0 && bp_n != 0;
src_n = src_n->next, bp_n = bp_n->next)
{
if(str8_match(src_n->string, bp_n->string, path_match_flags_from_os(operating_system_from_context())))
{
num_backtracks -= 1;
}
else
{
break;
}
}
// rjf: only build relative string if # of backtracks is not the entire `src`.
// if getting to `dst` from `src` requires erasing the entire `src`, then the
// only possible way to get to `dst` from `src` is via absolute path.
String8 dst_path = {0};
if(num_backtracks >= src_folders.node_count)
{
dst_path = dst;
}
else
{
// rjf: build backtrack parts
String8List dst_path_strs = {0};
for(U64 idx = 0; idx < num_backtracks; idx += 1)
{
str8_list_push(scratch.arena, &dst_path_strs, str8_lit(".."));
}
// rjf: build parts of dst which are unique from src
{
B32 unique_from_src = 0;
for(String8Node *src_n = src_folders.first, *bp_n = dst_folders.first;
bp_n != 0;
bp_n = bp_n->next)
{
if(!unique_from_src && (src_n == 0 || !str8_match(src_n->string, bp_n->string, path_match_flags_from_os(operating_system_from_context()))))
{
unique_from_src = 1;
}
if(unique_from_src)
{
str8_list_push(scratch.arena, &dst_path_strs, bp_n->string);
}
if(src_n != 0)
{
src_n = src_n->next;
}
}
}
// rjf: build file name
str8_list_push(scratch.arena, &dst_path_strs, dst_name);
// rjf: join
StringJoin join = {0};
{
join.sep = str8_lit("/");
}
dst_path = str8_list_join(arena, &dst_path_strs, &join);
}
scratch_end(scratch);
return dst_path;
}
internal String8
path_absolute_dst_from_relative_dst_src(Arena *arena, String8 dst, String8 src)
{
String8 result = dst;
PathStyle dst_style = path_style_from_str8(dst);
if(dst.size != 0 && dst_style == PathStyle_Relative)
{
Temp scratch = scratch_begin(&arena, 1);
String8 dst_from_src_absolute = push_str8f(scratch.arena, "%S/%S", src, dst);
String8List dst_from_src_absolute_parts = str8_split_path(scratch.arena, dst_from_src_absolute);
PathStyle dst_from_src_absolute_style = path_style_from_str8(src);
str8_path_list_resolve_dots_in_place(&dst_from_src_absolute_parts, dst_from_src_absolute_style);
result = str8_path_list_join_by_style(arena, &dst_from_src_absolute_parts, dst_from_src_absolute_style);
scratch_end(scratch);
}
return result;
}
////////////////////////////////
//~ rjf: Path Normalization
internal String8List
path_normalized_list_from_string(Arena *arena, String8 path_string, PathStyle *style_out)
{
// rjf: analyze path
PathStyle path_style = path_style_from_str8(path_string);
String8List path = str8_split_path(arena, path_string);
// rjf: resolve dots
str8_path_list_resolve_dots_in_place(&path, path_style);
// rjf: return
if(style_out != 0)
{
*style_out = path_style;
}
return path;
}
internal String8
path_normalized_from_string(Arena *arena, String8 path_string)
{
Temp scratch = scratch_begin(&arena, 1);
PathStyle style = PathStyle_Relative;
String8List path = path_normalized_list_from_string(scratch.arena, path_string, &style);
String8 result = str8_path_list_join_by_style(arena, &path, style);
scratch_end(scratch);
return result;
}
internal B32
path_match_normalized(String8 left, String8 right)
{
Temp scratch = scratch_begin(0, 0);
String8 left_normalized = path_normalized_from_string(scratch.arena, left);
String8 right_normalized = path_normalized_from_string(scratch.arena, right);
B32 result = str8_match(left_normalized, right_normalized, StringMatchFlag_CaseInsensitive);
scratch_end(scratch);
return result;
}
////////////////////////////////
//~ rjf: Basic Helpers
internal PathStyle
path_style_from_string(String8 string)
{
for (U64 i = 0; i < ArrayCount(g_path_style_map); ++i)
{
if(str8_match(g_path_style_map[i].string, string, StringMatchFlag_CaseInsensitive))
{
return g_path_style_map[i].path_style;
}
}
return PathStyle_Null;
}
internal String8
string_from_path_style(PathStyle style)
{
Assert(style < ArrayCount(g_path_style_map));
return g_path_style_map[style].string;
}
internal String8
path_separator_string_from_style(PathStyle style)
{
String8 result = str8_zero();
switch (style)
{
case PathStyle_Null: break;
case PathStyle_Relative: break;
case PathStyle_WindowsAbsolute: result = str8_lit("\\"); break;
case PathStyle_UnixAbsolute: result = str8_lit("/"); break;
}
return result;
}
internal StringMatchFlags
path_match_flags_from_os(OperatingSystem os)
{
StringMatchFlags flags = StringMatchFlag_SlashInsensitive;
switch(os)
{
default:{}break;
case OperatingSystem_Windows:
{
flags |= StringMatchFlag_CaseInsensitive;
}break;
case OperatingSystem_Linux:
case OperatingSystem_Mac:
{
// NOTE(rjf): no-op
}break;
}
return flags;
}
internal String8
path_convert_slashes(Arena *arena, String8 path, PathStyle path_style)
{
Temp scratch = scratch_begin(&arena, 1);
String8List list = str8_split_path(scratch.arena, path);
StringJoin join = {0};
join.sep = path_separator_string_from_style(path_style);
String8 result = str8_list_join(arena, &list, &join);
scratch_end(scratch);
return result;
}
internal String8
path_replace_file_extension(Arena *arena, String8 file_name, String8 ext)
{
String8 file_name_no_ext = str8_chop_last_dot(file_name);
String8 result = push_str8f(arena, "%S.%S", file_name_no_ext, ext);
return result;
}
-30
View File
@@ -1,30 +0,0 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
#ifndef PATH_H
#define PATH_H
////////////////////////////////
//~ rjf: Relative <-> Absolute Path
internal String8 path_relative_dst_from_absolute_dst_src(Arena *arena, String8 dst, String8 src);
internal String8 path_absolute_dst_from_relative_dst_src(Arena *arena, String8 dst, String8 src);
////////////////////////////////
//~ rjf: Path Normalization
internal String8List path_normalized_list_from_string(Arena *arena, String8 path, PathStyle *style_out);
internal String8 path_normalized_from_string(Arena *arena, String8 path);
internal B32 path_match_normalized(String8 left, String8 right);
////////////////////////////////
//~ rjf: Basic Helpers
internal PathStyle path_style_from_string(String8 string);
internal String8 string_from_path_style(PathStyle style);
internal String8 path_separator_string_from_style(PathStyle style);
internal StringMatchFlags path_match_flags_from_os(OperatingSystem os);
internal String8 path_convert_slashes(Arena *arena, String8 path, PathStyle path_style);
internal String8 path_replace_file_extension(Arena *arena, String8 file_name, String8 ext);
#endif //PATH_H
+2 -12
View File
@@ -18,7 +18,6 @@
#include "base/base_inc.h" #include "base/base_inc.h"
#include "linker/hash_table.h" #include "linker/hash_table.h"
#include "os/os_inc.h" #include "os/os_inc.h"
#include "path/path.h"
#include "async/async.h" #include "async/async.h"
#include "rdi_format/rdi_format_local.h" #include "rdi_format/rdi_format_local.h"
#include "rdi_make/rdi_make_local.h" #include "rdi_make/rdi_make_local.h"
@@ -29,11 +28,7 @@
#include "elf/elf_parse.h" #include "elf/elf_parse.h"
#include "codeview/codeview.h" #include "codeview/codeview.h"
#include "codeview/codeview_parse.h" #include "codeview/codeview_parse.h"
#include "dwarf/dwarf.h" #include "dwarf/dwarf_inc.h"
#include "dwarf/dwarf_parse.h"
#include "dwarf/dwarf_coff.h"
#include "dwarf/dwarf_elf.h"
// #include "dwarf/dwarf_dump.h"
#include "msf/msf.h" #include "msf/msf.h"
#include "msf/msf_parse.h" #include "msf/msf_parse.h"
#include "pdb/pdb.h" #include "pdb/pdb.h"
@@ -50,7 +45,6 @@
#include "base/base_inc.c" #include "base/base_inc.c"
#include "linker/hash_table.c" #include "linker/hash_table.c"
#include "os/os_inc.c" #include "os/os_inc.c"
#include "path/path.c"
#include "async/async.c" #include "async/async.c"
#include "rdi_format/rdi_format_local.c" #include "rdi_format/rdi_format_local.c"
#include "rdi_make/rdi_make_local.c" #include "rdi_make/rdi_make_local.c"
@@ -61,11 +55,7 @@
#include "elf/elf_parse.c" #include "elf/elf_parse.c"
#include "codeview/codeview.c" #include "codeview/codeview.c"
#include "codeview/codeview_parse.c" #include "codeview/codeview_parse.c"
#include "dwarf/dwarf.c" #include "dwarf/dwarf_inc.c"
#include "dwarf/dwarf_parse.c"
#include "dwarf/dwarf_coff.c"
#include "dwarf/dwarf_elf.c"
// #include "dwarf/dwarf_dump.c"
#include "msf/msf.c" #include "msf/msf.c"
#include "msf/msf_parse.c" #include "msf/msf_parse.c"
#include "pdb/pdb.c" #include "pdb/pdb.c"
-2
View File
@@ -28,7 +28,6 @@
#include "base/base_inc.h" #include "base/base_inc.h"
#include "os/os_inc.h" #include "os/os_inc.h"
#include "async/async.h" #include "async/async.h"
#include "path/path.h"
#include "rdi_make/rdi_make_local.h" #include "rdi_make/rdi_make_local.h"
#include "linker/hash_table.h" #include "linker/hash_table.h"
#include "coff/coff.h" #include "coff/coff.h"
@@ -60,7 +59,6 @@
#include "base/base_inc.c" #include "base/base_inc.c"
#include "os/os_inc.c" #include "os/os_inc.c"
#include "async/async.c" #include "async/async.c"
#include "path/path.c"
#include "rdi_make/rdi_make_local.c" #include "rdi_make/rdi_make_local.c"
#include "linker/hash_table.c" #include "linker/hash_table.c"
#include "coff/coff.c" #include "coff/coff.c"
-2
View File
@@ -218,7 +218,6 @@
#include "file_stream/file_stream.h" #include "file_stream/file_stream.h"
#include "text_cache/text_cache.h" #include "text_cache/text_cache.h"
#include "mutable_text/mutable_text.h" #include "mutable_text/mutable_text.h"
#include "path/path.h"
#include "coff/coff.h" #include "coff/coff.h"
#include "coff/coff_parse.h" #include "coff/coff_parse.h"
#include "pe/pe.h" #include "pe/pe.h"
@@ -272,7 +271,6 @@
#include "file_stream/file_stream.c" #include "file_stream/file_stream.c"
#include "text_cache/text_cache.c" #include "text_cache/text_cache.c"
#include "mutable_text/mutable_text.c" #include "mutable_text/mutable_text.c"
#include "path/path.c"
#include "coff/coff.c" #include "coff/coff.c"
#include "coff/coff_parse.c" #include "coff/coff_parse.c"
#include "pe/pe.c" #include "pe/pe.c"
-2
View File
@@ -28,7 +28,6 @@
#include "async/async.h" #include "async/async.h"
#include "rdi_format/rdi_format_local.h" #include "rdi_format/rdi_format_local.h"
#include "rdi_make/rdi_make_local.h" #include "rdi_make/rdi_make_local.h"
#include "path/path.h"
#include "linker/hash_table.h" #include "linker/hash_table.h"
#include "coff/coff.h" #include "coff/coff.h"
#include "coff/coff_parse.h" #include "coff/coff_parse.h"
@@ -61,7 +60,6 @@
#include "async/async.c" #include "async/async.c"
#include "rdi_format/rdi_format_local.c" #include "rdi_format/rdi_format_local.c"
#include "rdi_make/rdi_make_local.c" #include "rdi_make/rdi_make_local.c"
#include "path/path.c"
#include "linker/hash_table.c" #include "linker/hash_table.c"
#include "coff/coff.c" #include "coff/coff.c"
#include "coff/coff_parse.c" #include "coff/coff_parse.c"
-2
View File
@@ -16,7 +16,6 @@
//- rjf: [h] //- rjf: [h]
#include "base/base_inc.h" #include "base/base_inc.h"
#include "os/os_inc.h" #include "os/os_inc.h"
#include "path/path.h"
#include "async/async.h" #include "async/async.h"
#include "rdi_format/rdi_format_local.h" #include "rdi_format/rdi_format_local.h"
#include "dbgi/dbgi.h" #include "dbgi/dbgi.h"
@@ -24,7 +23,6 @@
//- rjf: [c] //- rjf: [c]
#include "base/base_inc.c" #include "base/base_inc.c"
#include "os/os_inc.c" #include "os/os_inc.c"
#include "path/path.c"
#include "async/async.c" #include "async/async.c"
#include "rdi_format/rdi_format_local.c" #include "rdi_format/rdi_format_local.c"
#include "dbgi/dbgi.c" #include "dbgi/dbgi.c"
+84 -86
View File
@@ -32,13 +32,11 @@
#include "third_party/xxHash/xxhash.h" #include "third_party/xxHash/xxhash.h"
#include "linker/base_ext/base_inc.h" #include "linker/base_ext/base_inc.h"
#include "linker/path_ext/path.h"
#include "linker/hash_table.h" #include "linker/hash_table.h"
#include "linker/thread_pool/thread_pool.h" #include "linker/thread_pool/thread_pool.h"
#include "linker/codeview_ext/codeview.h" #include "linker/codeview_ext/codeview.h"
#include "linker/base_ext/base_inc.c" #include "linker/base_ext/base_inc.c"
#include "linker/path_ext/path.c"
#include "linker/hash_table.c" #include "linker/hash_table.c"
#include "linker/thread_pool/thread_pool.c" #include "linker/thread_pool/thread_pool.c"
#include "linker/codeview_ext/codeview.c" #include "linker/codeview_ext/codeview.c"
@@ -56,88 +54,88 @@ print_inline_binary_annotations(String8 binary_annots)
fprintf(stdout, "\t\t[%04llX] ", op_offset); fprintf(stdout, "\t\t[%04llX] ", op_offset);
switch (op) { switch (op) {
case CV_InlineBinaryAnnotation_Null: { case CV_InlineBinaryAnnotation_Null: {
fprintf(stdout, "End"); fprintf(stdout, "End");
cursor = binary_annots.size; cursor = binary_annots.size;
} break; } break;
case CV_InlineBinaryAnnotation_CodeOffset: { case CV_InlineBinaryAnnotation_CodeOffset: {
U32 value = 0; U32 value = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &value); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &value);
code_offset += value; code_offset += value;
fprintf(stdout, "CodeOffset: 0x%X; Code 0x%X", value, code_offset); fprintf(stdout, "CodeOffset: 0x%X; Code 0x%X", value, code_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeCodeOffsetBase: { case CV_InlineBinaryAnnotation_ChangeCodeOffsetBase: {
U32 delta; U32 delta;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &delta); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &delta);
code_offset += delta; code_offset += delta;
fprintf(stdout, "ChangeCodeOffsetBase: 0x%X; Code 0x%X", delta, code_offset); fprintf(stdout, "ChangeCodeOffsetBase: 0x%X; Code 0x%X", delta, code_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeCodeOffset: { case CV_InlineBinaryAnnotation_ChangeCodeOffset: {
U32 delta = 0; U32 delta = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &delta); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &delta);
code_offset += delta; code_offset += delta;
fprintf(stdout, "ChangeCodeOffset: 0x%X; Code 0x%X", delta, code_offset); fprintf(stdout, "ChangeCodeOffset: 0x%X; Code 0x%X", delta, code_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeCodeLength: { case CV_InlineBinaryAnnotation_ChangeCodeLength: {
U32 delta = 0; U32 delta = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &delta); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &delta);
code_offset += delta; code_offset += delta;
fprintf(stdout, "ChangeCodeLength: 0x%X; Code End 0x%X", delta, code_offset); fprintf(stdout, "ChangeCodeLength: 0x%X; Code End 0x%X", delta, code_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeFile: { case CV_InlineBinaryAnnotation_ChangeFile: {
U32 file_id = 0; U32 file_id = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &file_id); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &file_id);
fprintf(stdout, "ChangeFile: 0x%X", file_id); fprintf(stdout, "ChangeFile: 0x%X", file_id);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeLineOffset: { case CV_InlineBinaryAnnotation_ChangeLineOffset: {
S32 delta = 0; S32 delta = 0;
cursor += cv_decode_inline_annot_s32(binary_annots, cursor, &delta); cursor += cv_decode_inline_annot_s32(binary_annots, cursor, &delta);
line_offset += delta; line_offset += delta;
fprintf(stdout, "ChangeLineOffset: %d; Line %d", delta, line_offset); fprintf(stdout, "ChangeLineOffset: %d; Line %d", delta, line_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeLineEndDelta: { case CV_InlineBinaryAnnotation_ChangeLineEndDelta: {
S32 end_delta = 0; S32 end_delta = 0;
cursor += cv_decode_inline_annot_s32(binary_annots, cursor, &end_delta); cursor += cv_decode_inline_annot_s32(binary_annots, cursor, &end_delta);
line_offset += end_delta; line_offset += end_delta;
fprintf(stdout, "ChangeLineEndDelta: %d; Line %d", end_delta, line_offset); fprintf(stdout, "ChangeLineEndDelta: %d; Line %d", end_delta, line_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeRangeKind: { case CV_InlineBinaryAnnotation_ChangeRangeKind: {
CV_InlineRangeKind range_kind = 0; CV_InlineRangeKind range_kind = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &range_kind); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &range_kind);
String8 range_kind_str = cv_string_from_inline_range_kind(range_kind); String8 range_kind_str = cv_string_from_inline_range_kind(range_kind);
fprintf(stdout, "ChangeRangeKind: %.*s (%u)", str8_varg(range_kind_str), range_kind); fprintf(stdout, "ChangeRangeKind: %.*s (%u)", str8_varg(range_kind_str), range_kind);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeColumnStart: { case CV_InlineBinaryAnnotation_ChangeColumnStart: {
S32 delta = 0; S32 delta = 0;
cursor += cv_decode_inline_annot_s32(binary_annots, cursor, &delta); cursor += cv_decode_inline_annot_s32(binary_annots, cursor, &delta);
fprintf(stdout, "ChangeColumnStart: %d", delta); fprintf(stdout, "ChangeColumnStart: %d", delta);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeCodeOffsetAndLineOffset: { case CV_InlineBinaryAnnotation_ChangeCodeOffsetAndLineOffset: {
U32 code_offset_and_line_offset = 0; U32 code_offset_and_line_offset = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &code_offset_and_line_offset); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &code_offset_and_line_offset);
S32 line_delta = cv_inline_annot_signed_from_unsigned_operand(code_offset_and_line_offset >> 4); S32 line_delta = cv_inline_annot_signed_from_unsigned_operand(code_offset_and_line_offset >> 4);
U32 code_delta = code_offset_and_line_offset & 0xF; U32 code_delta = code_offset_and_line_offset & 0xF;
line_offset += line_delta; line_offset += line_delta;
code_offset += code_delta; code_offset += code_delta;
fprintf(stdout, "ChnageCodeOffsetAndLineOffset: 0x%X %d; Code 0x%X Line %d", code_delta, line_delta, code_offset, line_offset); fprintf(stdout, "ChnageCodeOffsetAndLineOffset: 0x%X %d; Code 0x%X Line %d", code_delta, line_delta, code_offset, line_offset);
} break; } break;
case CV_InlineBinaryAnnotation_ChangeCodeLengthAndCodeOffset: { case CV_InlineBinaryAnnotation_ChangeCodeLengthAndCodeOffset: {
U32 code_length_delta = 0; U32 code_length_delta = 0;
U32 code_offset_delta = 0; U32 code_offset_delta = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &code_length_delta); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &code_length_delta);
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &code_offset_delta); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &code_offset_delta);
code_offset += code_offset_delta; code_offset += code_offset_delta;
fprintf(stdout, "ChangeCodeLengthAndCodeOffset: %u 0x%X; Code 0x%X Code End 0x%X", code_length_delta, code_offset_delta, code_offset, code_offset + code_length_delta); fprintf(stdout, "ChangeCodeLengthAndCodeOffset: %u 0x%X; Code 0x%X Code End 0x%X", code_length_delta, code_offset_delta, code_offset, code_offset + code_length_delta);
code_offset += code_length_delta; code_offset += code_length_delta;
} break; } break;
case CV_InlineBinaryAnnotation_ChangeColumnEnd: { case CV_InlineBinaryAnnotation_ChangeColumnEnd: {
U32 column_end = 0; U32 column_end = 0;
cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &column_end); cursor += cv_decode_inline_annot_u32(binary_annots, cursor, &column_end);
fprintf(stdout, "ChangeColumnEnd: %u", column_end); fprintf(stdout, "ChangeColumnEnd: %u", column_end);
} break; } break;
default: { default: {
fprintf(stdout, "Unknown Inline Binary Annotation Op Code: 0x%X", op); fprintf(stdout, "Unknown Inline Binary Annotation Op Code: 0x%X", op);
} break; } break;
} }
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
@@ -149,8 +147,8 @@ entry_point(CmdLine *cmdl)
Arena *arena = arena_alloc(); Arena *arena = arena_alloc();
B32 do_help = cmd_line_has_flag(cmdl, str8_lit("help")) || B32 do_help = cmd_line_has_flag(cmdl, str8_lit("help")) ||
cmd_line_has_flag(cmdl, str8_lit("h")) || cmd_line_has_flag(cmdl, str8_lit("h")) ||
(cmdl->inputs.node_count == 0 && cmdl->options.count == 0); (cmdl->inputs.node_count == 0 && cmdl->options.count == 0);
if (do_help) { if (do_help) {
fprintf(stdout, fprintf(stdout,
"Parse Inline Sites\n" "Parse Inline Sites\n"
-2
View File
@@ -14,7 +14,6 @@
//- rjf: [h] //- rjf: [h]
#include "base/base_inc.h" #include "base/base_inc.h"
#include "os/os_inc.h" #include "os/os_inc.h"
#include "path/path.h"
#include "hash_store/hash_store.h" #include "hash_store/hash_store.h"
#include "rdi_format/rdi_format_local.h" #include "rdi_format/rdi_format_local.h"
#include "regs/regs.h" #include "regs/regs.h"
@@ -24,7 +23,6 @@
//- rjf: [c] //- rjf: [c]
#include "base/base_inc.c" #include "base/base_inc.c"
#include "os/os_inc.c" #include "os/os_inc.c"
#include "path/path.c"
#include "hash_store/hash_store.c" #include "hash_store/hash_store.c"
#include "rdi_format/rdi_format_local.c" #include "rdi_format/rdi_format_local.c"
#include "regs/regs.c" #include "regs/regs.c"