Commit graph

68 commits

Author SHA1 Message Date
Giovanni
bd44250fd6
Add new implementation of RzConfig (#5820) 2026-05-03 15:34:48 +08:00
Florian Märkl
245e198cf1
RzReg: Associate roles with RzRegItem instead of name strings (#6291)
Register roles (RzRegisterId) are now associated directly with an
RzRegItem in RzReg rather than mapping to name strings, which previously
needed an additional hashtable lookup to get more information about the
register. Conversely, if the name is needed from an RzRegItem, it is
available directly as a member.

This is not a pure refactor as there were cases before where a register
name was assigned to a role in the register profile, but no register
actually existed under that name. Such cases will now cause a warning to
be printed during profile load and the role association will be ignored.
Changes in register profiles in this commit are for fixing such cases.
2026-04-30 12:03:51 +02:00
Giovanni
ea21a4a7b4
Implement colors for tables and move RzListInfo out of table.c (#5729) 2026-01-05 21:34:41 +08:00
well-mannered-goat
a77afb0a29
Refactor debug native plugin archos-wise and other minor refactors (#5295)
- separate plugin archos wise.
- move all register profiles under reg directory.
- move architecture specific from linux_debug.c and bsd_debug.c to respective files.
- replace eprintf with rz_sys_perror and RZ_LOG_*
- remove debug_native.c and reg.c
- refactor librz/debug/meson.build to compile the native plugins archos wise.

This improves code readability and maintainibility.
2025-09-01 00:00:35 +08:00
Ahmed Kamal
7bf87c4a09
Remove static vars from librz/core/windows_heap.c (#5326) 2025-08-29 08:30:04 +08:00
Giovanni
76d41f75f8
Fixes for Haiku OS (#5149)
* Fix sys.c unused variable.
* Add native/unsupported.c
* Clean rz_debug.h from comments and functions which does not exists
* Add fall-thru comment for haiku os case
* Fix warning: "MIN" redefined /boot/system/develop/headers/posix/sys/param.h:18: note: this is the location of the previous definition
2025-05-18 20:17:40 +08:00
Giovanni
144b47d455
Move RzBreakpoint into RzDebug (#5124)
- Move trap/sw breakpoint into RzArch
- Remove RzBreakpointPlugin & RzBreakpointArch
- Add get_sw_breakpoint_at/get_sw_breakpoint_size_at binds
- Remove `dbh-`
- Change `dbh` to just list supported archs for sw breakpoints
- Implement correct PPC traps
- Add missing x86 breakpoint callback
2025-05-13 01:57:37 +08:00
Rot127
a3e9fec7f4
Fix leaks during register profile parsing. (#4813)
* Add ownership info to reg_profile

* Fix leaks during register profile parsing.
2025-01-02 15:03:31 +00:00
Rot127
87b75910b5
Port remaining debug commands to RzShell (#4753)
* Port `dmhb` to RzShell
* Port `dmhf` to RzShell
* Remove 'to' argument from rz_core_debug_continue_until(). It was never used in the whole function. Hence, whatever it was supposed to do, it didn't
* Port `dcu` to RzShell
* Fix tests of `dmh[bf]` commands
* Port `dmi` commands to RzShell
* Port `dmx` to RzShell
* Remove `dta` command.

Originally it limited the addresses to trace.
But it was not used in any test, and the implementation was not optimal.
It allowed only specific addresses (no range).
Also worked on strings (not ut64 values).
Also, the usefulness is limited, considering the alternative
to just not tracing a certain address.

* Add quiet and quietest mode to `dmi` commands.

This also removes the test for `dmias`.
The command was not documented and it doesn't seem to
do anything special `dmia` can't do.
2024-12-06 08:10:25 +08:00
Rot127
30953d3bf6
refactor: Use HtSP for storing plugins. (#4687)
* Refactor: Use HtSP for storing plugins.

This saves iterations when searching for a plugin of a given name.
It also allows to save plugin configurations and data in hash table,
all addressed by their name. Hence, usage is more streamlined.

* Fix: iterators iterate over pointers of pointers.

* Soften the NULL check.

If arch is passed on from another struct, NULL is an allowed invalid value.

* Fix some leaks

* Fix NULL checks and incorrect inits

* Fix more leaks

* Add warning if plugin with same name was added before and is overwritten.

* Document rz_str_cmp

* Add function to create new list from iterator.

* Sort plugins alphabetically when listed.

* Fix parameter attributes, NULL checks, leaks and single rename.
2024-10-26 16:31:13 +08:00
pelijah
f2d8e0db3d
Add HtSP, HtSS, HtSU, SetS (#4415)
- All `ht_*_new0()` are removed
- `freefn` field of HT options was renamed to `finiKV`
- `finiKV_user` fields was added to HT options
- Added `ht_*_new_opt_size` API
- `HtSP` and `HtUP` are created with `ValueFree` callback  that allows to reduce extra LOC and prevent bugs
- `SetP` replaced with `SetS` (based on `HtSP`)
- `rz_th_ht_*_new0()` and `rz_th_ht_*_new_opt()` are replaced with `rz_th_ht_*_new(HtXX *)`
2024-04-16 20:27:48 +08:00
z3phyr
de4a3c7419
Enhance dmht tcache command (#4355)
- Add tcache heap heuristics
- Fetch glibc version from libc
- Add unit testcases for glibc version

Co-authored-by: Giridhar Prasath R <giridh1337@gmail.com>
2024-03-22 11:00:58 +08:00
wargio
d47ceedbd3 Merge rz_asm and rz_analysis into one library but keep deprecated apis.
The tms320c64x has been merged into tms320.
2024-03-07 18:38:49 +08:00
Huzaifa
58f7032f26
Add C API rz_debug_switch_to_first_thread() (#4287) 2024-02-26 21:13:33 +08:00
Florian Märkl
f3469946c5 Add specifiable size for watchpoints and tests
rz_bp_size_at() is not always the right size for a watchpoint, so we add
the possibility to specify the size as an extra argument to dmw.
2023-09-16 22:35:20 +08:00
Giovanni
8efdb3d3a3
Refactoring debug plugin and cleanup output (#3634) 2023-07-04 10:42:41 +08:00
Riccardo Schirone
c4767cf1ac
Fix plugin removal and clean code (#3277)
* cmd: Fix summary of few "L" sub-commands
* util: start decluttering plugins handling

- Add Doxygen docs
- Remove unused API functions and make others internal only
- Use RzLibType enum for plugin type instead of int

* util: move dlopen/dlsym/dlclose to rz_sys
* util: make rz_lib_open/close return bool
* util: simplify rz_lib_add_handler and rz_lib_open*
* libs: implement rz_*_plugin_del to remove a plugin
* core: remove commands from RzCmd when removing plugins
* librz: call plugins 'fini' method when removing a plugin
* core/cmd: do not fail if the hashmap removal fails

When removing a group command, the inner command might have the same
name, thus it would result in trying to remove the same name twice.
Ignore it, as it is fine.

* librz: make RzCrypto plugins handling like the others
* librz/crypto: add rz_crypto_reset and use it
* librz: allocate the plugin structures before adding them
2023-01-16 13:32:46 +01:00
wargio
f137f983a7 Remove unimplemented methods in debug 2022-12-04 16:53:58 +01:00
wargio
47e674acb6 Adds sync_registers in debug plugin and cleanup brainfuck debugger 2022-12-04 16:53:58 +01:00
Khairul Azhar Kasmiran
0493acc8b8
Fix up rz_debug_trace_ins_after() (#3216) 2022-11-30 23:38:26 +08:00
Anton Kochkov
4a037c2f2a
Convert dk commands to the rzshell (#3078) 2022-10-11 18:02:52 +08:00
Anton Kochkov
87e369b9a7
Convert de commands to the rzshell (#3083) 2022-10-10 22:10:48 +08:00
Anton Kochkov
d0bd24cf26
Convert dp commands to the rzshell (#3047) 2022-09-27 01:21:25 +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
Florian Märkl
8681cdc43b Use cpu_type_t for checking xnu debuggee's arch
This fixes basic single-stepping on macOS/arm64.
dbg->bits is affected by all kinds of things going on in rizin, in
particular it currently randomly switches to 16 when calling pd during
an arm64 debug session, causing the stepping code to break.
We now fetch the cpu type of the process once during attach, similar to
how lldb does it. They also use 0 for the "invalid" value, so we do that
as well.
2022-08-07 19:22:40 +02:00
Florian Märkl
1d88af3c56
Refactor and replace .dm* calls with pure C (#2847)
This fixes the following minor issues:
* Errors like "Cannot create flag (...) because there is already (...)
  flag" during debug startup
* Unnecessary seeks during .dm* causing io reads and e.g. delays of up
  to 5s on x86 macOS during debug startup
* Flags are now created in the "maps" flagspace, rather than globally,
  making them easier to clean up later
* Flags now have the same size as the maps and not +1
2022-07-28 13:40:44 +02:00
Riccardo Schirone
2987e035da hash: use RzHash in most hash APIs 2022-06-28 21:55:26 +08:00
Riccardo Schirone
9ea7c2fa5a RzHash: rename everything in librz/hash to RzHash prefix 2022-06-28 21:55:26 +08:00
Dean
e7f85fd409
Clean up headers (#2719)
* Remove duplicate declarations
* Remove undefined functions
2022-06-22 07:30:50 +08:00
GustavoLCR
f10e5d865a Debug: Allow dce in all platforms
* Used for `WinKD` and `Windows` debug
2022-06-05 00:27:35 +08:00
billow
e767046197
Convert dL to rzshell (becomes dl) and expose API
- Convert `dL` to rzshell
- `dL` becomes `dl`
- Expose `rz_core_debug_backtraces()` API
- Expose `rz_core_analysis_hint_set_offset()` API
2022-05-13 20:17:56 +08:00
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
Riccardo Schirone
12f7a4a6a5
Move CMD_CHECK_DEBUG_DEAD outside rz_debug.h (#2430) 2022-03-22 23:06:05 +08:00
billow
3632192818
Convert dt commands to rzshell (#2418) 2022-03-22 09:12:12 +08:00
GustavoLCR
849b734803 Support debugging DMP files
* Add `dmp` debug plugin
* Set `dbg.backend` later in rizin main when the backend is `dmp`
2022-03-03 21:52:41 +08: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
490fb69685 Refactor: Replace corebind by need-driven context in RzBreakpoint 2022-01-26 17:12:26 +01:00
Florian Märkl
b6f09fb6ad Make as command ready for RzReg splitting
* rz_debug_arg_get/set moved to core as rz_core_arg_get
* Syscall (as) code refactored to always use rz_core_reg_default()
  instead of hardcoded debug
2021-12-21 13:14:08 +01:00
Florian Märkl
db25123a59 Remove RzDebug.creg and clean its usages
This was holding the name of a "current" register that was awkwardly set
during register printing, to then be used for setting in visual mode.
The features make sense, but it's too confusingly implemented to be
useful or stable.
2021-12-21 13:14:08 +01: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
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +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
Anton Kochkov
c14a09f946 Remove unused RzFList 2021-10-21 16:45:09 +08:00
Dhruv Maroo
23e264c10d
Fix function return type for rz_debug_.*_wait functions (#1766)
* Fix function return type for `rz_debug_.*_wait` functions

* Use preprocessor condition to use `RzDebugReasonType` only for Windows

* Return `RzDebugReasonType` instead of `int` for `.*_wait` functions

* Use correct return values for wait functions in debug
2021-10-06 16:04:30 +05:30
Dhruv Maroo
a527b204d8
Add API function for RzBreakpointItem and fix breakpoint serialization tests (#1750) 2021-09-26 10:17:13 +02:00
Dhruv Maroo
2c48a91d13
Add serialization functionality for breakpoints (#1574)
* Migrate project from v5 to v6
* Add serialization for debug (RzDebug) instance (only for breakpoints as of now)
* Replace commit hash once the PR is merged into dev
* Add new namespaces added in v6
2021-09-24 12:30:28 +00: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
Anton Kochkov
b9cb29ac90
Rename RNum to the RzNum (#1539) 2021-08-29 21:06:29 +02:00
GustavoLCR
56841703e1
Various debug fixes (#1359)
* Fix regression showing threads `rip` for `dpt` on Windows
* Improve `dpt` output
* Consider flags too when printing thread address
* Improve `RzCoreBind->getNameDelta` to use realname if `flags->realnames` is true
* Fix negative offsets
* Fix flagspace selection side-effects after calling `rz_core_bin_apply()` APIs
* Fix wrong register profile after attaching to a process with `dpa`
* Fix wrong base address when opening a process memory
* Fix wrong register profile after opening a process memory
* Implement `rz_debug_reg_profile_sync()`
* Fix diff tests
2021-07-27 15:03:08 +08:00