Commit graph

35 commits

Author SHA1 Message Date
Riccardo Schirone
962ffe2755 RzDebug/p/native: do not use ptrace with NT_X86_XSTATE if not supported
If the kernel/system where Rizin is currently run does not support
ptrace(PTRACE_GETREGSET, ..., NT_X86_XSTATE, ...), ENODEV is returned by
the kernel. In such cases, we print the error message once and never
execute the ptrace call again, assuming it is not supported.

Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2022-04-05 14:14:35 +02: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
Florian Märkl
06ccd06197 Add unit tests for software breakpoints 2022-01-26 17:12:26 +01:00
Florian Märkl
3b0b966b29 Remove dbg.bpsize and instead calculate when needed
In practice, dbg.bpsize was always automatically set to
rz_bp_size(core->dbg->bp, core->analysis->bits) whenever the global bits
changed. But this breaks as soon as different bits are needed for where
the breakpoint is supposed to be set vs. the current value of asm.bits
(for example for thumb/arm32).
So this removes the global bpsize and always calculates it for the
specific breakpoint address.
As a sidenote, dbg.bpsize was not even used for manual db (for dcu it
was though).
2022-01-26 17:12:26 +01:00
Florian Märkl
7586e43625 Make breakpoint size respect address-specific bits
On thumb/arm, the current analysis->bits value may not be equal to the
bitness of code that a breakpoint is supposed to be set to. This caused
software breakpoints to be created with incorrect data.
Now the bits for an address is queried by bp through a callback instead
of using a global bp->bits value which would usually correspond to the
current seek, but not the breakpoint addr.
2022-01-26 17:12:26 +01:00
Florian Märkl
490fb69685 Refactor: Replace corebind by need-driven context in RzBreakpoint 2022-01-26 17:12:26 +01:00
Paul I
43aba6bec9
Fix memory leak in rz_debug_free() 2022-01-15 23:49:21 +08:00
Florian Märkl
b179a5f3c6 Refactor rz_debug_reg_get()/set()
* Logic for getting a register by role or name, whichever matches, moved
  to RzReg (rz_reg_get_by_role_or_name)
* Removed rz_debug_reg_err() because it's unnecessary
* Added rz_core_reg_getv_by_role_or_name() and
  rz_core_reg_aetv_by_role_or_name() to replace rz_debug_reg_get() for
  for usage whenever it is not debug-specific.
2021-12-21 13:14:08 +01:00
Riccardo Schirone
d8cd049652
Windows on non-x86 arch was still using non-existing RZ_BP defines (#2112) 2021-12-17 19:09:59 +01:00
Dhruv Maroo
3d6b7f0235
Cleanup dbl command handler; Remove rz_bp_list (#2012) 2021-11-25 22:33:24 +05:30
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
Florian Märkl
2ee8d603f8
Do not ask about killing the process if it is impossible (#1914) 2021-11-01 14:03:27 +08:00
Florian Märkl
7aeff0fc51
[Debug] Let gdb attach regularly and reset reason after attach (#1913) 2021-10-31 21:23:36 +01:00
Dhruv Maroo
178701f721
Reduce registers shown in the output of dr and Vpp when analysing an ARM64 executable (#1739)
* Add function to check if a register is a system register

* Only checks for ARM64 system registers as of now

* Check for system registers in ARM64 when printing registers using "dr"

* Does not completely remove the unnecessary register, but removes a
  huge number of useless registers printed by "dr"

* Rename `RZ_REG_TYPE_ALL` to `RZ_REG_TYPE_ANY`

* ADd register types for "sys" and "pauth": `RZ_REG_TYPE_SYS` and
  `RZ_REG_TYPE_PAUTH` respectively

* Remove `rz_reg_is_system_reg`

* Add `sys` and `pauth` register profiles

* Update debug tests to account for new arenas and register profiles

* REplace "pauth" with "sec" reg profile

* Update integration tests to account for new register profiles: `sys`, `sec`
2021-09-28 23:49:55 +08:00
Dhruv Maroo
a527b204d8
Add API function for RzBreakpointItem and fix breakpoint serialization tests (#1750) 2021-09-26 10:17:13 +02:00
Giovanni
74a9ed8ba8
Fix various Coverity bugs (#1569)
* CID 316598: Logically dead code (DEADCODE)
* CID 315963: Resource leak (RESOURCE_LEAK)
* CID 316731: Logically dead code (DEADCODE)
* CID 316000: Logically dead code (DEADCODE)
* CID 315918: Logically dead code (DEADCODE)
* CID 315950: Logically dead code (DEADCODE)
* CID 315965: Logically dead code (DEADCODE)
* CID 316044: Logically dead code (DEADCODE)
* CID 316064: Logically dead code (DEADCODE)
* CID 316067: Structurally dead code (UNREACHABLE)
* CID 316077: Logically dead code (DEADCODE)
* CID 316083: Logically dead code (DEADCODE)
* CID 316165: Missing break in switch (MISSING_BREAK)
* CID 316202: Logically dead code (DEADCODE)
* CID 316206: Logically dead code (DEADCODE)
* CID 316230: Logically dead code (DEADCODE)
* CID 316234: Logically dead code (DEADCODE)
* CID 316241: Logically dead code (DEADCODE)
2021-09-02 14:10:00 +02:00
Anton Kochkov
abc1d79f95
Add missing copyrights (#1570)
* Add missing SPDX copyrights

* Fix include headers
2021-09-02 16:39:50 +08:00
Anton Kochkov
b9cb29ac90
Rename RNum to the RzNum (#1539) 2021-08-29 21:06:29 +02:00
GustavoLCR
b84158fd3e
Fixes for value analysis (#1520)
* Fill `op->reg` for ARM64 `br`/`blr` analysis
* This fixes software single-stepping on `br`/`blr` instructions on ARM64
* Fill `op->reg` for ARM `bx`/`blx` analysis
* This fixes software single-stepping on `bx`/`blx` instructions on ARM
* Set `bx` as `RZ_ANALYSIS_OP_TYPE_RJMP`
* Fill `RzAnalysisValue->type`
* Use only `RzAnalysisValue` in `rz_core_link_stroff()`
* Fill `op->ireg/disp/scale` for ARM `ldr` analysis
* This fixes software single-stepping for `ldr pc` on ARM
* Fix riscv inverted src/dst values for store instructions
* Fix riscv analysis with buffer of size 2
* Add unit tests for `RzAnalysisOp` and `RzAnalysisValue`

Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
2021-08-27 22:07:39 +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
Paul I
8a69088719 Use HtUP for storing trace nodes 2021-03-01 18:47:53 +01:00
Alexis Ehret
35f6a1c53f Fix dead assignment librz/debug/debug.c 2021-02-09 10:37:25 -01:00
Anton Kochkov
a0be4e2e64 Run clang-format 2021-01-21 22:05:44 +08:00
yossizap
06f23ea202 Fix crash after tracing an invalid opcode ##trace 2021-01-05 23:34:09 -06:00
Florian Märkl
d53d1e3845
Final Analysis Renaming (#124)
* Rename missing Analysis Defines
* Rename analysis config vars and other lower case stuff
* Rename test/db/analysis
* Fix analysis tests

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2020-12-08 15:05:24 +08:00
Anton Kochkov
ad36954adb
More renames of *anal* to *analysis* (#123) 2020-12-07 13:20:29 +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
Liumeo
e9834fabe2 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-20 13:38:32 +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
Florian Märkl
6572b63794
Use Standard SPDX Header Comments (#51) 2020-10-27 09:04:11 +01: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/debug.c (Browse further)