Commit Graph
11 Commits
Author SHA1 Message Date
Ole André Vadla Ravnås fb7972e500 agent: Cap ITrace by captures, not invocations
Consume a capture index only when a trace is actually recorded,
so raising the limit or re-arming resumes capture instead of
staying stuck at the old invocation count.
2026-06-24 13:23:19 +02:00
Ole André Vadla Ravnås de4c469393 itrace: Give each trace its own buffer
Drop the shared-buffer rendezvous. Each trace now owns its
buffer, created before Stalker is armed and announced to Luma
via a token-keyed start/ack handshake. The ack carries the
drain verdict: Luma remaps the buffer out-of-process while the
agent blocks, so an early crash still yields data; on
task_for_pid denial (cached per target) the agent drains and
pushes chunks itself.

Fold all itrace into the tracer instrument. Function-arm traces
and thread traces share one Trace registry; thread traces become
threadTraces config entries on a find-or-created tracer instance.
Core no longer exports itrace, and the drain agent keys its
readers by session so concurrent traces stay separate.
2026-05-31 15:12:17 +02:00
Ole André Vadla Ravnås 2ea83c5cae tracer: Update hooks in place, don't re-attach
Re-attaching the interceptor on an itrace_arming change relocated
its own live redirect as the original prologue, so the trampoline
dereferenced the hooked function's bytes as a pointer and crashed.

A hook's target never moves via update, so reconcile in place when
code and state are unchanged. Snapshot the pristine prologue at
first attach so arming a live hook still has the original bytes.
2026-05-31 03:26:52 +02:00
Ole André Vadla Ravnås f3d35e9c32 tracer: Make hook state an enum
TracerConfig.Hook.State holds .enabled / .disabled, with
room for future cases (e.g. .muted: installed but no-op).
The mission tool's update_tracer_hook accepts a "state"
string; list/read return state as a string. The agent's
HookConfig wire format matches.
2026-05-11 21:47:47 +02:00
Ole André Vadla Ravnås 4a99bddc3e tracer: Remove unused isPinned hook field
Never read anywhere. Settable via update_tracer_hook, but
no UI, agent branch, or Swift consumer ever used the value.
2026-05-11 21:36:29 +02:00
Ole André Vadla Ravnås 38fb69fa1a agent: Cap itrace by bytes per invocation
ITraceArming gains maxBytesPerInvocation (default 1 MB).
The itrace core polls each open session every 100 ms,
streams the drained chunk back via itrace:chunk, and stops
the session as soon as cumulative bytes cross the
threshold. The tracer config UI grows a second stepper for
the byte budget alongside the invocation counter, and
update_tracer_hook accepts max_bytes_per_invocation in
itrace_arming.
2026-05-10 11:03:12 +02:00
Ole André Vadla Ravnås 804086184e agent: Arm itrace with a max-invocations cap
Replace TracerConfig.Hook.itraceEnabled (Bool) with
itraceArming (ITraceArming?) carrying maxInvocations.
The agent only opens an itrace session while
callIndex < maxInvocations, so a flooding hook can no
longer flood the trace store. The tracer config UI gets a
stepper for the cap and shows captured/cap live, derived
from saved ITrace rows. update_tracer_hook now takes
itrace_arming as an object {max_invocations} or null to
disarm.
2026-05-10 10:51:09 +02:00
Ole André Vadla Ravnås 425aa555eb core: Unify ITrace concept and wire session node
Drop the dual ITraceCaptureRecord/CapturedITrace types in favour of
a single ITrace covering both function-call and thread origins.
Promote itrace-capture from an instrument into a core service so
both origins share the same start/stop/drain machinery.

ProcessNode now keys pending traces by an opaque session id, hands
finalized data to a TraceStore, throttles running emits, drains
in-process when no system-drain is available, and skips the
Interceptor-trampoline trim for thread origin. ModuleDelta carries
incremental module updates.

LumaDocument grows sqliteURL and tracesDirectory accessors so the
project file can be a directory holding both the index and
per-trace blobs.
2026-05-07 16:39:47 +02:00
Ole André Vadla Ravnås 2d7cb2ed58 tracer: Support Java method hooks via the bridge
Add a javaMethod anchor kind and the matching java-method scope
so the tracer can target JVM methods. Resolution uses
Java.enumerateMethods through the bridge; attachment replaces
each method's implementation and restores it on detach.

The bridge isn't bundled into our agent, since only one copy
can live in a process at a time. Instead it's marked external
so frida-compile leaves the imports as runtime lookups, and our
agent does `await import("frida-java-bridge")` on demand. If
the user hasn't installed the package via the Packages panel,
we surface a message pointing them there.

To let frida-compile honour the external, LumaBundleCompiler
grew a --external <name> flag that forwards to
BuildOptions.externals. Both the Xcode Run Script phase and the
GTK Makefile now pass --package [email protected] (for
TypeScript types) alongside --external frida-java-bridge (so
the runtime code isn't embedded).

Java resolves to no native address, so ProcessNode.resolve and
the instruction annotation map throw / skip rather than trying
to materialise one. The seed code for new Java hooks matches
frida-tools' pattern: log args via JSON.stringify.
2026-04-16 14:33:59 +02:00
Ole André Vadla Ravnås 126843ce10 tracer: Support objc/swift/debug-symbol scopes
Extend the resolver path so traced targets can be described by more
anchor kinds than just module exports. The agent now exposes a
unified resolveTargets RPC on top of Frida's ApiResolver (module,
objc, swift) plus DebugSymbol.findFunctionsMatching, and a
lookupAnchorAddress entry point that resolves a stored anchor back
to an address.

AddressAnchor gains objcMethod, swiftFunc, and debugSymbol cases
with matching Codable round-tripping. ProcessNode.resolve routes
the new cases through the agent; the sync fast-path only handles
anchors that don't require the target runtime.

Both Add-Hook UIs keep using scope:"function" for now so behaviour
is unchanged; Stage 2 will expose a scope picker. The search-result
rows now carry a pre-resolved AddressAnchor instead of reconstructing
module+export pairs, and subtitle switches are exhaustive over the
new cases.
2026-04-16 12:46:07 +02:00
Ole André Vadla Ravnås 92357bfd80 Add LumaCore package + cross-platform scaffolding
Lay the groundwork for a GTK/Adwaita frontend by extracting
shared infrastructure into a LumaCore Swift package. Agent
sources and LumaBundleCompiler move to top-level locations
so both the Xcode project and SPM can reference them.

New structure:
- Package.swift: root manifest with LumaCore lib + compiler
- Sources/LumaCore/: engine, persistence, models, and
  platform-abstracted token store
- Sources/LumaBundleCompiler/: moved from LumaBundleCompiler/
- Agent/: moved from Luma/Agent/
- LumaGtk/: skeleton GTK app package
2026-04-06 18:59:29 +02:00