From 9108f5a92f67b5d9bf8100dbd596b3f99145d02d Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:06:07 +0800 Subject: [PATCH 1/7] Fix sys.c unused variable. --- librz/util/sys.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/librz/util/sys.c b/librz/util/sys.c index f27b9614e3d..4522a13bd31 100644 --- a/librz/util/sys.c +++ b/librz/util/sys.c @@ -1229,12 +1229,11 @@ RZ_API char *rz_sys_pid_to_path(int pid) { } return rz_str_dup(pathbuf); #else - int ret; #if __FreeBSD__ || __DragonFly__ char pathbuf[PATH_MAX]; size_t pathbufl = sizeof(pathbuf); int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, pid }; - ret = sysctl(mib, 4, pathbuf, &pathbufl, NULL, 0); + int ret = sysctl(mib, 4, pathbuf, &pathbufl, NULL, 0); if (ret != 0) { return NULL; } @@ -1245,7 +1244,7 @@ RZ_API char *rz_sys_pid_to_path(int pid) { size_t len; pathbuf[0] = '\0'; - ret = sysctl(mib, 4, NULL, &len, NULL, 0); + int ret = sysctl(mib, 4, NULL, &len, NULL, 0); if (ret < 0) { return NULL; } @@ -1310,7 +1309,7 @@ RZ_API char *rz_sys_pid_to_path(int pid) { #else char buf[128], pathbuf[1024]; snprintf(buf, sizeof(buf), "/proc/%d/exe", pid); - ret = readlink(buf, pathbuf, sizeof(pathbuf) - 1); + int ret = readlink(buf, pathbuf, sizeof(pathbuf) - 1); if (ret < 1) { return NULL; } From 394884ca32cb8c029c6bbd801a95b87f4ade3797 Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:08:09 +0800 Subject: [PATCH 2/7] Add native/unsupported.c --- librz/debug/p/debug_native.c | 6 +++++- librz/debug/p/native/unsupported.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 librz/debug/p/native/unsupported.c diff --git a/librz/debug/p/debug_native.c b/librz/debug/p/debug_native.c index a35a0c0be86..83798dfdcf7 100644 --- a/librz/debug/p/debug_native.c +++ b/librz/debug/p/debug_native.c @@ -30,6 +30,7 @@ static int rz_debug_native_reg_write(RzDebug *dbg, int type, const ut8 *buf, int #warning "Unsupported debugging platform" #undef DEBUGGER #define DEBUGGER 0 +#include "native/unsupported.c" #endif #elif __ANDROID__ @@ -43,6 +44,7 @@ static int rz_debug_native_reg_write(RzDebug *dbg, int type, const ut8 *buf, int #warning "Unsupported debugging platform" #undef DEBUGGER #define DEBUGGER 0 +#include "native/unsupported.c" #endif #elif __linux__ @@ -74,6 +76,7 @@ static int rz_debug_native_reg_write(RzDebug *dbg, int type, const ut8 *buf, int #warning "Unsupported debugging platform" #undef DEBUGGER #define DEBUGGER 0 +#include "native/unsupported.c" #endif #elif __sun @@ -81,11 +84,12 @@ static int rz_debug_native_reg_write(RzDebug *dbg, int type, const ut8 *buf, int #undef DEBUGGER #define DEBUGGER 0 #warning "No debugger support for SunOS yet" - +#include "native/unsupported.c" #else #warning "Unsupported debugging platform" #undef DEBUGGER #define DEBUGGER 0 +#include "native/unsupported.c" #endif // Native OS & Arch #if DEBUGGER diff --git a/librz/debug/p/native/unsupported.c b/librz/debug/p/native/unsupported.c new file mode 100644 index 00000000000..42972559a0a --- /dev/null +++ b/librz/debug/p/native/unsupported.c @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2025 RizinOrg +// SPDX-FileCopyrightText: 2025 deroad +// SPDX-License-Identifier: LGPL-3.0-only + +/** + * \file This is a file with dummy debugger functions for when + * the native debugger is unsupported. + */ + +RZ_API ut64 rz_debug_get_tls(RZ_NONNULL RzDebug *dbg, int tid) { + return 0; +} + +RZ_API RZ_OWN RzList /**/ *rz_debug_native_threads(RzDebug *dbg, int pid) { + return rz_list_new(); +} From 18e21493ace939cc3b1c82ebf8f2a0c439677345 Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:08:44 +0800 Subject: [PATCH 3/7] Clean rz_debug.h from comments and functions which does not exists --- librz/include/rz_debug.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/librz/include/rz_debug.h b/librz/include/rz_debug.h index d638a0cefd1..8628bb6b217 100644 --- a/librz/include/rz_debug.h +++ b/librz/include/rz_debug.h @@ -472,10 +472,6 @@ RZ_API int rz_debug_continue_pass_exception(RzDebug *dbg); /* process/thread handling */ RZ_API bool rz_debug_select(RzDebug *dbg, int pid, int tid); -// RZ_API int rz_debug_pid_add(RzDebug *dbg); -// RZ_API int rz_debug_pid_add_thread(RzDebug *dbg); -// RZ_API int rz_debug_pid_del(RzDebug *dbg); -// RZ_API int rz_debug_pid_del_thread(RzDebug *dbg); RZ_API RzDebugPid *rz_debug_pid_new(const char *path, int pid, int uid, char status, ut64 pc); RZ_API RzDebugPid *rz_debug_pid_free(RzDebugPid *pid); RZ_API RzList /**/ *rz_debug_pids(RzDebug *dbg, int pid); @@ -502,8 +498,6 @@ RZ_API int rz_debug_signal_set(RzDebug *dbg, int num, ut64 addr); RZ_API bool rz_debug_can_kill(RzDebug *dbg); RZ_API int rz_debug_kill(RzDebug *dbg, int pid, int tid, int sig); RZ_API RzList /**/ *rz_debug_kill_list(RzDebug *dbg); -// XXX: must be uint64 action -RZ_API int rz_debug_kill_setup(RzDebug *dbg, int sig, int action); /* handle.c */ RZ_API void rz_debug_plugin_init(RzDebug *dbg); @@ -531,7 +525,6 @@ RZ_API int rz_debug_desc_dup(RzDebug *dbg, int fd, int newfd); RZ_API int rz_debug_desc_read(RzDebug *dbg, int fd, ut64 addr, int len); RZ_API int rz_debug_desc_seek(RzDebug *dbg, int fd, ut64 addr); // TODO: whence? RZ_API int rz_debug_desc_write(RzDebug *dbg, int fd, ut64 addr, int len); -RZ_API int rz_debug_desc_list(RzDebug *dbg, int rad); /* registers */ RZ_API bool rz_debug_reg_profile_sync(RzDebug *dbg); @@ -588,7 +581,6 @@ RZ_API int rz_debug_esil_watch_empty(RzDebug *dbg); RZ_API void rz_debug_esil_prestep(RzDebug *d, int p); /* record & replay */ -// RZ_API ut8 rz_debug_get_byte(RzDebug *dbg, ut32 cnum, ut64 addr); RZ_API bool rz_debug_add_checkpoint(RzDebug *dbg); RZ_API bool rz_debug_session_add_reg_change(RzDebugSession *session, int arena, ut64 offset, ut64 data); RZ_API bool rz_debug_session_add_mem_change(RzDebugSession *session, ut64 addr, ut8 data); @@ -637,23 +629,3 @@ static inline void *rz_debug_ptrace_func(RzDebug *dbg, void *(*func)(void *), vo #endif #endif - -/* regset */ -// RZ_API struct rz_regset_t* rz_regset_diff(struct rz_regset_t *a, struct rz_regset_t *b); -// RZ_API int rz_regset_set(struct rz_regset_t *r, int idx, const char *name, ut64 value); -// RZ_API struct rz_regset_t *rz_regset_new(int size); -// RZ_API void rz_regset_free(struct rz_regset_t *r); - -#if 0 -Missing callbacks -================= - - alloc - - dealloc - - list maps (memory regions) - - change memory protections - - touchtrace - - filedescriptor set/get/mod.. - - get/set signals - - get regs, set regs - -#endif From 3d8f699977ba07b7ad0a88437b08dc0ee171563d Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:14:17 +0800 Subject: [PATCH 4/7] Add fall-thru comment for haiku os case --- librz/cons/input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/librz/cons/input.c b/librz/cons/input.c index b77788aab37..8bd9fd6cf55 100644 --- a/librz/cons/input.c +++ b/librz/cons/input.c @@ -103,6 +103,7 @@ RZ_API int rz_cons_arrow_to_hjkl(int ch) { ch = 0xf1 + (ch & 0xf); break; } + // fall-thru case '[': // 0x5b function keys (2) /* Haiku need ESC + [ for PageUp and PageDown */ if (ch < 'A' || ch == '[') { From 7487aac45006072238d9d9f37dd0260c7ea58dc8 Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:17:24 +0800 Subject: [PATCH 5/7] Fix warning: "MIN" redefined /boot/system/develop/headers/posix/sys/param.h:18: note: this is the location of the previous definition 18 | # define MIN(a,b) (((a) < (b)) ? (a) : (b)) --- librz/arch/isa/tricore/tricore_il.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/librz/arch/isa/tricore/tricore_il.c b/librz/arch/isa/tricore/tricore_il.c index 6a991c3d21d..995cfaf18c7 100644 --- a/librz/arch/isa/tricore/tricore_il.c +++ b/librz/arch/isa/tricore/tricore_il.c @@ -2588,10 +2588,10 @@ static RzILOpEffect *e_BS(RzAsmTriCoreContext *ctx, unsigned b, FUNC_BS f) { return NULL; } -#define MIN(x, y) ITE(UGT(x, y), DUP(x), DUP(y)) +#define IL_MIN(x, y) ITE(UGT(x, y), DUP(x), DUP(y)) #define CRC_32_GENERATOR 0xEDB88320 static RzILOpPure *crc_div(RzILOpPure *c, RzILOpPure *g, RzILOpPure *crc_width, RzILOpPure *data_width) { - return LET("shift", MIN(crc_width, data_width), + return LET("shift", IL_MIN(crc_width, data_width), MOD(SHIFTL0(c, VARLP("shift")), LOGOR(g, SHIFTL0(U32(1), DUP(crc_width))))); } From 6d11e8a9ae18ba592edcba2dcab0a23573b6803c Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:22:20 +0800 Subject: [PATCH 6/7] Fix declared 'static' but never defined when unsupported OS --- librz/debug/p/native/unsupported.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/librz/debug/p/native/unsupported.c b/librz/debug/p/native/unsupported.c index 42972559a0a..057e83776ee 100644 --- a/librz/debug/p/native/unsupported.c +++ b/librz/debug/p/native/unsupported.c @@ -14,3 +14,17 @@ RZ_API ut64 rz_debug_get_tls(RZ_NONNULL RzDebug *dbg, int tid) { RZ_API RZ_OWN RzList /**/ *rz_debug_native_threads(RzDebug *dbg, int pid) { return rz_list_new(); } + +static int rz_debug_native_continue(RzDebug *dbg, int pid, int tid, int sig) { + return -1; +} + +static int rz_debug_native_reg_read(RzDebug *dbg, int type, ut8 *buf, int size) { + // TODO: this is returning a boolean, but for some reasons we have int + return false; +} + +static int rz_debug_native_reg_write(RzDebug *dbg, int type, const ut8 *buf, int size) { + // TODO: this is returning a boolean, but for some reasons we have int + return false; +} From e0a53b27cd3580d625b2e37293b95fc61c8af287 Mon Sep 17 00:00:00 2001 From: wargio Date: Sat, 17 May 2025 17:30:39 +0800 Subject: [PATCH 7/7] Fix formatting --- librz/arch/isa/tricore/tricore_il.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librz/arch/isa/tricore/tricore_il.c b/librz/arch/isa/tricore/tricore_il.c index 995cfaf18c7..a061029b613 100644 --- a/librz/arch/isa/tricore/tricore_il.c +++ b/librz/arch/isa/tricore/tricore_il.c @@ -2588,7 +2588,7 @@ static RzILOpEffect *e_BS(RzAsmTriCoreContext *ctx, unsigned b, FUNC_BS f) { return NULL; } -#define IL_MIN(x, y) ITE(UGT(x, y), DUP(x), DUP(y)) +#define IL_MIN(x, y) ITE(UGT(x, y), DUP(x), DUP(y)) #define CRC_32_GENERATOR 0xEDB88320 static RzILOpPure *crc_div(RzILOpPure *c, RzILOpPure *g, RzILOpPure *crc_width, RzILOpPure *data_width) { return LET("shift", IL_MIN(crc_width, data_width),