From 1ecd970f3116fc0bd83680046e498db7336e3610 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Thu, 22 Jan 2026 13:30:03 -0800 Subject: [PATCH] STAP copy functions --- src/stap/stap_parse.c | 19 +++++++++++++++++++ src/stap/stap_parse.h | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/stap/stap_parse.c b/src/stap/stap_parse.c index ae9302b0..8bb048de 100644 --- a/src/stap/stap_parse.c +++ b/src/stap/stap_parse.c @@ -436,3 +436,22 @@ stap_read_arg_f(STAP_Arg arg, Arch arch, void *reg_block, STAP_MemoryRead *memor return stap_read_arg(arg, arch, reg_block, memory_read, memory_read_ctx, f_out); } +internal STAP_Arg +stap_arg_copy(STAP_Arg *src) +{ + return *src; +} + +internal STAP_ArgArray +stap_arg_array_copy(Arena *arena, STAP_ArgArray arr) +{ + STAP_ArgArray result = {0}; + result.count = arr.count; + result.v = push_array(arena, STAP_Arg, arr.count); + for EachIndex(arg_idx, arr.count) + { + result.v[arg_idx] = stap_arg_copy(&arr.v[arg_idx]); + } + return result; +} + diff --git a/src/stap/stap_parse.h b/src/stap/stap_parse.h index 43101a36..8d5164ca 100644 --- a/src/stap/stap_parse.h +++ b/src/stap/stap_parse.h @@ -32,7 +32,7 @@ typedef struct STAP_Arg B8 is_alias; } reg; struct { - S64 disp; + S64 disp; struct { U32 reg_code; B8 is_alias; @@ -41,7 +41,7 @@ typedef struct STAP_Arg U32 reg_code; B8 is_alias; } index; - U64 scale; + U64 scale; } memory_ref; }; } STAP_Arg; @@ -78,5 +78,8 @@ internal B32 stap_read_arg_u(STAP_Arg arg, Arch arch, void *reg_block, STAP_Memo internal B32 stap_read_arg_s(STAP_Arg arg, Arch arch, void *reg_block, STAP_MemoryRead *memory_read, void *memory_read_ctx, S64 *s_out); internal B32 stap_read_arg_f(STAP_Arg arg, Arch arch, void *reg_block, STAP_MemoryRead *memory_read, void *memory_read_ctx, F64 *f_out); +internal STAP_Arg stap_arg_copy(STAP_Arg *src); +internal STAP_ArgArray stap_arg_array_copy(Arena *arena, STAP_ArgArray arr); + #endif // STAP_PARSE_H