Browse Source

Change layout of `Frame_Location`

gingerBill 1 year ago
parent
commit
0fa269811a
2 changed files with 14 additions and 10 deletions
  1. 8 4
      core/debug/trace/trace.odin
  2. 6 6
      core/debug/trace/trace_windows.odin

+ 8 - 4
core/debug/trace/trace.odin

@@ -6,11 +6,15 @@ import "base:runtime"
 Frame :: distinct uintptr
 MAX_FRAMES :: 64
 
-Frame_Location :: runtime.Source_Code_Location
+Frame_Location :: struct {
+	using loc: runtime.Source_Code_Location,
+	allocator: runtime.Allocator,
+}
 
-delete_frame_location :: proc(loc: Frame_Location, allocator: runtime.Allocator) -> runtime.Allocator_Error {
-	delete(loc.procedure, allocator) or_return
-	delete(loc.file_path, allocator) or_return
+delete_frame_location :: proc(fl: Frame_Location) -> runtime.Allocator_Error {
+	allocator := fl.allocator
+	delete(fl.loc.procedure, allocator) or_return
+	delete(fl.loc.file_path, allocator) or_return
 	return nil
 }
 

+ 6 - 6
core/debug/trace/trace_windows.odin

@@ -41,7 +41,7 @@ _frames :: proc(ctx: ^Context, skip: uint, allocator: runtime.Allocator) -> []Fr
 }
 
 
-_resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (result: runtime.Source_Code_Location) {
+_resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (fl: Frame_Location) {
 	intrinsics.atomic_store(&ctx.in_resolve, true)
 	defer intrinsics.atomic_store(&ctx.in_resolve, false)
 
@@ -54,17 +54,17 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (
 	symbol.SizeOfStruct = size_of(symbol)
 	symbol.MaxNameLen = 255
 	if win32.SymFromAddrW(ctx.impl.hProcess, win32.DWORD64(frame), &{}, symbol) {
-		result.procedure, _ = win32.wstring_to_utf8(&symbol.Name[0], -1, allocator)
+		fl.procedure, _ = win32.wstring_to_utf8(&symbol.Name[0], -1, allocator)
 	} else {
-		result.procedure = fmt.aprintf("(procedure: 0x%x)", frame, allocator=allocator)
+		fl.procedure = fmt.aprintf("(procedure: 0x%x)", frame, allocator=allocator)
 	}
 
 	line: win32.IMAGEHLP_LINE64
 	line.SizeOfStruct = size_of(line)
 	if win32.SymGetLineFromAddrW64(ctx.impl.hProcess, win32.DWORD64(frame), &{}, &line) {
-		result.file_path, _ = win32.wstring_to_utf8(line.FileName, -1, allocator)
-		result.line = i32(line.LineNumber)
+		fl.file_path, _ = win32.wstring_to_utf8(line.FileName, -1, allocator)
+		fl.line = i32(line.LineNumber)
 	}
 
-	return result
+	return
 }