mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 11:43:39 +00:00
Darwin: start debugging suspended. Fixes in lm32
This commit is contained in:
parent
196d7db68d
commit
486c88954f
@ -8,6 +8,8 @@
|
||||
#include <r_asm.h>
|
||||
#include "../arch/lm32/lm32_isa.h"
|
||||
|
||||
#define LM32_UNUSED 0
|
||||
|
||||
//str has to be at least 8 chars elements long
|
||||
static int reg_number_to_string(ut8 reg, char *str) {
|
||||
ut8 match_idx = 0xff;
|
||||
@ -24,6 +26,7 @@ static int reg_number_to_string(ut8 reg, char *str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LM32_UNUSED
|
||||
static int string_to_reg_number(const char *str, ut8 *num) {
|
||||
ut8 match_idx = 0xff;
|
||||
int i;
|
||||
@ -39,22 +42,6 @@ static int string_to_reg_number(const char *str, ut8 *num) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//str has to be at least 8 chars elements long
|
||||
static int csr_number_to_string(ut8 csr, char *str) {
|
||||
ut8 match_idx = 0xff;
|
||||
int i;
|
||||
for (i = 0; i < RAsmLm32CsrNumber; i++) {
|
||||
if (RAsmLm32Csrs[i].number == csr) {
|
||||
match_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//csr number not found in array
|
||||
if (match_idx == 0xff) return -1;
|
||||
strcpy (str, RAsmLm32Csrs[match_idx].name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int string_to_csr_number(const char *str, ut8 *num) {
|
||||
ut8 match_idx = 0xff;
|
||||
int i;
|
||||
@ -83,6 +70,23 @@ static int string_to_opcode(const char *str, ut8 *num) {
|
||||
*num = tmp_num;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
//str has to be at least 8 chars elements long
|
||||
static int csr_number_to_string(ut8 csr, char *str) {
|
||||
ut8 match_idx = 0xff;
|
||||
int i;
|
||||
for (i = 0; i < RAsmLm32CsrNumber; i++) {
|
||||
if (RAsmLm32Csrs[i].number == csr) {
|
||||
match_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//csr number not found in array
|
||||
if (match_idx == 0xff) return -1;
|
||||
strcpy (str, RAsmLm32Csrs[match_idx].name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//sign_loc is the location of the sign bit before the shift
|
||||
static st32 shift_and_signextend(ut8 shift, ut8 sign_loc, ut32 val) {
|
||||
@ -363,6 +367,8 @@ static int r_asm_lm32_stringify(RAsmLm32Instruction *instr, char *str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
static int r_asm_lm32_destringify(const char *string, RAsmLm32Instruction *instr) {
|
||||
//TODO
|
||||
return -1;
|
||||
@ -373,8 +379,14 @@ static int r_asm_lm32_encode(RAsmLm32Instruction *instr, ut32 *val) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int assemble(RAsm *a, RAsmOp *ao, const char *str) {
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int disassemble(RAsm *a, RAsmOp *op, ut8 *buf, ut64 len) {
|
||||
#endif
|
||||
|
||||
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
||||
RAsmLm32Instruction instr;
|
||||
//lm32 is big endian
|
||||
a->big_endian = 1;
|
||||
@ -394,18 +406,13 @@ static int disassemble(RAsm *a, RAsmOp *op, ut8 *buf, ut64 len) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
static int assemble(RAsm *a, RAsmOp *ao, const char *str) {
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
RAsmPlugin r_asm_plugin_lm32 = {
|
||||
.name = "lm32",
|
||||
.arch = "lm32",
|
||||
.desc = "disassembly plugin for Lattice Micro 32 ISA",
|
||||
.license = "BSD",
|
||||
.bits = 32,
|
||||
.disassemble = &disassemble,
|
||||
.disassemble = disassemble,
|
||||
//.assemble = &assemble, TODO
|
||||
};
|
||||
|
||||
|
@ -57,6 +57,7 @@ bool xnu_step(RDebug *dbg) {
|
||||
|
||||
//debug_arch_x86_trap_set (dbg, 1);
|
||||
// TODO: not supported in all platforms. need dbg.swstep=
|
||||
task_resume (pid_to_task (pid));
|
||||
#if __arm__ || __arm64__ || __aarch64__
|
||||
ios_hwstep_enable (dbg, true);
|
||||
ret = ptrace (PT_STEP, pid, (caddr_t)1, 0); //SIGINT
|
||||
@ -98,6 +99,7 @@ int xnu_continue(RDebug *dbg, int pid, int tid, int sig) {
|
||||
#else
|
||||
//ut64 rip = r_debug_reg_get (dbg, "pc");
|
||||
void *data = (void*)(size_t)((sig != -1) ? sig : dbg->reason.signum);
|
||||
task_resume (pid_to_task (pid));
|
||||
return ptrace (PT_CONTINUE, pid, (void*)(size_t)1,
|
||||
(int)(size_t)data) == 0;
|
||||
#endif
|
||||
|
@ -279,13 +279,15 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
|
||||
{
|
||||
#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
|
||||
posix_spawn_file_actions_t fileActions;
|
||||
ut32 ps_flags = POSIX_SPAWN_SETEXEC;
|
||||
//ut32 ps_flags = POSIX_SPAWN_SETEXEC;
|
||||
ut32 ps_flags = POSIX_SPAWN_SETEXEC | \
|
||||
POSIX_SPAWN_SETSIGDEF | \
|
||||
POSIX_SPAWN_SETSIGMASK;
|
||||
posix_spawnattr_t attr = {0};
|
||||
size_t copied = 1;
|
||||
cpu_type_t cpu;
|
||||
pid_t p = -1;
|
||||
int ret;
|
||||
int useASLR = io->aslr;
|
||||
int ret, useASLR = io->aslr;
|
||||
posix_spawnattr_init (&attr);
|
||||
if (useASLR != -1) {
|
||||
if (useASLR) {
|
||||
@ -301,6 +303,7 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
|
||||
posix_spawn_file_actions_addinherit_np (&fileActions, STDOUT_FILENO);
|
||||
posix_spawn_file_actions_addinherit_np (&fileActions, STDERR_FILENO);
|
||||
ps_flags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
|
||||
ps_flags |= POSIX_SPAWN_START_SUSPENDED;
|
||||
|
||||
(void)posix_spawnattr_setflags (&attr, ps_flags);
|
||||
#if __i386__ || __x86_64__
|
||||
@ -373,9 +376,7 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) {
|
||||
#endif
|
||||
|
||||
static int __plugin_open(RIO *io, const char *file, ut8 many) {
|
||||
if (!strncmp (file, "dbg://", 6) && file[6])
|
||||
return true;
|
||||
return false;
|
||||
return (!strncmp (file, "dbg://", 6) && file[6]);
|
||||
}
|
||||
|
||||
static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
|
||||
|
Loading…
Reference in New Issue
Block a user