pdb -> rdi: more gracefully handle ..s in file paths when building source line maps, normalized file paths, and path tree

This commit is contained in:
Ryan Fleury
2025-05-07 14:58:23 -07:00
parent 4f980c4820
commit a4367e02f2
2 changed files with 120 additions and 79 deletions
+39 -1
View File
@@ -1921,6 +1921,25 @@ rdim_bake_path_node_from_string(RDIM_BakePathTree *tree, RDIM_String8 string)
} }
} }
// rjf: .. -> go up
if(sub_dir.RDIM_String8_SizeMember == 2 &&
sub_dir.RDIM_String8_BaseMember[0] == '.' &&
sub_dir.RDIM_String8_BaseMember[1] == '.')
{
sub_dir_node = node->parent;
if(sub_dir_node == 0)
{
sub_dir_node = &tree->root;
}
}
// rjf: . -> stay here
else if(sub_dir.RDIM_String8_SizeMember == 1 &&
sub_dir.RDIM_String8_BaseMember[0] == '.')
{
sub_dir_node = node;
}
// rjf: descend to child // rjf: descend to child
node = sub_dir_node; node = sub_dir_node;
} }
@@ -1975,8 +1994,27 @@ rdim_bake_path_tree_insert(RDIM_Arena *arena, RDIM_BakePathTree *tree, RDIM_Stri
} }
} }
// rjf: no child -> make one // rjf: .. -> go up
if(sub_dir.RDIM_String8_SizeMember == 2 &&
sub_dir.RDIM_String8_BaseMember[0] == '.' &&
sub_dir.RDIM_String8_BaseMember[1] == '.')
{
sub_dir_node = node->parent;
if(sub_dir_node == 0) if(sub_dir_node == 0)
{
sub_dir_node = &tree->root;
}
}
// rjf: . -> stay here
else if(sub_dir.RDIM_String8_SizeMember == 1 &&
sub_dir.RDIM_String8_BaseMember[0] == '.')
{
sub_dir_node = node;
}
// rjf: no child -> make one
else if(sub_dir_node == 0)
{ {
sub_dir_node = rdim_push_array(arena, RDIM_BakePathNode, 1); sub_dir_node = rdim_push_array(arena, RDIM_BakePathNode, 1);
RDIM_SLLQueuePush_N(tree->first, tree->last, sub_dir_node, next_order); RDIM_SLLQueuePush_N(tree->first, tree->last, sub_dir_node, next_order);
+3
View File
@@ -641,6 +641,7 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
// rjf: file name -> normalized file path // rjf: file name -> normalized file path
String8 file_path = lines->file_name; String8 file_path = lines->file_name;
String8 file_path_normalized = lower_from_str8(scratch.arena, str8_skip_chop_whitespace(file_path)); String8 file_path_normalized = lower_from_str8(scratch.arena, str8_skip_chop_whitespace(file_path));
{
for(U64 idx = 0; idx < file_path_normalized.size; idx += 1) for(U64 idx = 0; idx < file_path_normalized.size; idx += 1)
{ {
if(file_path_normalized.str[idx] == '\\') if(file_path_normalized.str[idx] == '\\')
@@ -648,6 +649,8 @@ ASYNC_WORK_DEF(p2r_units_convert_work)
file_path_normalized.str[idx] = '/'; file_path_normalized.str[idx] = '/';
} }
} }
file_path_normalized = path_normalized_from_string(scratch.arena, file_path_normalized);
}
// rjf: normalized file path -> source file node // rjf: normalized file path -> source file node
U64 file_path_normalized_hash = rdi_hash(file_path_normalized.str, file_path_normalized.size); U64 file_path_normalized_hash = rdi_hash(file_path_normalized.str, file_path_normalized.size);