diff options
author | eutarass | 2010-05-21 22:29:17 +0000 |
---|---|---|
committer | eutarass | 2010-05-21 22:29:17 +0000 |
commit | fd7104ccee41621c3a545ea3034c6dcdc0f13843 (patch) | |
tree | e7a3b2f43663fb3f72936e8d40adc2e2ee3a9db0 | |
parent | 2cc1f63c7b44806808b5790379f2b8f3f3dd180b (diff) | |
download | org.eclipse.tcf.agent-fd7104ccee41621c3a545ea3034c6dcdc0f13843.tar.gz org.eclipse.tcf.agent-fd7104ccee41621c3a545ea3034c6dcdc0f13843.tar.xz org.eclipse.tcf.agent-fd7104ccee41621c3a545ea3034c6dcdc0f13843.zip |
TCF Agent: moved CPU dependent code from framework/cpudefs.c to machine/cpudefs-ext.h to allow client extensions of the code.
-rw-r--r-- | agent.vcproj | 4 | ||||
-rw-r--r-- | framework/cpudefs.c | 120 | ||||
-rw-r--r-- | framework/cpudefs.h | 7 | ||||
-rw-r--r-- | framework/mdep.h | 2 | ||||
-rw-r--r-- | machine/cpudefs-ext.h | 132 | ||||
-rw-r--r-- | server/machine/cpudefs-ext.h | 75 | ||||
-rw-r--r-- | server/server.vcproj | 16 | ||||
-rw-r--r-- | server/services/context-proxy.c | 67 | ||||
-rw-r--r-- | server/services/context-proxy.h | 5 | ||||
-rw-r--r-- | services/breakpoints.c | 34 | ||||
-rw-r--r-- | services/diagnostics.c | 1 | ||||
-rw-r--r-- | services/dwarfframe.h | 1 | ||||
-rw-r--r-- | system/Darwin/context-darwin.c | 13 | ||||
-rw-r--r-- | system/FreeBSD/context-freebsd.c | 13 | ||||
-rw-r--r-- | system/GNU/Linux/context-linux.c | 12 | ||||
-rw-r--r-- | system/Windows/context-win32.c | 6 |
16 files changed, 273 insertions, 235 deletions
diff --git a/agent.vcproj b/agent.vcproj index b9f029d7..5cafae5a 100644 --- a/agent.vcproj +++ b/agent.vcproj @@ -954,6 +954,10 @@ <Filter
Name="machine"
>
+ <File
+ RelativePath=".\machine\cpudefs-ext.h"
+ >
+ </File>
<Filter
Name="x86_64"
>
diff --git a/framework/cpudefs.c b/framework/cpudefs.c index a16ae085..2955f3af 100644 --- a/framework/cpudefs.c +++ b/framework/cpudefs.c @@ -29,125 +29,7 @@ #include <framework/myalloc.h> #include <framework/exceptions.h> #include <services/symbols.h> - -#if ENABLE_ContextProxy - -/* Register definitions are provided by context proxy */ - -#else - -#include <cpudefs-mdep.h> - -struct RegisterData { - REG_SET data; - REG_SET mask; -}; - -RegisterDefinition * get_reg_definitions(Context * ctx) { - return regs_index; -} - -size_t get_break_size(void) { - return sizeof(BREAK_INST); -} - -static RegisterDefinition * get_reg_by_dwarf_id(unsigned id) { - static RegisterDefinition ** map = NULL; - static unsigned map_length = 0; - - if (map == NULL) { - RegisterDefinition * r; - for (r = get_reg_definitions(NULL); r->name != NULL; r++) { - if (r->dwarf_id >= (int)map_length) map_length = r->dwarf_id + 1; - } - map = (RegisterDefinition **)loc_alloc_zero(sizeof(RegisterDefinition *) * map_length); - for (r = get_reg_definitions(NULL); r->name != NULL; r++) { - if (r->dwarf_id >= 0) map[r->dwarf_id] = r; - } - } - return id < map_length ? map[id] : NULL; -} - -static RegisterDefinition * get_reg_by_eh_frame_id(unsigned id) { - static RegisterDefinition ** map = NULL; - static unsigned map_length = 0; - - if (map == NULL) { - RegisterDefinition * r; - for (r = get_reg_definitions(NULL); r->name != NULL; r++) { - if (r->eh_frame_id >= (int)map_length) map_length = r->eh_frame_id + 1; - } - map = (RegisterDefinition **)loc_alloc_zero(sizeof(RegisterDefinition *) * map_length); - for (r = get_reg_definitions(NULL); r->name != NULL; r++) { - if (r->eh_frame_id >= 0) map[r->eh_frame_id] = r; - } - } - return id < map_length ? map[id] : NULL; -} - -RegisterDefinition * get_reg_by_id(Context * ctx, unsigned id, unsigned munbering_convention) { - switch (munbering_convention) { - case REGNUM_DWARF: return get_reg_by_dwarf_id(id); - case REGNUM_EH_FRAME: return get_reg_by_eh_frame_id(id); - } - return NULL; -} - -int read_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { - if (reg_def != NULL && frame != NULL) { - if (frame->is_top_frame) { - return context_read_reg(frame->ctx, reg_def, offs, size, buf); - } - if (frame->regs != NULL) { - size_t i; - uint8_t * r_addr = (uint8_t *)&frame->regs->data + reg_def->offset; - uint8_t * m_addr = (uint8_t *)&frame->regs->mask + reg_def->offset; - for (i = 0; i < size; i++) { - if (m_addr[offs + i] != 0xff) { - errno = ERR_INV_CONTEXT; - return -1; - } - } - assert(reg_def->offset + reg_def->size <= sizeof(REG_SET)); - if (offs + size > reg_def->size) { - errno = ERR_INV_DATA_SIZE; - return -1; - } - memcpy(buf, r_addr + offs, size); - return 0; - } - } - errno = ERR_INV_CONTEXT; - return -1; -} - -int write_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { - if (reg_def != NULL && frame != NULL) { - if (frame->is_top_frame) { - return context_write_reg(frame->ctx, reg_def, offs, size, buf); - } - if (frame->regs == NULL && context_has_state(frame->ctx)) { - frame->regs = (RegisterData *)loc_alloc_zero(sizeof(RegisterData)); - } - if (frame->regs != NULL) { - uint8_t * r_addr = (uint8_t *)&frame->regs->data + reg_def->offset; - uint8_t * m_addr = (uint8_t *)&frame->regs->mask + reg_def->offset; - - assert(reg_def->offset + reg_def->size <= sizeof(REG_SET)); - if (offs + size > reg_def->size) { - errno = ERR_INV_DATA_SIZE; - return -1; - } - memcpy(r_addr + offs, buf, size); - memset(m_addr + offs, 0xff, size); - return 0; - } - } - errno = ERR_INV_CONTEXT; - return -1; -} - -#endif /* !ENABLE_ContextProxy */ +#include <machine/cpudefs-ext.h> int read_reg_value(StackFrame * frame, RegisterDefinition * reg_def, uint64_t * value) { uint8_t buf[8]; diff --git a/framework/cpudefs.h b/framework/cpudefs.h index d59efb2f..a006224a 100644 --- a/framework/cpudefs.h +++ b/framework/cpudefs.h @@ -134,11 +134,8 @@ extern char * register2id(Context * ctx, int frame, RegisterDefinition * reg); /* Get register for TCF ID */ extern int id2register(const char * id, Context ** ctx, int * frame, RegisterDefinition ** reg_def); -#if !defined(_WRS_KERNEL) -extern unsigned char BREAK_INST[]; /* breakpoint instruction */ -#define BREAK_SIZE get_break_size() /* breakpoint instruction size */ -extern size_t get_break_size(void); -#endif +/* Get breakpoint instruction code and size */ +extern uint8_t * get_break_instruction(Context * ctx, size_t * size); /* * Retrieve stack frame information by examining stack data in memory. diff --git a/framework/mdep.h b/framework/mdep.h index 7db4c21f..1e419a57 100644 --- a/framework/mdep.h +++ b/framework/mdep.h @@ -454,7 +454,7 @@ extern int tkill(pid_t pid, int signal); #endif -#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(__VXWORKS__) extern size_t strlcpy(char * dst, const char * src, size_t size); extern size_t strlcat(char * dst, const char * src, size_t size); #endif diff --git a/machine/cpudefs-ext.h b/machine/cpudefs-ext.h new file mode 100644 index 00000000..cd33fbeb --- /dev/null +++ b/machine/cpudefs-ext.h @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +/* + * This file provides debug context register definitions and lookup functions. + * It is included into cpudefs.c. + * The code assumes that all contexts share same register definitions. + * If it is not the case, this file needs to be substituted with alternative implementation. + */ + +#include <cpudefs-mdep.h> + +struct RegisterData { + REG_SET data; + REG_SET mask; +}; + +RegisterDefinition * get_reg_definitions(Context * ctx) { + return regs_index; +} + +uint8_t * get_break_instruction(Context * ctx, size_t * size) { + *size = sizeof(BREAK_INST); + return BREAK_INST; +} + +static RegisterDefinition * get_reg_by_dwarf_id(unsigned id) { + static RegisterDefinition ** map = NULL; + static unsigned map_length = 0; + + if (map == NULL) { + RegisterDefinition * r; + for (r = regs_index; r->name != NULL; r++) { + if (r->dwarf_id >= (int)map_length) map_length = r->dwarf_id + 1; + } + map = (RegisterDefinition **)loc_alloc_zero(sizeof(RegisterDefinition *) * map_length); + for (r = regs_index; r->name != NULL; r++) { + if (r->dwarf_id >= 0) map[r->dwarf_id] = r; + } + } + return id < map_length ? map[id] : NULL; +} + +static RegisterDefinition * get_reg_by_eh_frame_id(unsigned id) { + static RegisterDefinition ** map = NULL; + static unsigned map_length = 0; + + if (map == NULL) { + RegisterDefinition * r; + for (r = regs_index; r->name != NULL; r++) { + if (r->eh_frame_id >= (int)map_length) map_length = r->eh_frame_id + 1; + } + map = (RegisterDefinition **)loc_alloc_zero(sizeof(RegisterDefinition *) * map_length); + for (r = regs_index; r->name != NULL; r++) { + if (r->eh_frame_id >= 0) map[r->eh_frame_id] = r; + } + } + return id < map_length ? map[id] : NULL; +} + +RegisterDefinition * get_reg_by_id(Context * ctx, unsigned id, unsigned munbering_convention) { + switch (munbering_convention) { + case REGNUM_DWARF: return get_reg_by_dwarf_id(id); + case REGNUM_EH_FRAME: return get_reg_by_eh_frame_id(id); + } + return NULL; +} + +int read_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { + if (reg_def != NULL && frame != NULL) { + if (frame->is_top_frame) { + return context_read_reg(frame->ctx, reg_def, offs, size, buf); + } + if (frame->regs != NULL) { + size_t i; + uint8_t * r_addr = (uint8_t *)&frame->regs->data + reg_def->offset; + uint8_t * m_addr = (uint8_t *)&frame->regs->mask + reg_def->offset; + for (i = 0; i < size; i++) { + if (m_addr[offs + i] != 0xff) { + errno = ERR_INV_CONTEXT; + return -1; + } + } + assert(reg_def->offset + reg_def->size <= sizeof(REG_SET)); + if (offs + size > reg_def->size) { + errno = ERR_INV_DATA_SIZE; + return -1; + } + memcpy(buf, r_addr + offs, size); + return 0; + } + } + errno = ERR_INV_CONTEXT; + return -1; +} + +int write_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { + if (reg_def != NULL && frame != NULL) { + if (frame->is_top_frame) { + return context_write_reg(frame->ctx, reg_def, offs, size, buf); + } + if (frame->regs == NULL && context_has_state(frame->ctx)) { + frame->regs = (RegisterData *)loc_alloc_zero(sizeof(RegisterData)); + } + if (frame->regs != NULL) { + uint8_t * r_addr = (uint8_t *)&frame->regs->data + reg_def->offset; + uint8_t * m_addr = (uint8_t *)&frame->regs->mask + reg_def->offset; + + assert(reg_def->offset + reg_def->size <= sizeof(REG_SET)); + if (offs + size > reg_def->size) { + errno = ERR_INV_DATA_SIZE; + return -1; + } + memcpy(r_addr + offs, buf, size); + memset(m_addr + offs, 0xff, size); + return 0; + } + } + errno = ERR_INV_CONTEXT; + return -1; +} diff --git a/server/machine/cpudefs-ext.h b/server/machine/cpudefs-ext.h new file mode 100644 index 00000000..75aa2f00 --- /dev/null +++ b/server/machine/cpudefs-ext.h @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +#include <services/context-proxy.h> + +RegisterDefinition * get_reg_by_id(Context * ctx, unsigned id, unsigned munbering_convention) { + RegisterDefinition * defs = get_reg_definitions(ctx); + while (defs != NULL && defs->name != NULL) { + switch (munbering_convention) { + case REGNUM_DWARF: + if (defs->dwarf_id == (int)id) return defs; + break; + case REGNUM_EH_FRAME: + if (defs->eh_frame_id == (int)id) return defs; + break; + } + defs++; + } + return NULL; +} + +int read_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { + if (reg_def == NULL || frame == NULL) { + errno = ERR_INV_CONTEXT; + return -1; + } + else { + size_t i; + uint8_t * r_addr = frame->regs->data + reg_def->offset; + uint8_t * m_addr = frame->regs->mask + reg_def->offset; + for (i = 0; i < size; i++) { + if (m_addr[offs + i] != 0xff) { + errno = ERR_INV_CONTEXT; + return -1; + } + } + if (offs + size > reg_def->size) { + errno = ERR_INV_DATA_SIZE; + return -1; + } + memcpy(buf, r_addr + offs, size); + } + return 0; +} + +int write_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { + if (reg_def == NULL || frame == NULL) { + errno = ERR_INV_CONTEXT; + return -1; + } + else { + uint8_t * r_addr = frame->regs->data + reg_def->offset; + uint8_t * m_addr = frame->regs->mask + reg_def->offset; + + if (offs + size > reg_def->size) { + errno = ERR_INV_DATA_SIZE; + return -1; + } + memcpy(r_addr + offs, buf, size); + memset(m_addr + offs, 0xff, size); + } + return 0; +} + diff --git a/server/server.vcproj b/server/server.vcproj index 73851132..3cfcd842 100644 --- a/server/server.vcproj +++ b/server/server.vcproj @@ -279,14 +279,6 @@ >
</File>
<File
- RelativePath="..\agent\services\stacktrace.c"
- >
- </File>
- <File
- RelativePath="..\agent\services\stacktrace.h"
- >
- </File>
- <File
RelativePath="..\agent\services\symbols.c"
>
</File>
@@ -503,6 +495,14 @@ >
</File>
</Filter>
+ <Filter
+ Name="machine"
+ >
+ <File
+ RelativePath=".\machine\cpudefs-ext.h"
+ >
+ </File>
+ </Filter>
<File
RelativePath=".\config.h"
>
diff --git a/server/services/context-proxy.c b/server/services/context-proxy.c index 8cac2292..17ab135d 100644 --- a/server/services/context-proxy.c +++ b/server/services/context-proxy.c @@ -43,11 +43,6 @@ typedef struct RegisterProps RegisterProps; #define CTX_ID_HASH_SIZE 101 -struct RegisterData { - uint8_t * data; - uint8_t * mask; -}; - struct ContextCache { char id[256]; char parent_id[256]; @@ -1164,25 +1159,6 @@ RegisterDefinition * get_PC_definition(Context * ctx) { return cache->pc_def; } -RegisterDefinition * get_reg_by_id(Context * ctx, unsigned id, unsigned munbering_convention) { - RegisterDefinition * defs; - ContextCache * cache = *EXT(ctx); - check_registers_cache(cache); - defs = cache->reg_defs; - while (defs != NULL && defs->name != NULL) { - switch (munbering_convention) { - case REGNUM_DWARF: - if (defs->dwarf_id == (int)id) return defs; - break; - case REGNUM_EH_FRAME: - if (defs->eh_frame_id == (int)id) return defs; - break; - } - defs++; - } - return NULL; -} - static void validate_reg_values_cache(Channel * c, void * args, int error) { StackFrameCache * s = (StackFrameCache *)args; Context * ctx = s->ctx->ctx; @@ -1419,49 +1395,6 @@ int get_top_frame(Context * ctx) { return STACK_TOP_FRAME; } -int read_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { - if (reg_def == NULL || frame == NULL) { - errno = ERR_INV_CONTEXT; - return -1; - } - else { - size_t i; - uint8_t * r_addr = frame->regs->data + reg_def->offset; - uint8_t * m_addr = frame->regs->mask + reg_def->offset; - for (i = 0; i < size; i++) { - if (m_addr[offs + i] != 0xff) { - errno = ERR_INV_CONTEXT; - return -1; - } - } - if (offs + size > reg_def->size) { - errno = ERR_INV_DATA_SIZE; - return -1; - } - memcpy(buf, r_addr + offs, size); - } - return 0; -} - -int write_reg_bytes(StackFrame * frame, RegisterDefinition * reg_def, unsigned offs, unsigned size, uint8_t * buf) { - if (reg_def == NULL || frame == NULL) { - errno = ERR_INV_CONTEXT; - return -1; - } - else { - uint8_t * r_addr = frame->regs->data + reg_def->offset; - uint8_t * m_addr = frame->regs->mask + reg_def->offset; - - if (offs + size > reg_def->size) { - errno = ERR_INV_DATA_SIZE; - return -1; - } - memcpy(r_addr + offs, buf, size); - memset(m_addr + offs, 0xff, size); - } - return 0; -} - static void channel_close_listener(Channel * c) { LINK * l = NULL; diff --git a/server/services/context-proxy.h b/server/services/context-proxy.h index fcd9f00d..c1abfa5f 100644 --- a/server/services/context-proxy.h +++ b/server/services/context-proxy.h @@ -22,6 +22,11 @@ #include <config.h> #include <framework/channel.h> +struct RegisterData { + uint8_t * data; + uint8_t * mask; +}; + extern void create_context_proxy(Channel * host, Channel * target); #endif /* D_context_proxy */ diff --git a/services/breakpoints.c b/services/breakpoints.c index 4c7bdcb2..7fc8f23e 100644 --- a/services/breakpoints.c +++ b/services/breakpoints.c @@ -110,6 +110,7 @@ struct BreakInstruction { VXDBG_BP_ID vxdbg_id; #else char saved_code[16]; + size_t saved_size; #endif ErrorReport * error; int stepping_over_bp; @@ -240,16 +241,17 @@ static void plant_instruction(BreakInstruction * bi) { assert(bi->error != NULL); } #else - assert(sizeof(bi->saved_code) >= BREAK_SIZE); if (select_valid_context(&bi->ctx) < 0) { bi->error = get_error_report(errno); } else { + uint8_t * break_inst = get_break_instruction(bi->ctx, &bi->saved_size); + assert(sizeof(bi->saved_code) >= bi->saved_size); planting_instruction = 1; - if (context_read_mem(bi->ctx, bi->address, bi->saved_code, BREAK_SIZE) < 0) { + if (context_read_mem(bi->ctx, bi->address, bi->saved_code, bi->saved_size) < 0) { bi->error = get_error_report(errno); } - else if (context_write_mem(bi->ctx, bi->address, &BREAK_INST, BREAK_SIZE) < 0) { + else if (context_write_mem(bi->ctx, bi->address, break_inst, bi->saved_size) < 0) { bi->error = get_error_report(errno); } planting_instruction = 0; @@ -288,7 +290,7 @@ static void remove_instruction(BreakInstruction * bi) { #else if (select_valid_context(&bi->ctx) == 0) { planting_instruction = 1; - if (context_write_mem(bi->ctx, bi->address, bi->saved_code, BREAK_SIZE) < 0) { + if (context_write_mem(bi->ctx, bi->address, bi->saved_code, bi->saved_size) < 0) { bi->error = get_error_report(errno); } planting_instruction = 0; @@ -363,7 +365,7 @@ static void flush_instructions(void) { void check_breakpoints_on_memory_read(Context * ctx, ContextAddress address, void * p, size_t size) { #if !defined(_WRS_KERNEL) if (!planting_instruction) { - int i; + size_t i; char * buf = (char *)p; LINK * l = instructions.next; while (l != &instructions) { @@ -371,9 +373,9 @@ void check_breakpoints_on_memory_read(Context * ctx, ContextAddress address, voi l = l->next; if (!bi->planted) continue; if (bi->ctx->mem != ctx->mem) continue; - if (bi->address + BREAK_SIZE <= address) continue; + if (bi->address + bi->saved_size <= address) continue; if (bi->address >= address + size) continue; - for (i = 0; i < (int)BREAK_SIZE; i++) { + for (i = 0; i < bi->saved_size; i++) { if (bi->address + i < address) continue; if (bi->address + i >= address + size) continue; buf[bi->address + i - address] = bi->saved_code[i]; @@ -386,7 +388,6 @@ void check_breakpoints_on_memory_read(Context * ctx, ContextAddress address, voi void check_breakpoints_on_memory_write(Context * ctx, ContextAddress address, void * p, size_t size) { #if !defined(_WRS_KERNEL) if (!planting_instruction) { - int i; char * buf = (char *)p; LINK * l = instructions.next; while (l != &instructions) { @@ -394,13 +395,18 @@ void check_breakpoints_on_memory_write(Context * ctx, ContextAddress address, vo l = l->next; if (!bi->planted) continue; if (bi->ctx->mem != ctx->mem) continue; - if (bi->address + BREAK_SIZE <= address) continue; + if (bi->address + bi->saved_size <= address) continue; if (bi->address >= address + size) continue; - for (i = 0; i < (int)BREAK_SIZE; i++) { - if (bi->address + i < address) continue; - if (bi->address + i >= address + size) continue; - bi->saved_code[i] = buf[bi->address + i - address]; - buf[bi->address + i - address] = BREAK_INST[i]; + { + size_t i; + uint8_t * break_inst = get_break_instruction(bi->ctx, &i); + assert(i == bi->saved_size); + for (i = 0; i < bi->saved_size; i++) { + if (bi->address + i < address) continue; + if (bi->address + i >= address + size) continue; + bi->saved_code[i] = buf[bi->address + i - address]; + buf[bi->address + i - address] = break_inst[i]; + } } } } diff --git a/services/diagnostics.c b/services/diagnostics.c index 65a63659..9c967f70 100644 --- a/services/diagnostics.c +++ b/services/diagnostics.c @@ -29,7 +29,6 @@ #include <framework/cache.h> #if ENABLE_Symbols # include <services/symbols.h> -# include <services/stacktrace.h> #endif #if SERVICE_Streams # include <services/streamsservice.h> diff --git a/services/dwarfframe.h b/services/dwarfframe.h index c8d75fbe..206fe501 100644 --- a/services/dwarfframe.h +++ b/services/dwarfframe.h @@ -27,7 +27,6 @@ #include <framework/context.h> #include <services/dwarfcache.h> -#include <services/stacktrace.h> /* * Lookup stack tracing information in ELF file, in .debug_frame and .eh_frame sections. diff --git a/system/Darwin/context-darwin.c b/system/Darwin/context-darwin.c index d29aecf1..04c21ac2 100644 --- a/system/Darwin/context-darwin.c +++ b/system/Darwin/context-darwin.c @@ -554,15 +554,16 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) { } if (signal == SIGTRAP && event == 0 && !syscall) { - ctx->stopped_by_bp = !EXT(ctx)->regs_error && - is_breakpoint_address(ctx, pc1 - BREAK_SIZE); + size_t break_size = 0; + get_break_instruction(ctx, &break_size); + ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - break_size); EXT(ctx)->end_of_step = !ctx->stopped_by_bp && ctx->pending_step; + if (ctx->stopped_by_bp) { + set_regs_PC(ctx, pc1 - break_size); + EXT(ctx)->regs_dirty = 1; + } } ctx->pending_step = 0; - if (ctx->stopped_by_bp) { - set_regs_PC(ctx, pc1 - BREAK_SIZE); - EXT(ctx)->regs_dirty = 1; - } send_context_stopped_event(ctx); } } diff --git a/system/FreeBSD/context-freebsd.c b/system/FreeBSD/context-freebsd.c index 299375ce..a53b66d5 100644 --- a/system/FreeBSD/context-freebsd.c +++ b/system/FreeBSD/context-freebsd.c @@ -553,15 +553,16 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) { } if (signal == SIGTRAP && event == 0 && !syscall) { - ctx->stopped_by_bp = !EXT(ctx)->regs_error && - is_breakpoint_address(ctx, pc1 - BREAK_SIZE); + size_t break_size = 0; + get_break_instruction(ctx, &break_size); + ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - break_size); EXT(ctx)->end_of_step = !ctx->stopped_by_bp && ctx->pending_step; + if (ctx->stopped_by_bp) { + set_regs_PC(ctx, pc1 - break_size); + EXT(ctx)->regs_dirty = 1; + } } ctx->pending_step = 0; - if (ctx->stopped_by_bp) { - set_regs_PC(ctx, pc1 - BREAK_SIZE); - EXT(ctx)->regs_dirty = 1; - } send_context_stopped_event(ctx); } } diff --git a/system/GNU/Linux/context-linux.c b/system/GNU/Linux/context-linux.c index ecb69574..fc5ce8c0 100644 --- a/system/GNU/Linux/context-linux.c +++ b/system/GNU/Linux/context-linux.c @@ -735,14 +735,16 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) { } if (signal == SIGTRAP && event == 0 && !syscall) { - ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - BREAK_SIZE); + size_t break_size = 0; + get_break_instruction(ctx, &break_size); + ctx->stopped_by_bp = !EXT(ctx)->regs_error && is_breakpoint_address(ctx, pc1 - break_size); EXT(ctx)->end_of_step = !ctx->stopped_by_bp && ctx->pending_step; + if (ctx->stopped_by_bp) { + set_regs_PC(ctx, pc1 - break_size); + EXT(ctx)->regs_dirty = 1; + } } ctx->pending_step = 0; - if (ctx->stopped_by_bp) { - set_regs_PC(ctx, pc1 - BREAK_SIZE); - EXT(ctx)->regs_dirty = 1; - } send_context_stopped_event(ctx); } } diff --git a/system/Windows/context-win32.c b/system/Windows/context-win32.c index 5b80a89e..a87067a9 100644 --- a/system/Windows/context-win32.c +++ b/system/Windows/context-win32.c @@ -164,6 +164,7 @@ static void get_registers(Context * ctx) { static void event_win32_context_stopped(Context * ctx) { ContextExtensionWin32 * ext = EXT(ctx); DWORD exception_code = ext->pending_event.ExceptionRecord.ExceptionCode; + size_t break_size = 0; if (ctx->exited || ctx->stopped && exception_code == 0) return; memcpy(&ext->suspend_reason, &ext->pending_event, sizeof(EXCEPTION_DEBUG_INFO)); @@ -205,9 +206,10 @@ static void event_win32_context_stopped(Context * ctx) { case EXCEPTION_SINGLE_STEP: break; case EXCEPTION_BREAKPOINT: + get_break_instruction(ctx, &break_size); get_registers(ctx); - if (!ext->regs_error && is_breakpoint_address(ctx, ext->regs->Eip - BREAK_SIZE)) { - ext->regs->Eip -= BREAK_SIZE; + if (!ext->regs_error && is_breakpoint_address(ctx, ext->regs->Eip - break_size)) { + ext->regs->Eip -= break_size; ext->regs_dirty = 1; ctx->stopped_by_bp = 1; } |