mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-30 16:40:57 +00:00
992012d021
Some checks failed
build / macos-acr (arm64, 13) (push) Waiting to run
build / macos-acr (x86_64, 12) (push) Waiting to run
build / ios (cydia32) (push) Waiting to run
build / ios (true, cydia) (push) Waiting to run
build / w32-meson (push) Waiting to run
build / w64-static-2022 (push) Waiting to run
build / w64-static (push) Waiting to run
build / w64-meson (push) Waiting to run
build / check_release (push) Blocked by required conditions
build / release (push) Blocked by required conditions
CI / macos-test (push) Waiting to run
CI / macos-rpath (push) Waiting to run
CI / w64-make (push) Waiting to run
build / linux-wasi (push) Failing after 0s
build / linux-wasi-api (push) Failing after 1s
build / linux-csnext (push) Failing after 1s
build / tarball (push) Failing after 1s
build / linux-static (push) Failing after 1s
build / check_abi_compatibility (push) Has been skipped
build / linux-acr-rpm-64 (push) Failing after 1s
build / linux-acr-deb (amd64) (push) Failing after 1s
build / linux-acr-deb (arm64, aarch64-linux-gnu) (push) Failing after 1s
build / linux-acr-deb (i386, multilib) (push) Failing after 1s
build / android-acr (16, arm) (push) Failing after 1s
build / android-acr (aarch64) (push) Failing after 1s
build / android-meson (x86_64) (push) Has been skipped
CI / linux-acr-oldlibsbug (push) Failing after 1s
CI / linux-nocs (push) Failing after 1s
CI / linux-acr-gperf (push) Failing after 1s
CI / linux-sys-capstone (push) Failing after 1s
CI / linux-acr-resymlink (push) Failing after 1s
CI / linux-test (push) Failing after 1s
CI / linux-static-meson (push) Failing after 1s
CI / linux-rpath (push) Failing after 1s
CI / linux-meson-spaces (push) Failing after 1s
CI / linux-tinyasan-fuzz (push) Failing after 1s
CI / linux-asan-fuzz (push) Failing after 1s
CI / w32-mingw (push) Failing after 1s
CI / w64-mingw (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Coverity Scan / latest (push) Failing after 1s
tcc / ubuntu-tcc-newabi (push) Failing after 1s
tcc / ubuntu-tcc-test (push) Failing after 1s
tcc / ubuntu-tcc-nodbg (push) Failing after 1s
tcc / r2pm-tcc (push) Failing after 1s
tcc / ubuntu-tcc-syslibs (push) Failing after 1s
53 lines
1.5 KiB
C
53 lines
1.5 KiB
C
/* radare - LGPL - Copyright 2010-2024 pancake */
|
|
|
|
#include <r_debug.h>
|
|
|
|
R_API ut64 r_debug_arg_get(RDebug *dbg, const char *cc, int num) {
|
|
R_RETURN_VAL_IF_FAIL (dbg, UT64_MAX);
|
|
if (!cc) {
|
|
cc = r_anal_syscc_default (dbg->anal);
|
|
}
|
|
if (dbg->anal && !R_STR_ISEMPTY (cc)) {
|
|
if (!strcmp (cc, "stdcall") || !strcmp (cc, "pascal")) {
|
|
ut64 sp = r_debug_reg_get (dbg, "SP");
|
|
if (dbg->bits == 64) {
|
|
ut64 n64;
|
|
sp += 8; // skip return address, assume we are inside the call
|
|
sp += 8 * num;
|
|
dbg->iob.read_at (dbg->iob.io, sp, (ut8*)&n64, sizeof (ut64));
|
|
// TODO: honor endianness of platform
|
|
return (ut64)n64;
|
|
} else {
|
|
sp += 4; // skip return address, assume we are inside the call
|
|
sp += 4 * num;
|
|
ut32 n32;
|
|
dbg->iob.read_at (dbg->iob.io, sp, (ut8*)&n32, sizeof (ut32));
|
|
// TODO: honor endianness of platform
|
|
return (ut64)n32;
|
|
}
|
|
}
|
|
const char *rn = r_anal_cc_arg (dbg->anal, cc, num, -1);
|
|
if (rn) {
|
|
return r_debug_reg_get (dbg, rn);
|
|
}
|
|
}
|
|
r_strf_var (reg, 32, "A%d", num);
|
|
return r_debug_reg_get (dbg, reg);
|
|
}
|
|
|
|
R_API bool r_debug_arg_set(RDebug *dbg, const char *cc, int num, ut64 val) {
|
|
R_RETURN_VAL_IF_FAIL (dbg, false);
|
|
if (!R_STR_ISEMPTY (cc)) {
|
|
cc = r_anal_syscc_default (dbg->anal);
|
|
}
|
|
const char *rn = r_anal_cc_arg (dbg->anal, cc, num, -1);
|
|
if (rn) {
|
|
r_debug_reg_set (dbg, rn, val);
|
|
return true;
|
|
}
|
|
char reg[32];
|
|
snprintf (reg, sizeof (reg) - 1, "A%d", num);
|
|
r_debug_reg_set (dbg, reg, val);
|
|
return true;
|
|
}
|