Commit Graph

1883 Commits

Author SHA1 Message Date
Sergi Àlvarez i Capilla
607134947e Honor esil.maxsteps in more commands and stop earlier when no =PC ##esil 2022-03-23 13:02:55 +01:00
Sergi Àlvarez i Capilla
50b8813f1d Fix w64blob artifact name for the release
* Fix meson -Dplugins=arm reg profile issue
* Fix an infinite loop when emulating with no valid regprofile
2022-03-22 20:06:43 +01:00
pancake
c8ae21f68f
Only build library archives when -Dblob is provided ##build
* Lowers the amount of objects from 2400 to 1500
2022-03-22 11:59:13 +01:00
pancake
34f1bbbcc8 Fix unitialized buffer read bug enumerating process files ##debug 2022-03-17 18:34:06 +01:00
pancake
7699f37c7d Fix warnings spotted by latest XCode (unused variables) 2022-03-17 10:12:02 +01:00
pancake
4ba0af5d1d Fix meson -Dblob=true builds for static ##windows 2022-03-16 00:48:50 +01:00
pancake
f8a35da205
Dont use != NULL as its implicit in C, even for bool casts ##refactor
$ find binr libr -name "*.c" -exec sed -i -e 's/ != NULL//g' {} \;
2022-03-15 19:54:04 +01:00
pancake
4bed905d8a
Fix msvc warnings (#19827) 2022-03-15 19:27:34 +01:00
Lazula
d507bda91c Remove R_EMPTY and R_EMPTY2 2022-03-13 11:26:10 +01:00
pancake
7b52e66c9c Skip wired-to-ground registers in dr= ##debug 2022-03-07 17:18:53 +01:00
pancake
5385336573 Add missing eiz/riz registers for x86 and x64 ##analysis
* ESIL was already correct, but the regprofile was missing those
2022-03-07 17:18:53 +01:00
Sergi Àlvarez i Capilla
aef278ee9c Make -Dblob=true statically link all r2 libraries ##build 2022-03-02 11:30:28 +01:00
pkubaj
6e4819b054
Add support for powerpc, powerpc64, powerpc64le and riscv64 on FreeBSD ##debug
* Also correct issue in vmenus.c, where ch is checked later whether it's -1, but on ARM and POWER, char is unsigned.
2022-02-18 19:25:53 +01:00
pancake
f2995c2949
Introduce r_strf and stop using sdb_fmt ##util 2022-01-18 18:35:31 +01:00
Sergi Àlvarez i Capilla
2cc473640f Expose RDebug for Linux-arm64 is also for 32bit 2022-01-13 19:20:52 +01:00
Sergi Àlvarez i Capilla
1a6ac566c3 Expose the 32bit arm reg profile on 64bit hosts ##debug 2022-01-13 18:57:56 +01:00
junchao-loongson
efd05bc7e9
Add support for the new loongarch architecture ##analysis
* Disasm, emulation, analysis and ELF support updated
2021-12-23 12:37:29 +01:00
Lazula
ad749a0b1a Fix static/R_API function definition formatting
* Remove spaces before parens
* Remove spaces after asterisks
2021-12-21 20:58:12 +01:00
junchao-loongson
fb7778c395
Add basic support for loongarch ##ports 2021-12-16 12:46:18 +01:00
pancake
e6f2cd0b2a
Remove trailing spaces (#19460)
$ git grep ' $' | grep -v ^test/ | cut -d : -f 1 | sort -u > /tmp/trailing
$ for a in `cat /tmp/trailing` ; do sed -i -e 's/ *$//' $a ; done
2021-12-02 17:39:59 +01:00
Lazula
2255bf8b5d Many indentation style fixes
* Change several 8-space indents to tabs
* Apply tab indent style when breaking long lines
* Move operators from EOL to start of next line
* Fix ternary formatting
2021-11-18 10:43:52 +01:00
pancake
d76201ce7f Fix w32 dp and ood regressions 2021-11-14 22:53:59 +01:00
pancake
3e032073a3
Fix null name maps, workaround msvc-asan compiler crash and acp/utf/wchar fixes for w32 2021-11-14 00:50:54 +01:00
pancake
9046aa2ebf
find | mv s/-/_/g (#19302) 2021-10-24 23:46:02 +02:00
pancake
9dbadb0ac1
mv shlr/heap into libr/include/heap (#19285) 2021-10-22 14:56:34 +02:00
pancake
6161fcd798
Use proper naming and location for the w32 debugger wrapper api (#19271) 2021-10-21 12:08:10 +02:00
Sergi Àlvarez i Capilla
76a50afce0 Add build failure fortune 2021-10-20 15:22:12 +02:00
Sergi Àlvarez i Capilla
f06bdadc3b Fix missing function return 2021-10-19 22:46:13 +02:00
pancake
3548e2e8a4 Final mingw fixes 2021-10-19 12:52:00 +02:00
pancake
93f6b4cd3b
Initial work towards supporting mingw32/64 again ##build 2021-10-18 23:58:16 +02:00
Sergi Àlvarez i Capilla
d6e6609617 Make the macOS debugger more stable ##debug
* Fix random spawn error
* Fix ood regression
2021-10-12 21:53:23 +02:00
Sergi Àlvarez i Capilla
4020dfe52a Fix reopen regression on Windows 2021-10-12 20:24:32 +02:00
pancake
704bf823d1
Cleanup and boolify some more debug apis ##refactor 2021-10-04 20:56:34 +02:00
Sergi Àlvarez i Capilla
6e85aa2970 Handle PPID on macOS debugger ##debug 2021-10-04 00:08:54 +02:00
pancake
007fdc97d9 Move linux specific thing used only in the debugger out of RUtil 2021-09-13 02:30:22 -07:00
pancake
e3f51a6ae5 ProcessIdToSessionId requires windows vista, so make it dynamic 2021-09-12 09:57:31 +02:00
pancake
9d18eb1a3a
Fix crash on windows dd, still wip ##debug 2021-09-09 20:59:11 +02:00
pancake
658239c1c6
Support 16bit debuggers and fix 27bit define ##debug (#19040) 2021-08-31 17:09:15 +02:00
pancake
13782053d9
Minor code cleanup 2021-08-27 14:53:21 +02:00
pancake
0c1155211a Expose a wrapper for r_w32_CancelSynchronousIo() 2021-08-27 13:04:55 +02:00
pancake
fd8e97034b Expose r_w32_ function APIs instead of global symbols ##windows
* This fixes some long standing bugs related to linker problems
2021-08-27 03:03:34 +02:00
pancake
ba375f5702 Code cleanup, somewhat related to windows code 2021-08-27 03:03:34 +02:00
pancake
1c73f1b101 Portable fixes 2021-08-25 14:15:15 +02:00
pancake
395a6f2e64 Improve portability by defining util deps properly 2021-08-25 13:47:36 +02:00
pancake
84e323334c Fix recent android build regression 2021-08-19 18:26:22 +02:00
pancake
6ca0abfe07 Fix w32 build (cdecl vs stdcall)
error C2440: '=': cannot convert from:
* 'HANDLE (__stdcall *)(DWORD,BOOL,DWORD)'
* 'HANDLE (__cdecl *)(DWORD,BOOL,DWORD)'
2021-08-18 11:14:26 +02:00
pancake
67b8af8f5b
Fix the windows debugger and make it more stable ##debug 2021-08-18 01:41:30 +02:00
pancake
f931473bec
Use data-align = 2 for v850 (#18988) 2021-08-17 15:47:09 +02:00
pancake
8a78055996
Fix all the sign UB bugs in the risc disassembler spotted by VS (#18986) 2021-08-17 02:09:49 +02:00
pancake
0acb19b68a
Fix some warnings spotted by visual studio (#18985)
Co-authored-by: pancake <pancake@nopcode.org>
2021-08-16 20:45:17 +02:00
pancake
321bb7fe75
Fix null deref and boolify the RDebug.attach() function (#18960) 2021-08-01 11:48:09 +02:00
pancake
3e1d31993d
dbg.verbose is now set to false by default (#18911)
* Hide GETREG error shown on WSL1
2021-07-18 18:25:11 +02:00
gogo
754e014ba6 Change the way wait events are handled in the unix-debug backend ##debug 2021-07-17 13:00:21 +02:00
pancake
5188df196d Random code cleanup 2021-07-17 13:00:21 +02:00
gogo
130c220792 Add 'sigstr' to the 'di' output for verboser stop reasons ##debug 2021-07-17 13:00:21 +02:00
gogo
472c7327f4 Add RSignal.toHuman() and improve RDebugReason.toString() ##debug 2021-07-17 13:00:21 +02:00
pancake
46068b1625 More portability build fixes 2021-07-07 20:09:55 +02:00
pancake
97f0c73058 Honor --disable-debugger in BSD 2021-07-07 20:04:12 +02:00
pancake
b56b63081d Fix segfault in di when the process is dead 2021-06-29 20:09:11 +02:00
pancake
188bce9f25 Use DRX APIs to handle breakpoint recoils only on x86-64 ##debug 2021-06-29 11:56:55 +02:00
pancake
46db8026d1 Resolve GetProcessImageFileName at runtime 2021-06-21 23:21:55 +02:00
pancake
190d809466 Use dynamic api resolution on windows builds for better portability ##windows
* Single implementation in r_util, used across io and debug
2021-06-21 23:09:14 +02:00
pancake
57a9bfd9da Fix iOS build regression 2021-06-21 01:18:57 +02:00
gogo
42290ab92a remove message about to attach PID 2021-06-12 04:04:55 +02:00
nmeum
79539dfbda
Fix armhf/armv7 musl compatibility again (#18792) ##build
In e92d170a3b, the include of asm/ptrace.h
has been silently disabled. Thereby basically reverting #13427. However,
without asm/ptrace.h included the build will fail on musl armhf/armv7
targets with the following compilation failure:

	p/native/linux/linux_coredump.c: In function 'linux_get_arm_vfp_data':
	p/native/linux/linux_coredump.c:950:27: error: 'ARM_VFPREGS_SIZE' undeclared (first use in this function)
	  950 |  char *vfp_data = calloc (ARM_VFPREGS_SIZE + 1, 1);
	      |                           ^~~~~~~~~~~~~~~~

This commit fixes this build failure by including asm/ptrace.h again.
2021-06-03 02:21:51 +02:00
Sergi Àlvarez i Capilla
66e8e33428 Define flags as gpr on the darwin-arm64 profile 2021-05-30 20:12:02 +02:00
Sergi Àlvarez i Capilla
976d0f0a7b Copypaste error 2021-05-30 20:08:36 +02:00
pancake
68f3aa05c4
Add missing =SN and zf for the darwin-arm64 native debugger reg profile ##debug (#18779) 2021-05-30 20:00:35 +02:00
pancake
bc929df5be Fix assert in r2 -e dbg.btalgo=trace -c dbt -d r2 2021-05-27 15:50:16 +02:00
David CARLIER
269f6808a7
debug: Fix FreeBSD 13 build. (#18728) 2021-05-20 20:18:51 +02:00
pancake
70a42d04d2
Fix infinite loop in r2 -c 'ood;ood' - ##debug (#18714) 2021-05-20 02:43:24 +02:00
Giovanni Di Santi
8ee7b62943
Fix dmha output after ood (#18710) ##debug 2021-05-20 00:45:41 +02:00
pancake
e92d170a3b
Add support for acr/musl-gcc static builds ##build 2021-05-14 21:34:21 +02:00
gogo2464
aee94edf49
Fix cast issue in ptrace call, waitpid fix ##debug 2021-05-10 10:50:12 +02:00
pancake
b5e262a6b9 Linux debugger improvements 2021-04-19 17:28:42 -07:00
pancake
7a39abeaff Ignore ENODEV on RDebug.regGet on Linux for kernels not supporting ##debug 2021-04-17 22:33:09 +00:00
pancake
3fcba682b6 Fix drx issue and step failing on linux-arm64 ##debug 2021-04-16 00:52:28 +02:00
murphy
413d1ef726 Fix 1451561 Resource leak 2021-04-13 20:09:33 +02:00
pancake
4c8aa2bf2e
Fix last covs I got by mail (#18531) 2021-04-03 03:50:08 +02:00
pancake
9f23cf7378 Fix #18502 - dangling pointers issues in dbm ##debug 2021-03-29 21:25:20 +02:00
pancake
a001a33a72 Fix #18510 - json assert in drtj 2021-03-29 19:44:56 +02:00
pancake
a7c08c15ce Don't scream out WARNINGs, capitalizing it is enough 2021-03-19 11:02:54 +01:00
pancake
639045efc5 Dont run debugger tests in ASAN mode and fix crash in snap.c 2021-03-15 12:26:09 +01:00
pancake
894bc43ea9 Use more r_str_ncpy and improve it to not alloc beyond nullbyte ##api 2021-03-15 02:24:16 +01:00
pancake
a08c89eb10 Fix warnings found on 32bit and --with-check-levels=0 2021-02-27 01:01:22 +01:00
pancake
2bed411446 Boolify all the ESIL callbacks ##esil 2021-02-24 17:13:30 +01:00
pancake
6de47ca9f8 Add dbg.maxsnapsize to avoid snapping huge maps ##debug
* Fix ASAN assert with debugger tests
2021-02-13 03:00:40 +01:00
GustavoLCR
ed208edcd9 Put registers in their own flagspace 2021-02-06 03:30:53 +01:00
Kamil Rytarowski
73bb7fdd66
Avoid overwriting LDFLAGS (#18294)
Append, instead of setting -lkvm for BSD platforms.
2021-01-26 10:55:54 +01:00
Liumeo
a79bf446fa
Use pj in debug ##refactor (#18270) 2021-01-24 16:07:30 +01:00
yossizap
7919b99305 Fix trace crash caused by a mismatch between the register profile and op anal ##rizin 2021-01-19 05:37:17 +01:00
pancake
ae9ffe4a83 One more -Werror=maybe-uninitialized 2021-01-18 16:10:59 +01:00
pancake
edda7a408a Add CC, command previous CC, is now CCF ##meta 2021-01-15 10:56:58 +01:00
pancake
08d7fe688c Implement RTable:sql and add RTable.name ##core 2021-01-15 10:56:58 +01:00
Liumeo
c631443b9b
Remove strncat usage (#18229) ##refactor 2021-01-14 17:24:23 +01:00
pancake
298888dfec Fix issues spotted with gcc -Werror 2021-01-13 01:28:10 +01:00
liumeo
965f3ed10e Use pj in dmj, dmhj & fix regex r2r ##refactor 2021-01-09 12:35:20 +01:00
Fredrik Fornwall
c4bc218576 Fix debugger build problem in android-x86_64 ##build 2021-01-07 10:24:41 +01:00
eagleoflqj
cd3ac9e2f2 Use pj in cmd_anal.c ##refactor 2021-01-06 00:03:44 +01:00
Liumeo
079b7cd991
Fix memleak in test_str & test_debug_session (#18164) 2021-01-04 03:54:43 +01:00
Liumeo
7a222e68dc
Fix some arm32 warnings (#18104) 2020-12-26 16:18:49 +01:00
Paul I
2c796ae5fd
Fix type check in w32_desc_list() (#18095) 2020-12-23 00:42:25 +01:00
Lazula
f2976d3c7e
Use r_str_get_fail() throughout codebase ##refactor (#18079) 2020-12-21 08:51:44 +01:00
pancake
d3157e2ed3
Fix 32 critical COVs (UAF, UB and OOB) (#18077) 2020-12-21 01:10:22 +01:00
pancake
89f6c6e1f1
Fix many ASAN issues, from uaf to memory leaks and some boolification (#18048) 2020-12-20 23:37:45 +01:00
Paul I
c8c508c5bd Revert "Fix clang-cl build"
This reverts commit 66aa8ee645.
2020-12-19 23:22:37 +01:00
pancake
ce48120056 Remove all uses of R_ANAL_CC_ 2020-12-16 00:48:54 +01:00
pancake
bd856af635 Add anal.cc & anal.syscc and remove the hardcoded conventions in debug ##anal 2020-12-16 00:48:54 +01:00
pancake
bf3188306e Fix a crash in dts+ command with empty register arenas ##debug #172
* Inspired by https://github.com/rizinorg/rizin/pull/172/files
2020-12-13 10:25:30 +01:00
Lazula
243bc871c3 Multiple refactors in io and util ##io ##util ##refactor
* Add r_io_map macros throughout code base
* Update string NULL-checking with renamed functions r_str_get() and r_str_getf()
* Change string NULL-checks throughout code base to use functions
* Add r_str_get_fail() to specify a custom string to return if NULL-check fails
* Mark JSON to be updated with PJ with "TODO PJ"
* Incidental style updates such as missing spaces
2020-12-13 05:09:13 +01:00
Liumeo
9efc80fed5
Fix Travis CI ARMv8 (ARM64) tests (#17939)
* Fix the remaining failures
* Enforce ARMv8 Travis build

Co-authored-by: Anton Kochkov <xvilka@gmail.com>
2020-11-19 15:06:46 +08:00
Paul I
66aa8ee645 Fix clang-cl build 2020-11-18 18:06:13 +08:00
Paul I
c317865d1f Fix copy-paste bug in windbg_reg_read() 2020-11-18 10:23:32 +08:00
Anton Kochkov
5da1b3b076 Fix some warnings 2020-11-16 18:56:21 +08:00
Anton Kochkov
14f82ee301 Fix formatting warnings for sdb_fmt() ##refactor 2020-11-12 15:14:42 +08:00
Anton Kochkov
aaccc09828 Variadic argument fixes 2020-11-10 11:11:45 +08:00
Liumeo
898a29713a
Remove some of the ARM64 warnings (#17875) 2020-10-30 12:18:56 +08:00
pancake
752787fdbc
Fix uninitialized pj instance in dreg.c (#17828)
dreg.c:294:3: warning: 'pj' may be used uninitialized in this function [-Wmaybe-uninitialized]

Co-authored-by: pancake <pancake@nopcode.org>
2020-10-26 14:06:18 +08:00
GustavoLCR
623c4819d6
Fix some warnings in WinDBG plugin (#17784) 2020-10-14 14:51:11 +08:00
yossizap
8872019a23 Show child processes in *bsd dp ##debug 2020-10-09 12:32:18 +08:00
yossizap
7522b2c9cc Fix dp 0 not showing other processes on freebsd ##debug 2020-10-09 12:32:18 +08:00
yossizap
e32ad7091c Fix FreeBSD dp permission denied failure ##debug
kvm_openfiles failed to open /dev/mem without root on fbsd, the special value
"/dev/null" should be used as non root since we don't directly access kernel memory.
2020-10-09 12:32:18 +08:00
Florian Märkl
16a91fbe5a Fix eprinf -> eprintf 2020-10-05 21:22:58 +08:00
yossizap
9bced66d7b
Fix FreeBSD step error ##debug (#17749) 2020-10-05 10:01:47 +08:00
pancake
b4a6b3ab20
Add remaining =A0 in regprofiles for calling convention ##anal (#17735) 2020-10-01 13:56:47 +02:00
pancake
aa7de006e6 Fix TinyCC build ##build 2020-09-27 13:33:26 +08:00
Khairul Azhar Kasmiran
73317d4955
r_reg_get_bytes: Return NULL if there are no bytes in the arena for the given regset type (#17657) 2020-09-16 18:14:43 +08:00
Khairul Azhar Kasmiran
d9057505dc
Set RPATH/RUNPATH on r2 libs too if local (#17639) 2020-09-15 09:16:14 +02:00
GustavoLCR
52d5b867aa
Fix step over for windbg plugin (#17586) 2020-09-04 15:56:11 -03:00
Anton Kochkov
43feee7a51
Fixes for old glibc (Debian Etch) (#17564) 2020-09-01 17:05:50 -05:00
abcSup
16c5017898 Fix ESIL tracing to be consistent with debug tracing ##anal 2020-09-02 06:00:38 +08:00
GustavoLCR
7e28739835
Expose TEB address as a flag on Windows ##debug (#17551)
* Also log the TEB address on thread start
2020-08-31 14:52:03 +08:00
Zi Fan
0ba897f5c9
Add network support for WinDbg/KD (KDNET) ##debug (#17340)
* Add network support for WinDbg/KD (KDNET) ##debug
* Add iob_net io_backend plugin for shlr/winkd
* Add Windows 10 (May 2019 Update) build 18362 profile
* Add r_hash_do_hmac_sha256 function to r_hash
* Change r_socket_connect to bind source port for UDP connection
2020-08-26 10:24:20 +08:00
GustavoLCR
489538e02b
Add DbgEng based debug backend for Windows ##debug (#17491)
* Rename `windbg` plugin to `winkd` ##debug
* Add DbgEng based debug backend for Windows ##debug
2020-08-24 19:01:10 +08:00
Zi Fan
3c88900134
Implement save and load functions for debug session ##debug (#17430)
* Add `dtst` and `dtsf` commands
* Change `RDebugSession` to store its data in their own sdb namespace
* Add `r_debug_session_serialize()` and `r_debug_session_deserialize()` API
* Add unit tests for `RDebugSession `save and load functions
2020-08-20 12:25:47 +08:00
abcSup
1407627c1a Define PTRACE_EVENT_* 2020-08-18 12:23:30 +08:00
abcSup
66f57c708c Fix broken linux_dbg_wait_break when running in background and undo more changes 2020-08-18 12:23:30 +08:00
abcSup
528e79818f Undo changes that modify signals in threads 2020-08-18 12:23:30 +08:00
abcSup
c4289abc73 Fix hanging threads when continuing after switching to another thread ##debug 2020-08-18 12:23:30 +08:00
abcSup
fef7638a1e Fix Linux native debugger freezes after interrupted by user in attach sessions and refactor ##debug 2020-08-18 12:23:30 +08:00
abcSup
02b4086970 Improve support for single-stepping in a multithreaded process #debug
* Remove debug print in the previous commit
* Fix logic errors and add documentation
2020-08-18 12:23:30 +08:00
abcSup
ab70092664 Improve support for debugging multihreaded processes on Linux ##debug 2020-08-18 12:23:30 +08:00
Anton Kochkov
8a1b1e9410
Older GCC/Glibc warning fixes (#17468) 2020-08-17 17:48:15 +08:00
Anton Kochkov
3af28896f9
Define PTRACE_O_* flags for old glibc ##debug (#17459) 2020-08-13 17:57:49 +08:00
Florian Märkl
68a1db448d
Merge everything time-related in r_time.h (#17445) 2020-08-12 18:54:49 +02:00
Zi Fan
2dfa75cc47
Update record & replay features to trace reg/mem changes ##debug (#17127)
* Update record & replay features to trace reg/mem changes ##debug
* Support tracing in r_debug_continue_kill ##debug
* Fix error writing registers when stepping back and refactor ##debug
* Implement checkpoints for reverse debugging and make tests green ##debug
* Add `dbg.trace_continue` option to enable/disable tracing every instruction when continue
* Fix continue when tracing to allow skipping and continuing ##debug
2020-07-27 12:54:33 +08:00
Riccardo Schirone
594b940b7c
Fixes some of the issues in Travis (#17267)
* Do not check with r_return_ if the convention is present

Let's just assume the NULL default in such a case, so that architectures
for which we don't have a defined calling convention can still be
processed somehow by the analysis code. It won't be precise, but it's
better than nothing.

Also add a warning message so users are aware when the calling
convention is not defined.

* Fix oob-read when # is at the end of the cmd string

* Do not set TMPDIR when the new value is the empty string

When TMPDIR is set to empty value, clang+ld behaves in weird ways and
you cannot compile files from within the r2 shell (e.g. when using #!c
or #!cpipe)

* Use meson and add -lasan to pkgconfig files when sanitizer are used
2020-07-16 20:47:30 +08:00
Zi Fan
af485c0770
Fix non-working drt flg command and refactor (#17254) ##debug
* Refactor r_reg_get_list to support R_REG_TYPE_ALL
* Fix registers type in linux_x64 regprofile
* Add test for drt flg
2020-07-13 12:09:58 +02:00
Riccardo Schirone
e3b67f124c
Release pipeline with GitHub Actions (#17192)
* Make sure meson can build with `system` = `android`.
* Add support for binr/blob in meson build
* Create release GitHub Actions workflow
* Add publish-docker-image job
* Also create Ubuntu packages and ship static windows zip
2020-07-09 12:07:45 +08:00
meowmeowxw
4b02987666
Fix tcache parsing on glibc version < 2.30 (#17206) 2020-07-08 20:16:27 +08:00
Riccardo Schirone
d6c9bd4542
Add support for binr/blob and fix android build ##meson ##build (#17150)
* Make sure meson can build with `system` = `android`.

* Add support for binr/blob in meson build

* Add also r_util as dependency

* Create sdb_version.py to get the SDBVER value from config.mk

* Set unknown sdb version if something fails
2020-07-05 10:53:37 +08:00
GustavoLCR
043b0183bd
Fixes for windows debugger ##debug (#17151)
* Fixes memleaks
* Fix compiler warnings
* Fix warning when reopening file as debugger
* Improve exception logging
* Fix inconsistencies killing/restarting a process
* Fix detaching without killing debuggee
* Fix warning when continuing after receiving CONTROL-C
* Expose exception reason for 'di'
* Fix listing opened files with 'dd'
2020-06-30 10:48:08 +08:00
Zi Fan
5124bef434
Fix non-working drt all command and add tests for drt ##debug (#16974) 2020-06-22 14:56:05 +08:00
Zi Fan
3abfdc023d
Fix invalid json output for drtj command ##debug (#17073) 2020-06-21 21:00:00 +08:00
meowmeowxw
1faed017c7
Heap glibc resolve main_arena using symbol (#17018) 2020-06-18 12:14:21 +02:00
pancake
bd9a604a87
Check for return values in about ~50 method calls (#17025) 2020-06-15 11:24:43 +02:00
pancake
160fc95e66
Use (void) instead of () in function signatures (#17026) ##refactoring
* Use (void) instead of () in function signatures
* Add test to avoid further contributions to commit the same mistake
2020-06-14 16:08:32 +02:00
Anton Kochkov
ffe743ef39
Fix #4056 - rename DEPS to R2DEPS ##build (#17020)
* Rename DEPS to R2DEPS
* Cleanup of sys/build.sh
2020-06-12 10:49:28 +08:00
pancake
75ee57bfb0
Update SDB with boolified SdbForeachCallback (#17040) 2020-06-11 11:25:23 +02:00
Paul I
9508a6ba56
Use HtPP for accessing dbg trace entries (#16921)
* Use HtPP for accessing dbg trace entries
* Remove #if R_DEBUG_HT_TRACES
2020-05-20 21:02:42 +08:00
Paul I
7451b67448
Add r_debug_trace_op() API to avoid analyzing the same op twice (#16816) ##anal 2020-05-13 20:51:26 +02:00
Riccardo Schirone
a29f0ccce5
Add CI job for CentOS 6 build (#16712)
* Fix re-definition of RAnalBlockCb and RAnalAddrCb

* Small compilation fixes for gcc-4

* Check PTRACE_GETREGSET before using it

* Add GH workflow to run on centos:6 for prerelease branches

* Fix configure.acr
2020-04-29 19:02:02 +08:00
pancake
af4b6e7dc3
Avoid the use of for (int in our codebase (#16718) 2020-04-27 15:47:21 +02:00
GustavoLCR
ac5355fb3d
Fixes for windows debugger - ##windows ##debug (#16717)
* Fix #15937 - Fix debuggee hanging when attaching to it
* Fix `dm` not working for attached processes
* Fix debuggee crashing when opening a file dialog
* Unify RIOW32Dbg and w32dbg_wrap_instance under W32DbgWInst
* Don't signal threads on select, only on continue
2020-04-26 11:54:36 +08:00
Liumeo
b9786ac7e3
Add header guards in the include files (#16595) 2020-04-15 12:20:02 +08:00
Florian Märkl
0a2f9dd29e
Fix Build on NetBSD (#16520) ##build 2020-04-11 01:52:19 +02:00
radare
3f77b9a76b
Avoid duplicated module filenames to fix static.sh ##build (#16403) 2020-04-02 14:30:27 +02:00
Florian Märkl
2c7ecc9736
Even more R2R (#16348)
* Fix r2r without FILE
* Fix many tests for r2r-c
* Pipe stdin in r2r to make isatty() return false
* Fix a leak in r2r
* Fix lock usage in RThread
* Always print stderr on failed tests
* Break broken zip tests
* Add -j arg to r2r
* Temporarily disable some tests that js and v don't parse
* Fix ar= trailing newline
2020-03-29 18:07:44 +02:00
Zi Fan
fec0aea039
Decouple shlr/gdb registers profile from code (#16312) ##debug
* Sync r2 debugger registers profile with shlr/gdb
* Add new set_reg_profile function to r_debug plugin
* Add set_reg_profile to r_debug_plugin_gdb
* Change "drp" to sync r_debug plugin register profile
* Fix incorrect pointer arithmetic and code style
2020-03-27 02:00:27 +01:00
Florian Märkl
0eb98d24be
Fix all Warnings for GCC 9 (#16223) 2020-03-17 13:31:28 +01:00
Florian Märkl
0b5e78e923
Make size arg of r_file_slurp() size_t (#16221) 2020-03-15 23:34:38 +01:00
Khairulmizam Samsudin
bb389101da
Make r_reg_get_list() search harder (#16202) ##reg 2020-03-13 12:01:54 +01:00
radare
0cacc6e829
Fix file reopen in debug mode ood/doo (#16131) ##debug 2020-03-05 14:42:32 +01:00
radare
f74dd31440
Fix debugger build on Linux/s390x ##build (#16105) 2020-03-03 00:03:43 +01:00
radare
5e629a3260
Avoidify the strTrim() APIs + cleanup/refactor ##util (#16056) 2020-03-02 21:39:37 +01:00
radare
6ae8806411
Do not use the elvis operator for bool expressions (#16073) 2020-02-28 15:19:37 +01:00
Anton Kochkov
9ae41ae69f
Revert "Avoidify the RUtil.strTrim() APIs, rename trimHeadTail() and add asserts in RConfig ##refactor" (#16055)
This reverts commit 38b61c7bcf.
2020-02-26 09:59:04 +08:00
radare
38b61c7bcf
Avoidify the RUtil.strTrim() APIs, rename trimHeadTail() and add asserts in RConfig ##refactor 2020-02-25 17:53:09 +01:00
pancake
5677390ca6 Fix #10696 - Kill r_io_map_add_next_available
The function is just renamed to be reused and we have no tests for it, but it may fall into an infinite loop
2020-02-24 01:16:14 +01:00
Khairulmizam Samsudin
17026c8c62
Fix show register value in column (#16010) ##debug
* Fix for ar= and dr= and add tests
* increase width to accomodate register name larger than 4 chr
* fix flag type register value not printed
* update r_debug_reg_list() to accept '=' arg
2020-02-20 16:26:29 +01:00
Florian Märkl
14215350af Refactor RAnal Basic Blocks and Functions (#15169) ##anal
Basic Blocks are now global instead of owned by a single function.
2020-01-15 15:23:34 +01:00
Anton Kochkov
f3a0a3d01c Some coverity fixes 2020-01-10 12:30:23 +01:00
pancake
0e34303648 Third fix attepmt for musl builds 2020-01-10 03:50:30 +01:00
pancake
5a48a40178 Second fix attempt for Alpine/musl builds 2020-01-10 03:32:13 +01:00
pancake
52d9baf988 Aim to fix the alpine build 2020-01-10 03:06:46 +01:00
yossizap
2e5f4b41b4 Fix multithreaded breakpoint behavior in linux ##debug
The plugin wouldn't properly trace breakpoint hits on different threads
since they weren't switched to and the events weren't always handled.
Also, since the breakpoints are removed after they are found in one of the
threads, it's best to stop all threads for now even if dbg.threads is false.
2020-01-10 00:30:18 +01:00
yossizap
ed1f42085c Attach to new linux threads on creation ##debug
New threads were only added after being attached to manually or if
dbg->trace_clone was true. dbg->trace_clone stops debug and switches the
new thread now.
2020-01-10 00:30:18 +01:00
radare
c3651a43ec
Fix debugger build on linux-s390x ##debug
* Add s390x reg profile
* Add missing pc register
* Use gregset instead of regset
2020-01-09 15:21:41 +01:00
yossizap
0de7c21bcc Always unset bps after continue and step hard ##debug (#15772)
Breakpoints were left in disassembly after a signal/break and there
are probably other cases that may lead to it.
2020-01-09 12:00:24 +01:00
Anton Kochkov
0c46c3e1e3 Some coverity fixes 2020-01-08 14:16:11 +01:00
yossizap
3b804c5bc5 Add detailed location info to dpt using pc instead of path ##debug 2020-01-07 21:50:17 +01:00
pancake
836ea638b7 Revert "Validate bp addr on rebase and restore instead of preventing creation ##debug (#15750)"
This reverts commit e503bdd9c2.
2020-01-03 01:35:05 +01:00
yossizap
e503bdd9c2 Validate bp addr on rebase and restore instead of preventing creation ##debug (#15750)
This way it is possible to set breakpoints before starting debug through
'db' and the user will be notified when a breakpoint points to an
invalid map.
2020-01-03 00:57:18 +01:00
yossizap
3f7dd9a47f Fix hardware bp restoring and fix hwbp repeating errors ##debug (#15749)
Instead of unsetting breakpoints they were set again without  removing
the previous drx values, which also caused the "Invalid DRX length (0)
must be 1, 2, 4, 8 bytes" error because of the wrong len values.
Also, when resetting twice, del failed since there weren't any hw
registers to delete, which caused the "hw breakpoints not yet
2020-01-03 00:56:54 +01:00
yossizap
230d2364f4 Add location in file to linux dpt output ##debug (#15744)
Shows the module, offset and function name instead of showing the executable's
path for all threads
2020-01-03 00:56:15 +01:00
yossizap
9a6bcce392 Fix windows dp showing the parent's path for all processes (#15741) 2020-01-01 20:39:45 -06:00
GustavoLCR
21781aa0d1 Fix #15734 - Automatically download PDB file if pdb.autoload=1 (#15738)
* Automatically download PDB file if pdb.autoload=1
* Don't re-download pdb if it already exists on the symstore
* Only download if file doesn't exist
2020-01-01 20:37:28 -06:00
David CARLIER
bac525d8e9 Refactoring ptrace register write for BSD ##debug (#15725) 2019-12-29 14:27:34 +01:00
David CARLIER
86768ccfdd Implement bsd_thread_list for FreeBSD ##debug (#15695) 2019-12-29 08:02:25 +01:00
David Carlier
7ee39fb157 Few warning build fixes proposal. 2019-12-27 06:13:53 -06:00
yossizap
59ce43d52c Fix reopening of windows debug after detaching not working ##debug
attach_new_process was called instead of regular attach because the
saved pid and tid in core->dbg weren't reset before calling r_debug_select
in a new session. Made sure this won't be a problem when using dp= after
dp- either.
2019-12-27 02:46:59 -06:00
yossizap
f0027aa263 Fix windows breakpoint rebasing ##debug
Calculate the diff ourselves since bp->delta is calculated with the
dbg->bp->baddr at the time of breakpoint creation, which may not
reflect the correct baddr and break the rebase.
2019-12-27 02:46:59 -06:00
David Carlier
28ec4ca297 Debug, BSD systems refactoring ##r_debug
Separate pure BSD calls into its separate compilation unit.
2019-12-20 21:11:30 -06:00
yossizap
bfa40cd5db Fix gdbr reg sync and concurrency ##debug 2019-12-20 10:17:58 +09:00
GustavoLCR
0e19329de7 Fix rebasing for remote GDB on windows 2019-12-19 17:42:22 -06:00
yossizap
6cfdafdf51 Refactor debug native's wait function ##debug
Separate windows, linux and *bsd/apple since they have vastly different
logic and the ifdef jungle implementation was too confusing
2019-12-17 11:04:19 -06:00
David CARLIER
8caa059c9b Refactor signal handling for FreeBSD ##r_debug (#15659)
Solving r_debug_handle_signals build warning issue.
2019-12-17 15:08:50 +01:00
Anton Kochkov
4e8e330475 Fix some MSVC warnings 2019-12-16 12:26:05 -06:00
yossizap
f1de1becfa Add ppid to dp and fix dp= for windows (#15649)
* Add ppid to win32 debug and 'dp''s display/json ##debug
* Add process selection to w32 debug ##debug

Previously, `dp=` wouldn't fully switch to the given process since it
was treated like `dpt` thread switching, leaving the debugger in
an undefined state.
2019-12-16 09:24:17 -06:00
yossizap
89a5320e5f Fixed a crash caused by reopening gdb ##debug
The plugin would try to work with an old version of desc that was already
freed by r_io_close_all after closing the session. I set debug_gdb's
global 'desc' to NULL in detach as a temporary solution. We should convert
to **desc to keep an updated copy of the pointer.
2019-12-16 01:23:27 +01:00
GustavoLCR
7e4157bc2b Fix format string in windows_message.c 2019-12-15 23:37:54 +01:00
Paul I
9a4578a915 Replace some strstr() calls with strchr() 2019-12-15 23:37:27 +01:00
yossizap
6f546149cf Fixed gdbr warnings and a dpt crash after debug was over ##debug (#15636)
RDebugPid not being initialized with NULL resulted in a free on an invalid
pointer after gdbr_threads_list failed.
2019-12-15 04:45:11 -06:00
yossizap
28cac248a6 Added an event to signal the end of the debug session ##debug 2019-12-15 10:46:48 +01:00
Anton Kochkov
e11b2a9145
Some Coverity defect fixes (#15626) 2019-12-13 11:25:19 -06:00
yossizap
9fca7b1f58 Fixed an issue with detached child breakpoint inheretence ##debug (#15561)
Previously, forked children would instantly die if the fork was stepped
over using a breakpoint which is accessible to the child process.
2019-12-09 09:52:53 +01:00
GustavoLCR
e43c9e7caf Fix some warnings (#15549) 2019-12-08 12:49:58 +01:00
fcasal
c2f01218f2 Rebase Breakpoints for PIEs ##debug (#12801) 2019-12-06 10:52:26 +01:00
yossizap
f12783f4ca Added dp processes info support to gdbr ##debug (#15544)
Most servers/clients should have xml support by now so it should behave
like `dp` in any other debugger. vFile is the only way to get detailed pid info unfortunately.
2019-12-05 13:30:05 +01:00
yossizap
21ec674969 Allow debug plugins to modify pid/tid on select ##debug
Previously, when using `dp=`, the debug plugin would set a new tid based
on the requested pid, but r_debug_select would set the old tid as dbg->tid,
resulting in issues interacting with the current thread. This could also
be an issue when the requested pid/tid is invalid and the plugin selects
something else.
2019-12-04 10:55:29 +01:00
yossizap
129158101f Fix linux_set_options error ##debug
Previously, setting options would fail sometimes since PT_ATTACH's attach
SIGSTOP wasn't hit before reaching linux_set_options.
2019-12-04 10:55:29 +01:00
yossizap
7823430724 Add process selection to linux native debug ##debug
Previously, `dp=` wouldn't fully switch to the given process since it was
treated like `dpt` thread switching, leaving the debugger in an undefined state.
2019-12-04 10:55:29 +01:00
David CARLIER
3ac93f1e16 Setting parent pid on pid list on BSD ##debug 2019-12-01 13:08:32 +01:00
yossizap
164e2cca23 Show all processes for pid 0 using dp ##debug 2019-12-01 11:44:15 +01:00
yossizap
8c02f7ccd3 Add current process field to dpj ##json 2019-11-30 00:50:18 +01:00
yossizap
a99c8026bd Improve linux native debug dp output ##debug
Previously, the command didn't show the pid's path, replaced the path
field with current/ppid, and showed the ppid instead of only showing the
requested process and the children of the requested process.
2019-11-30 00:50:18 +01:00
GustavoLCR
e1648b8196 Fix getting DRX breakpoint size ##debug (#15531) 2019-11-30 00:49:30 +01:00
GustavoLCR
ebaf8b603e Fix some warnings on Windows (#15532) 2019-11-30 00:49:16 +01:00
GustavoLCR
4378645f31 Add command to identify window under cursor ##windows (#15518) 2019-11-28 18:40:17 +01:00
GustavoLCR
78c232b5c5 Impl. list modules for WinDbg ##debug 2019-11-26 12:37:39 +01:00
yossizap
21cc6e7788 Fixed windbg concurrency and added missing locks ##debug
Previously, windbg_break would freeze waiting on a lock instead of breaking,
taks other than wait weren't breakable and read regs would freeze the
process while waiting for a mutex.
2019-11-25 18:04:16 +01:00
GustavoLCR
a484d2c6e9 Allow breaking for WinDbg ##debug
* Fix OOB read in windbg_reg_read
* Add locks to prevent collision
* Enable timeouts on the pipe backend
2019-11-25 18:04:16 +01:00
yossizap
a19f212586 Update hardcoded gdbr registers for 16/32bit x86 (#15488) ##debug
There are still platforms that don't support the target xml format.
2019-11-21 10:28:35 +01:00
yossizap
68babb75f3 Added parsing support to all gdb registers ##debug
The previous implementation was limited to 64bit registers and didn't
parse the 'feature' field.
2019-11-18 22:56:56 -06:00
yossizap
3c0267fc0a Fix gdbr's reg_write and reg_next_diff for reverse stepping ##debug
Writing registers with gdbr worked with single registers because
reg_next_diff started at delta 0 and only had to run the diff once for
the single register that was changed. When running reverse
stepping/continue, multiple registers are changed at once so
r_reg_next_diff would fail every time due to incorrect offset calculation.
The new r_reg_next_diff also support different register sizes to restore
all registers correctly.
The endianity swapping part from reg_write isn't needed since the arena
is the return value of 'g' which is already in the correct target byte
order (see: https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#read-registers-packet)
2019-11-18 22:56:56 -06:00
yossizap
e35f447a2a Added break to gdbserver vCont and refactored the code to use locks (#15433)
The previous gdbr implementation didn't allow interrupting background
tasks with &b since send_vcon wasn't properly configured with the cons
api. In addition to that, gdbserver doesn't support processing multiple
commands at the same time, resulting in undefined behavior once cons
were set up for vcont.
This commit adds the relevant cons api and solves the concurrency issues
by adding locks on all socket related logic.
2019-11-10 19:03:56 +01:00
Khairul Kasmiran
84ce2a7d04 r_list_new() -> r_list_new () 2019-11-10 14:06:02 +08:00
Khairul Azhar Kasmiran
9167a5e740 r_list_newf(..) -> r_list_newf (..) 2019-11-09 18:52:29 +08:00
Armin Weihbold
82047cc580 Add experimental ymm regs support for linux-x64 and extend drm command ##debug 2019-11-07 17:23:18 +01:00
GustavoLCR
88c848cc37 Fixes for Windows debugging (#15418)
* Fix error when continuing after attaching to process
* Get threads correct EIP
* Fix some memory corruptions and small refactor
2019-11-06 00:01:36 -06:00
GustavoLCR
36114b35f3 Fix attaching to a pid on Windows (#15406) ##debug 2019-11-04 11:05:55 +01:00
yossizap
05b000bb13 Modified debug_native to handle break's thread switching behavior
The user was interrupted during continue and switched to a different
thread since DebugBreakProcess creates a thread that triggers a breakpoint.
With these changes the DebugBreak thread is recorded to skip the breakpoint
event afterwards.
2019-11-02 00:30:25 +01:00
yossizap
12391ae483 Modified r_debug_native_wait to avoid switching between threads for each event
The debugger should return to the requested thread after handling events
in other threads except for breakpoints.
2019-11-02 00:30:25 +01:00
Johannes
5d76b9ff99 fix linux x86 build (#15395) 2019-11-01 02:54:48 +01:00
yossizap
45782c7705 Fixed w32dbg breaking issues (#15386) ##debug
* Fixed w32dbg breaking issues and moved break_push to w32_dbg_wait to support stepping as well

Previously, breaking would only work during 'dc' because it was pushed
in debug.c specifically for continue. This change moves the
responsibility of pushing/popping w32_break_process_wrapper to
windows_debug.c instead to support calls to w32_dbg_wait from anywhere.
2019-10-30 18:58:34 +01:00
radare
f639c3b6a1
Fix build for 32bit Linux systems ##build (#15384) 2019-10-30 13:04:25 +01:00
GustavoLCR
293b244caa Fix hang when running dc in a task ##windows (#15380) 2019-10-29 11:31:03 +01:00
yossizap
29e2ffe476 Fix issues in windows thread switching (#15366)
* Fixed issues in windows thread switching by implementing thread attach for w32dbg =!pid

Previously the function attempted to OpenProcess even though the main
pid is already opened by __open and the fact that re-opening the main
pid wouldn't do anything. This way it attaches to new threads when
called by r_debug_select.

* Modified w32_continue to update rio->pi.dwThreadId after switching to the requested thread

Manually changing iop->pi.dwThreadId in io_w32dbg's =!pid created a
problematic scenario when w32_continue is called with the last event's
tid from dbg_wait. This solution makes sure iop->pi.dwThreadId keeps
being updated after events on other threads arrive and that w32_continue
actually uses the given tid.

* Modified w32_continue return values
2019-10-28 11:06:57 +01:00
GustavoLCR
47a440cae5 Implement w32dbg_wrap 2019-10-28 05:56:10 +01:00
GustavoLCR
317c0ee811 Fix reading registers after thread exited 2019-10-28 05:56:10 +01:00