Skip to content

Commit

Permalink
barebone: Factor out uint64 helpers to base
Browse files Browse the repository at this point in the history
Co-authored-by: Håvard Sørbø <[email protected]>
  • Loading branch information
oleavr and hsorbo committed May 14, 2024
1 parent 868483a commit 29a0e9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
13 changes: 13 additions & 0 deletions lib/base/session.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2077,4 +2077,17 @@ namespace Frida {
return klass.get_value (val).value_nick;
}
}

namespace Numeric {
public uint uint64_hash (uint64? val) {
uint64 v = val;
return (uint) ((v >> 32) ^ (v & 0xffffffffU));
}

public bool uint64_equal (uint64? val_a, uint64? val_b) {
uint64 a = val_a;
uint64 b = val_b;
return a == b;
}
}
}
11 changes: 0 additions & 11 deletions src/barebone/barebone-host-session.vala
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,4 @@ namespace Frida {
private static void throw_not_supported () throws Error {
throw new Error.NOT_SUPPORTED ("Not yet supported");
}

private static uint uint64_hash (uint64? val) {
uint64 v = val;
return (uint) ((v >> 32) ^ (v & 0xffffffffU));
}

private static bool uint64_equal (uint64? val_a, uint64? val_b) {
uint64 a = val_a;
uint64 b = val_b;
return a == b;
}
}
7 changes: 4 additions & 3 deletions src/barebone/interceptor.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ namespace Frida.Barebone {
private GDB.Client gdb;

private Gee.Map<uint64?, BreakpointEntry> breakpoint_entries =
new Gee.HashMap<uint64?, BreakpointEntry> (uint64_hash, uint64_equal);
new Gee.HashMap<uint64?, BreakpointEntry> (Numeric.uint64_hash, Numeric.uint64_equal);
private Gee.Map<string, CallStack> call_stacks = new Gee.HashMap<string, CallStack> ();
private Gee.MultiMap<uint64?, CallStack> pending_returns =
new Gee.HashMultiMap<uint64?, CallStack> (uint64_hash, uint64_equal);
new Gee.HashMultiMap<uint64?, CallStack> (Numeric.uint64_hash, Numeric.uint64_equal);

private Gee.Map<uint64?, InlineHook> inline_hooks = new Gee.HashMap<uint64?, InlineHook> (uint64_hash, uint64_equal);
private Gee.Map<uint64?, InlineHook> inline_hooks =
new Gee.HashMap<uint64?, InlineHook> (Numeric.uint64_hash, Numeric.uint64_equal);

private Cancellable io_cancellable = new Cancellable ();

Expand Down

0 comments on commit 29a0e9a

Please sign in to comment.