Trigger breakpoints also when the CPU is not running
This commit is contained in:
parent
7dfe827854
commit
056b293f6a
@ -87,12 +87,18 @@ void libafl_load_qemu_snapshot(char *name)
|
|||||||
|
|
||||||
#define EXCP_LIBAFL_BP 0xf4775747
|
#define EXCP_LIBAFL_BP 0xf4775747
|
||||||
|
|
||||||
|
int libafl_qemu_break_asap = 0;
|
||||||
|
|
||||||
void libafl_qemu_trigger_breakpoint(CPUState* cpu);
|
void libafl_qemu_trigger_breakpoint(CPUState* cpu);
|
||||||
|
|
||||||
void libafl_qemu_trigger_breakpoint(CPUState* cpu)
|
void libafl_qemu_trigger_breakpoint(CPUState* cpu)
|
||||||
{
|
{
|
||||||
cpu->exception_index = EXCP_LIBAFL_BP;
|
if (cpu->running) {
|
||||||
cpu_loop_exit(cpu);
|
cpu->exception_index = EXCP_LIBAFL_BP;
|
||||||
|
cpu_loop_exit(cpu);
|
||||||
|
} else {
|
||||||
|
libafl_qemu_break_asap = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HELPER(libafl_qemu_handle_breakpoint)(CPUArchState *env)
|
void HELPER(libafl_qemu_handle_breakpoint)(CPUArchState *env)
|
||||||
|
@ -82,6 +82,13 @@ void cpu_loop(CPUARMState *env)
|
|||||||
abi_long ret;
|
abi_long ret;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
|
//// --- Begin LibAFL code ---
|
||||||
|
|
||||||
|
if (libafl_qemu_break_asap) return;
|
||||||
|
|
||||||
|
//// --- End LibAFL code ---
|
||||||
|
|
||||||
cpu_exec_start(cs);
|
cpu_exec_start(cs);
|
||||||
trapnr = cpu_exec(cs);
|
trapnr = cpu_exec(cs);
|
||||||
cpu_exec_end(cs);
|
cpu_exec_end(cs);
|
||||||
|
@ -319,6 +319,13 @@ void cpu_loop(CPUARMState *env)
|
|||||||
abi_ulong ret;
|
abi_ulong ret;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
|
||||||
|
//// --- Begin LibAFL code ---
|
||||||
|
|
||||||
|
if (libafl_qemu_break_asap) return;
|
||||||
|
|
||||||
|
//// --- End LibAFL code ---
|
||||||
|
|
||||||
cpu_exec_start(cs);
|
cpu_exec_start(cs);
|
||||||
trapnr = cpu_exec(cs);
|
trapnr = cpu_exec(cs);
|
||||||
cpu_exec_end(cs);
|
cpu_exec_end(cs);
|
||||||
|
@ -23,6 +23,12 @@
|
|||||||
#include "exec/log.h"
|
#include "exec/log.h"
|
||||||
#include "special-errno.h"
|
#include "special-errno.h"
|
||||||
|
|
||||||
|
//// --- Begin LibAFL code ---
|
||||||
|
|
||||||
|
extern int libafl_qemu_break_asap;
|
||||||
|
|
||||||
|
//// --- End LibAFL code ---
|
||||||
|
|
||||||
#define EXCP_DUMP(env, fmt, ...) \
|
#define EXCP_DUMP(env, fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
CPUState *cs = env_cpu(env); \
|
CPUState *cs = env_cpu(env); \
|
||||||
|
@ -205,6 +205,13 @@ void cpu_loop(CPUX86State *env)
|
|||||||
abi_ulong ret;
|
abi_ulong ret;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
|
||||||
|
//// --- Begin LibAFL code ---
|
||||||
|
|
||||||
|
if (libafl_qemu_break_asap) return;
|
||||||
|
|
||||||
|
//// --- End LibAFL code ---
|
||||||
|
|
||||||
cpu_exec_start(cs);
|
cpu_exec_start(cs);
|
||||||
trapnr = cpu_exec(cs);
|
trapnr = cpu_exec(cs);
|
||||||
cpu_exec_end(cs);
|
cpu_exec_end(cs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user