Introduce a unified target hook command system for LLDB that handles
multiple target lifecycle events (module load, module unload, process
stop) through a single Hook class.
The existing target stop-hook commands remain unchanged for now, meaning
stop-hooks can now be created through either target stop-hook add or
target hook add -S.
A future follow-up can alias target stop-hook to the unified system to
consolidate the two paths.
New commands:
- target hook add [-o cmd] [-P class] [-u] [-S] - create a hook (fires
on module load by default, optionally on unload/stop)
- target hook add-filter [filter-opts] <hook-id> - attach stop-event
filters (shlib, function, file/line, thread) to an existing hook
- target hook list / delete / enable / disable - manage hooks
- target hook {enable,disable} {module-loaded|module-unloaded|stop-hook}
<id> - per-event toggling
top-event filter options live on a separate add-filter command rather
than on target hook add, keeping the add command clean and making the
system safe for filters on other event types.
Ran the tests + Made sure stop tests are passing as well.
---------
Co-authored-by: Bar Soloveychik <barsolo@fb.com>
11 lines
314 B
Plaintext
11 lines
314 B
Plaintext
# Test that module hooks fire when modules are loaded.
|
|
#
|
|
# RUN: %clang_host -g %S/Inputs/main.c -o %t
|
|
# RUN: %lldb -b -o 'file %t' \
|
|
# RUN: -o 'target hook add -L -o "script print(\"HOOK_FIRED\")"' \
|
|
# RUN: -o 'target modules add %t' \
|
|
# RUN: 2>&1 | FileCheck %s
|
|
|
|
# CHECK: Hook #1 added.
|
|
# CHECK: HOOK_FIRED
|