-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor native debugger #4604
Refactor native debugger #4604
Conversation
For the build fail in AppVeyor, it runs Visual Studio 2017 and I think it does not support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job! Please create a new folder called native
and move these new files under it.
This is to ensure we know it is related to the native debugger.
Also change the uppercase names into lowercase (i.e. librz/debug/p/DragonFly.c
to librz/debug/p/dragonfly.c
We never had this issue before, so you probably have changed some code-paths. Also We can also do the opposite and have a big |
Thanks. I went through the code and logs once and found the following issues :
I will go through everything once more and look for more errors. I will also implement the changes suggested by you and will make a new commit in a few hours. |
Hello @wargio I corrected the formatting. Now its passing all except this one test case and my code passed for this particular test last time. I did not change any file that should affect native debugger. |
The error in the macos CI is unrelated to this PR. sometimes they fails. we have not yet discovered why. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any objections since it's purely code moving, but this code should be seriously (but carefully, very carefully) cleaned up.
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
#include <errno.h> | ||
#if !defined(__HAIKU__) && !defined(__sun) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit out of place, but could be done in a separate PR.
#ifndef MAP_ANONYMOUS | ||
#define MAP_ANONYMOUS 0x20 | ||
#endif | ||
snprintf(code, sizeof(code), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely rewrite/fix this part. And it doesn't belong to debugger, IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the task was to split this, so we can refactor for each platform so we can be sure to avoid breaking stuff and remove code that should definitely not be there.
}; | ||
int num = rz_syscall_get_num(dbg->analysis->syscall, "munmap"); | ||
|
||
snprintf(code, sizeof(code), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
RZ_API RZ_OWN RzList /*<RzDebugPid *>*/ *rz_debug_native_threads(RzDebug *dbg, int pid) { | ||
RzList *list = rz_list_new(); | ||
if (!list) { | ||
eprintf("No list?\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be removed probably.
@tushar3q34 do you want to try this issue? #3072 - it would help cleaning up and refactoring the native debugger for BSD, since it will ensure there are no regressions and allow us test debugger automatically on these platforms. |
Yeah sure I will look into the issue and try my best to resolve it. As for this PR, what else am I supposed to do ? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good we waited for the Android buids to be fixed. This change breaks the build:
/usr/local/lib/android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android33-clang -Ilibrz/debug/librz_debug.a.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/bin/format/elf -I../librz/bin/format/dmp -I../librz/bin/format/mdmp -I../librz/bin/format/pe -I../subprojects/rzgdb/include -I../subprojects/rzgdb/include/gdbclient -I../subprojects/rzgdb/include/gdbserver -Isubprojects/rzwinkd -I../subprojects/rzwinkd -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -I../librz/type/parser -I../subprojects/rzqnx/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -DRZ_PLUGIN_INCORE=1 -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fPIC -MD -MQ librz/debug/librz_debug.a.p/p_debug_native.c.o -MF librz/debug/librz_debug.a.p/p_debug_native.c.o.d -o librz/debug/librz_debug.a.p/p_debug_native.c.o -c ../librz/debug/p/debug_native.c
In file included from ../librz/debug/p/debug_native.c:33:
In file included from ../librz/debug/p/native/android_x86_64.c:44:
../librz/debug/p/native/reg.c:7:14: error: redefinition of 'rz_debug_native_reg_profile'
7 | static char *rz_debug_native_reg_profile(RzDebug *dbg) {
| ^
../librz/debug/p/native/android_x86_64.c:40:14: note: previous definition is here
40 | static char *rz_debug_native_reg_profile(RzDebug *dbg) {
| ^
In file included from ../librz/debug/p/debug_native.c:33:
In file included from ../librz/debug/p/native/android_x86_64.c:44:
../librz/debug/p/native/reg.c:68:2: warning: Unsupported Kernel [-W#warnings]
68 | #warning Unsupported Kernel
| ^
1 warning and 1 error generated.
[2247/2625] Compiling C object librz/debug/librz_debug.a.p/p_debug_gdb.c.o
[2248/2625] Compiling C object librz/debug/librz_debug.a.p/p_native_procfs.c.o
[2249/2625] Compiling C object librz/debug/librz_debug.a.p/p_debug_dmp.c.o
[2250/2625] Compiling C object librz/debug/librz_debug.a.p/p_native_linux_linux_debug.c.o
../librz/debug/p/native/linux/linux_debug.c:1183:2: warning: Android X86 does not support DRX [-W#warnings]
1183 | #warning Android X86 does not support DRX
| ^
1 warning generated.
/usr/local/lib/android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi33-clang -Ilibrz/debug/librz_debug.a.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/bin/format/elf -I../librz/bin/format/dmp -I../librz/bin/format/mdmp -I../librz/bin/format/pe -I../subprojects/rzgdb/include -I../subprojects/rzgdb/include/gdbclient -I../subprojects/rzgdb/include/gdbserver -Isubprojects/rzwinkd -I../subprojects/rzwinkd -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -I../librz/type/parser -I../subprojects/rzqnx/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -DRZ_PLUGIN_INCORE=1 -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fPIC -MD -MQ librz/debug/librz_debug.a.p/p_debug_native.c.o -MF librz/debug/librz_debug.a.p/p_debug_native.c.o.d -o librz/debug/librz_debug.a.p/p_debug_native.c.o -c ../librz/debug/p/debug_native.c
In file included from ../librz/debug/p/debug_native.c:35:
In file included from ../librz/debug/p/native/android_arm.c:44:
../librz/debug/p/native/reg.c:7:14: error: redefinition of 'rz_debug_native_reg_profile'
7 | static char *rz_debug_native_reg_profile(RzDebug *dbg) {
| ^
../librz/debug/p/native/android_arm.c:40:14: note: previous definition is here
40 | static char *rz_debug_native_reg_profile(RzDebug *dbg) {
| ^
In file included from ../librz/debug/p/debug_native.c:35:
In file included from ../librz/debug/p/native/android_arm.c:44:
../librz/debug/p/native/reg.c:68:2: warning: Unsupported Kernel [-W#warnings]
68 | #warning Unsupported Kernel
| ^
1 warning and 1 error generated.
[2250/2625] Compiling C object librz/debug/librz_debug.a.p/p_native_linux_linux_debug.c.o
../librz/debug/p/native/linux/linux_debug.c:1146:2: warning: print_fpu not implemented for this platform [-W#warnings]
1146 | #warning print_fpu not implemented for this platform
| ^
../librz/debug/p/native/linux/linux_debug.c:1250:2: warning: getfpregs not implemented for this platform [-W#warnings]
1250 | #warning getfpregs not implemented for this platform
| ^
../librz/debug/p/native/linux/linux_debug.c:1151:7: warning: variable 'showfpu' set but not used [-Wunused-but-set-variable]
1151 | bool showfpu = false;
| ^
../librz/debug/p/native/linux/linux_debug.c:1057:13: warning: unused function 'print_fpu' [-Wunused-function]
1057 | static void print_fpu(void *f) {
| ^~~~~~~~~
4 warnings generated.
/usr/local/lib/android/sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang -Ilibrz/debug/librz_debug.a.p -I. -I.. -Ilibrz -I../librz -Ilibrz/include -I../librz/include -I../librz/bin/format/elf -I../librz/bin/format/dmp -I../librz/bin/format/mdmp -I../librz/bin/format/pe -I../subprojects/rzgdb/include -I../subprojects/rzgdb/include/gdbclient -I../subprojects/rzgdb/include/gdbserver -Isubprojects/rzwinkd -I../subprojects/rzwinkd -Ilibrz/util/sdb/src -I../librz/util/sdb/src -I../librz/bin/format -I../librz/arch/isa -I../librz/arch/isa_gnu -Ilibrz/arch -I../librz/arch -I../librz/type/parser -I../subprojects/rzqnx/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O3 -DRZ_PLUGIN_INCORE=1 -DSUPPORTS_PCRE2_JIT -D_GNU_SOURCE --std=gnu99 -Werror=sizeof-pointer-memaccess -fPIC -MD -MQ librz/debug/librz_debug.a.p/p_debug_native.c.o -MF librz/debug/librz_debug.a.p/p_debug_native.c.o.d -o librz/debug/librz_debug.a.p/p_debug_native.c.o -c ../librz/debug/p/debug_native.c
In file included from ../librz/debug/p/debug_native.c:37:
In file included from ../librz/debug/p/native/android_arm64.c:44:
../librz/debug/p/native/reg.c:7:14: error: redefinition of 'rz_debug_native_reg_profile'
7 | static char *rz_debug_native_reg_profile(RzDebug *dbg) {
| ^
../librz/debug/p/native/android_arm64.c:40:14: note: previous definition is here
40 | static char *rz_debug_native_reg_profile(RzDebug *dbg) {
| ^
In file included from ../librz/debug/p/debug_native.c:37:
In file included from ../librz/debug/p/native/android_arm64.c:44:
../librz/debug/p/native/reg.c:68:2: warning: Unsupported Kernel [-W#warnings]
68 | #warning Unsupported Kernel
| ^
1 warning and 1 error generated.
[2247/2625] Compiling C object librz/debug/librz_debug.a.p/p_debug_qnx.c.o
[2248/2625] Compiling C object librz/debug/librz_debug.a.p/p_debug_dmp.c.o
[2249/2625] Compiling C object librz/debug/librz_debug.a.p/p_native_procfs.c.o
[2250/2625] Compiling C object librz/debug/librz_debug.a.p/p_debug_winkd.c.o
[2251/2625] Compiling C object librz/debug/librz_debug.a.p/p_native_linux_linux_debug.c.o
../librz/debug/p/native/linux/linux_debug.c:1146:2: warning: print_fpu not implemented for this platform [-W#warnings]
1146 | #warning print_fpu not implemented for this platform
| ^
../librz/debug/p/native/linux/linux_debug.c:1250:2: warning: getfpregs not implemented for this platform [-W#warnings]
1250 | #warning getfpregs not implemented for this platform
| ^
../librz/debug/p/native/linux/linux_debug.c:1151:7: warning: variable 'showfpu' set but not used [-Wunused-but-set-variable]
1151 | bool showfpu = false;
| ^
../librz/debug/p/native/linux/linux_debug.c:1057:13: warning: unused function 'print_fpu' [-Wunused-function]
1057 | static void print_fpu(void *f) {
| ^~~~~~~~~
4 warnings generated.
Yeah the same issue as linux builds. I will commit the changes asap. |
SQUASH ME
Your checklist for this pull request
Detailed description
Refactored debug_native.c into OS and arch specific files. Each file contains only the functions that are necessary and with minimal amounts of
#ifdef
.Test plan
Closing issues
closes #4581