Commit graph

45 commits

Author SHA1 Message Date
Giovanni
8efdb3d3a3
Refactoring debug plugin and cleanup output (#3634) 2023-07-04 10:42:41 +08:00
Riccardo Schirone
65e4e9ebd1
Fix few sscanf issues reported by @yeggor (#3428) 2023-03-22 18:36:54 +08:00
rizan21
cc18d675e6 Use clang-format 15 instead of 14 2023-01-25 22:02:26 +08:00
wargio
1165b20ee7 arch name is always set in debug native even when the arch is unknown 2022-12-06 10:07:38 +08:00
Dean
59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00
Anton Kochkov
6bdcbc5124
Fix unused variable warnings on MacOS ARM64 (#2980) 2022-08-24 18:16:39 +02:00
Florian Märkl
aaa34e9281 Refactor global state of xnu debugger into RzXnuDebug struct
The chained_address in arm32 xnu_modify_trace_bit is left for now since
we don't test this platform yet.
2022-08-07 19:22:40 +02:00
GustavoLCR
5a54787eee
Fix pdb.autoload crash (#2729) 2022-06-23 10:50:11 +02:00
Theofilos Pechlivanis
d8ed585cba
Fix minor compiler warnings on i386 (#2585)
* Fix a `-Wpointer-to-int-cast` and a `-Wunused-variable` on i386
2022-05-03 22:23:14 +08:00
Florian Märkl
b40dde5fbf
Move DEBUGGER checks from C to meson.build (#2577)
Entire files are now avoided to be built by checking in meson rather
than using #if DEBUGGER. This now also includes bsd_debug.c, which
is currently slightly broken on OpenBSD/sparc64 and caused compile
errors even with -Ddebugger=false.
2022-05-02 11:22:35 +02:00
Frankenstein
9b618ca12f
Fixing compilation warnings on RISC-V (#2527) 2022-04-13 21:24:59 +08:00
GustavoLCR
170ab3eb3b
Remove windows.h include from rz_types.h (#2410)
* Create `rz_windows.h`
* Move `RzThread` structure definitions to internal header
* Create and use `rz_th_get_user()` API to avoid exposing `RzThread` layout in external header
* Make `rz_th_self()` an IPI
* Use `_wmkdir()` in `rz_sys_mkdir()` on Windows
* Remove unused `winkd_break_read` function
* Remove `RzIORap` definition from `rz_io.h`
* Remove include of `Windows.h` from `rz_types.h`
* Use `rz_windows.h` when necessary
* Remove `RzCoreRtrHost` definition from `rz_core.h`
* Remove `rz_socket.h` include from `rz_core.h`
2022-03-16 13:54:41 +01:00
David Carlier
fe3e1f47e8 debug: THP update possible system config paths. 2021-12-16 10:00:45 +01:00
Khairul Azhar Kasmiran
d73920c901
Fix -Wunused-function warning on Mac (#2070) 2021-12-05 17:38:53 +08:00
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +08:00
GustavoLCR
53a7694631
Add support for Windows on ARM (#1502)
* Support building for Windows on ARM

* Fix usage of reserved function name on ARM
* Fix architecture dependent `CONTEXT` fields access

* Fixes for debugging on Windows on ARM

* Fix breakpoint behavior on windows on ARM
* Fix register profile when debugging
* Remove `drx` error message if not supported
* Add support for hardware breakpoints
* Disable support for hardware single-stepping

* Fix Windows Message breakpoints on ARM

* Fix software single-stepping on return instruction on ARM

* Consider link register as destination for return instructions

* Fix setting debug bits to 16

* Rename `r12` to `ip` for windows arm register profile

* Remove debug bits hardcoding on windows

* Add 32bit registers to Windows ARM64 register profile

* Fix software step breakpoint alignment when entering thumb mode

* Define `RZ_TEST_ARCH` for `arm` and `arm64`

* Use `StackWalk64` API for backtracing on Windows

* Fix software single-stepping ARM in thumb mode

* Sync `asm.bits` with debugger

* Cleanup windows_debug.c

* Add SPDX for cross-arm64-windows.txt

* Add floating point control register flags

* Fix Windows Arm register profile alignment

* Keep `drx` warning
2021-11-24 20:13:42 +08:00
David CARLIER
73fa2b30a5
debug: descriptors list netbsd and porting fixes on linux version. (#2018)
took from the linux version, files descriptors per process are stored
 in a similar fashion.
2021-11-24 08:35:01 +08:00
David CARLIER
5ec700715a
debug: handle signals on NetBSD and little build fix. (#1719) 2021-09-19 10:52:58 +08:00
pancake
7483713268 Move linux specific thing used only in the debugger out of RUtil
Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2021-09-15 10:31:26 +08:00
David CARLIER
c913107d91
debug: generate coredump on netbsd. (#1603)
Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2021-09-07 12:08:13 +08:00
GustavoLCR
69611e103b
Remove RzDebug->user and use RzDebug->plugin_data instead (#1355)
* Remove doubled `rz_reg_set_profile_string()` call in `rz_debug_use()`
* Remove `RzDebug->user` and use `RzDebug->plugin_data` instead
* Fix crashes when switching between `native` and `windbg` debug plugins
2021-07-24 11:13:53 +02:00
Giovanni
f21be3b6d3
Fix various leaks (#1348)
* Fixed Leak in types code
* Fixed leak on `rz_cons_grep` in newshell
* Avoid flushing when cons is not used.
* Fixed memory leak in `rz_analysis_free`
* file_hashes is not used.
* `rz_bin_file_set_hashes` needs to be freed
* More timeout
2021-07-22 14:50:50 +08:00
Anton Kochkov
7ce60258bc Use RZ_LOG_INFO for debug messages 2021-07-20 17:36:25 +08:00
GustavoLCR
885c45a699
Refactor Windows debug code (#1318)
* Fix some handle leaks
* Fix some memory leaks
* Re-use handles if possible
* Avoid allocations inside loops in `w32_desc_list()`
* Use debug plugin functions instead of reimplementing logic in io_debug.c and io_w32dbg.c to maintain state consistency
* Remove unneeded code
* Rename some functions
2021-07-19 18:22:54 +08:00
Florian Märkl
78652caaf5 Add user pointer to RzDebug Plugins and Refactor GDB for it 2021-06-14 11:46:17 +02:00
Riccardo Schirone
53bf5c497f SPDX Copyright text for all files based on history
- Add LICENSES directory
- Download additional licenses used
- Add .reuse directory
- Add doc about SPDX/reuse

Co-authored-by: Florian Märkl <info@florianmaerkl.de>
2021-03-05 19:39:15 +08:00
Riccardo Schirone
2c54547ec0 Clean dependencies between modules and put them in order 2021-01-28 11:57:28 +01:00
Anton Kochkov
a0be4e2e64 Run clang-format 2021-01-21 22:05:44 +08:00
Anton Kochkov
48e353462a Workaround a multiline comment clang-format bug 2021-01-21 22:05:44 +08:00
Khairul Azhar Kasmiran
d5601cc2fe
Replace naked rz_sys_system/write/read/freopen calls with their wrapped counterparts (#388) 2021-01-19 00:07:19 +08:00
Florian Märkl
40a29cba29
Remove Pseudo-Sandbox (#239) 2020-12-21 21:31:32 +01:00
Riccardo Schirone
286f930b93 Use O_CLOEXEC when creating pipes so they are closed on exec
By default, pipes file descriptors are not closed on exec. This means
they are inherited by the child process. However, this may be a problem
in particular in multi-threading programs (e.g. rz-test), because EOF is
not sent to a pipe until the last pipe file descriptor is closed.

This commit makes sure that by default pipes are created with O_CLOEXEC,
so they are closed whenever an exec syscall is executed. Usually pipe
file descriptors are duplicated to be stdin/stdout/stderr of the
children process and those dupped file descriptors won't be closed on
exec.

In case pipe2 is not available (e.g. MacOS), we do a pipe + fcntl, which
is in theory racy (see man open(2)). For this reason pipe, exec, system,
etc. are wrapped in rz_sys and they use a global mutex to make sure a
pipe is either created and set as O_CLOEXEC or not created at all before
an exec operation is done.

On very old systems, O_CLOEXEC may not be available at all. In those
cases, which should be rare, we just keep a list of file descriptors
created with rz_sys_pipe that we need to close before executing another
process.

Interaction with external libs may be tricky. We expect external libs to
create files/pipes that need to be closed on exec with the right flags
and we expect rizin code to manually close pipes file descriptors as
appropriate if the exec syscall is executed by an external library
(non-rizin code).

Make sure execl is found by acr/make
2020-12-15 10:18:50 +01:00
Riccardo Schirone
85ce44b435 Ignore unresolved symbols in object files on FreeBSD
On some platforms (e.g. FreeBSD) by default -Wl,--no-undefined is passed
to the compiler, thus when generating the util library there is an
error, because `environ` is defined only in an executable. Let's
automatically add a linker option to ignore those errors on FreeBSD.
2020-12-09 18:37:30 +01:00
Anton Kochkov
041d73dce3
Change the "anal" abbreviation to "Analysis" in Code (#117) 2020-12-06 19:25:27 +01:00
Giovanni
35a9ef94c9
Code and comments cleanup (#108) 2020-12-04 18:11:51 +08:00
Anton Kochkov
b23222c2c8 Fix some warnings 2020-11-20 13:38:32 +08:00
Anton Kochkov
7ee14fb853 More renames 2020-11-12 12:27:04 +08:00
Anton Kochkov
539f60a1a8
Rename radare to rizin (#68)
* Rename radare to rizin

- Rename REvent to RzEvent
- Rename RBreakpoint to RzBreakpoint
- Rename RRune to RzRune

* Remove unnecessary files
2020-11-04 18:56:27 +08:00
Liumeo
8a319a2b09 Remove some of the ARM64 warnings (#17875) 2020-10-30 10:44:38 +01:00
Florian Märkl
6572b63794
Use Standard SPDX Header Comments (#51) 2020-10-27 09:04:11 +01:00
yossizap
284776d8ae Fix dp 0 not showing other processes on freebsd ##debug 2020-10-10 11:59:53 +08:00
Florian Märkl
2b19ace9fa Fix eprinf -> eprintf 2020-10-05 15:41:57 +02:00
Anton Kochkov
df8d0308bb
Import patches from radare2 (#15)
* Fix #17746 (buffer overflow in brainfuck disassembler) ##asm (#17747)
* Fix FreeBSD step error ##debug (#17749)

Co-authored-by: plaets <49844988+plaets@users.noreply.github.com>
Co-authored-by: yossizap <yossizap@gmail.com>
2020-10-05 10:46:24 +02:00
Riccardo Schirone
502e91aff7
Rename R_ and R2_ to RZ_ (#8)
* Rename R2_ -> RZ_
* Rename R_ -> RZ_
* Rename R2R_ -> RZ_TEST_
* Rename R2R defines and types to RZ_TEST/RzTest
* Keep R_ for REIL registers
2020-10-02 16:09:13 +02:00
Riccardo Schirone
721609a17b
Rename to rizin (#2) 2020-10-01 16:13:03 +02:00
Renamed from libr/debug/p/debug_native.c (Browse further)