Commit graph

44 commits

Author SHA1 Message Date
Peiwei Hu
886dfa5c17
Transition from list to pvector for symbols in RzBinPlugin (#4077) 2024-01-06 19:54:19 +08:00
Khairul Azhar Kasmiran
398b4ae8de
dsui: Remove error msg on success (#3913) 2023-10-08 22:21:50 +02: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
Anton Kochkov
b5a936585a Rename analop to analysis_op and aop 2023-06-26 08:40:47 +08:00
Anton Kochkov
d010892648
Convert dcs to the rzshell (#3403) 2023-02-28 14:24:55 +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
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
7c0bd7cd03 Convert dW command to the rzshell 2022-09-30 15:52:08 +08:00
Anton Kochkov
2a22a1fcc6 Convert dw command to the rzshell 2022-09-30 15:52:08 +08:00
Anton Kochkov
c5e901c332 Convert dg command to the rzshell 2022-09-30 15:52:08 +08:00
Anton Kochkov
4bf6b67212
Convert dd commands to rzshell (#3049)
* Convert `dd` command to rzshell
* Remove unimplemented `dH` command
* Remove `ddt` command
* Move `date` command to the "shell" category
2022-09-29 08:24:50 +08:00
Anton Kochkov
1d7458150e
Convert dx commands to the rzshell (#3043) 2022-09-28 00:49:09 +08:00
Anton Kochkov
d0bd24cf26
Convert dp commands to the rzshell (#3047) 2022-09-27 01:21:25 +08:00
Anton Kochkov
8fd06cd6b7
Convert di commands to the rzshell (#3041) 2022-09-20 20:35:20 +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
0f352c3ab3 Move RzDebug APIs to the cdebug.c 2022-09-08 07:41:18 +08:00
Giovanni
c89b12a046
Removed plenty of eprintfs in rz_core (#2950) 2022-08-29 00:32:17 +08: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
Peiwei Hu
0fc9c9682e
Fix some checks of rz_analysis_op (#2755)
* Fix some checks of rz_analysis_op
* rm unreachable code
2022-07-01 18:12:14 +08:00
GustavoLCR
23a3468834 Fix register flag address not updating after dc 2022-06-17 21:15:59 +08:00
GustavoLCR
f10e5d865a Debug: Allow dce in all platforms
* Used for `WinKD` and `Windows` debug
2022-06-05 00:27:35 +08:00
Anton Kochkov
2188b4564d
Various Coverity fixes (#2615)
* Fix CID 392733 - memory leak

* Fix CID 392732 - memory leak

* Fix CID 392730 - memory leak

* Fix CID 392729 - memory leak

* Fix `rz_analysis_diff_free()` API function

* Fix CID 392685 - memory leak

* Fix CID 392012 - use after free

* Fix CID 391968 - uninitialized pointer read

* Fix CID 391966 - memory leak

* Fix CID 391964 - uninitialized pointer read

* Fix CID 390013 - memory leak

* Fix CID 389939 - memory leak

* Fix CID 379249 - memory leak

* Fix CID 378881 - uninitialized scalar variable

* Fix CID 378973 - uninitialized scalar variable

* Fix CID 378850 - uninitialized scalar variable

* Fix CID 371079 - memory leak

* Fix CID 367478 - memory leak

* Fix CID 366821 - memory leak

* Fix CID 366736 - memory leak

* Fix CID 361684 - uninitialized scalar value

* Fix CID 352581 - memory leak

* Fix CID 352557 - memory leak

* Fix CID 348937 - memory leak

* Fix CID 322229 - memory leak

* Fix CID 320122 - memory leak

* Fix CID 317611 - memory leak
2022-05-15 23:15:28 +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
billow
457105f640
Convert do to rzshell (#2573)
* `doo` -> `ood`
* `doof` -> `oodf`
* expose `rz_core_debug_process_close()` API
2022-05-07 09:07:02 +08:00
Riccardo Schirone
8624495e36 RzBin/dmp64: implement strings method to check only data 2022-05-06 18:09:17 +02:00
billow
bb4167acc9
Convert ds commands to the rzshell (#2574)
* expose `rz_core_debug_step_until_frame()` API
* expose `rz_core_debug_step_over()` API
* expose `rz_core_debug_step_skip()` API
* expose `rz_core_debug_step_back()` API
2022-05-06 16:18:20 +08: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
Riccardo Schirone
78bbf5ba80
RzCore: remove as many #include .c as possible in cmd.c (#2378) 2022-03-17 10:30:57 +08:00
Giovanni
6d5e235a9a
Convert rz_print_date_* to rz_time_date_* (#2375) 2022-03-03 17:25:00 +01:00
Anton Kochkov
2f638cad1e Convert f commands to rzshell
* Changed behavior of `f` to only add flag if there is none
* Changed behavior of `f+` to add flag in any case
* Moved listing subcommands from `f` to `fl`
* Moved listing subcommands from `f.` to `f.l`
* Added subcommand `f.l*` to list all local flags in all functions
* Listing flags at the current offset became `fl.`
* Moved `f=` to `fl=`
* Old `fl` (flag length) now became `fL`
* Removed original `fe` commands
* Old `f?` (check if flag exists) now became `fe`
* Removed `fV` commands
* Removed `fn` commands in favor of `fl` and `asm.flags.real=true`
* Removed `fS` commands (`fSo` and `fSn`)
* `fo` became `fortune` and moved from "flags" to "shell" category
* Removed oldshell handlers of the `z` commands
2022-02-03 21:46:42 +08: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
Anton Kochkov
638872ca47
Use API instead of commands in Visual Panels (#2163) 2022-01-03 11:05:22 +08:00
Florian Märkl
9b60670013 Prepare various RzReg accesses for splitting
Common accesses for both debug and analysis must not use
debug->reg or analysis->reg, but go through rz_core_reg_default().
2021-12-21 13:14:08 +01:00
Florian Märkl
76eb7bf182 Refactor debug checks and flags from registers
* Added rz_core_is_debug() to check for debug mode instead of hard-coding "cfg.debug"
* rz_core_reg_default() uses the above to get the currently relevant RzReg
* rz_core_debug_regs2flags() -> rz_core_reg_update_flags() uses the above
  to update the flags.
2021-12-21 13:14:08 +01:00
Dhruv Maroo
a255ff57a2
Fix some more Coverity issues (#2044)
* C352467: Free the heap allocated string after appending to `RzStrBuf`

* Remove unused variable `nofail`

* C352453: Free `fieldstr` after appending to `format`

* C350836: Free `name` before returning inside the loop

* C349252, C349231: Free `ta` when breaking halfway through the loop

* C349248: Free `pj` before breaking from switch statement

* C366622: Check result of `strtok` (`fcnname_aux`) for `NULL`

* Free `RzList` before returning from macro `SYNC_READ`

  * Fixes Coverity issues 366625, 366624, 366623, 366621 and probably
    a few others as well

* C366620: Check `arg` for `NULL` before dereferncing in `strchr`

* C366618: Cleanup `parse_lis` and use `rz_str_*` API instead of C `str` API

* Fix `SYNC_` macros in `cmd_regs.c` to no return prematurely

* C365952: Check `x` for `NULL` before dereferencing

* C365936: Use a wider integer type for the bitshift

* C365808: Fix double free of `real_type`

* C365805: Remove redundant `NULL` check for `path`
2021-12-13 23:09:46 +08:00
Florian Märkl
3c2e4bf63a
Rewrite ar and dr with newshell (#2006)
* Show group-level details of commands

Details can be defined at either a group command or its subcommand of
the same name. If define on group-level it will also be shown in the
group help without needing ??.

* Fix > $ redirection for errored command and leak

* Rewrite ar and dr commands with newshell

Breaking changes:
ar* => arf, ar- => arf-, ar. => ar*
ar, => art, ar? => arq
ar0 => ara0, arb => arab, ars => araS
arC => arpC
arn => arR
art => arT
arf => arF
Removed: drm, aer
2021-12-06 19:02:43 +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
289536cc04
Unscramble Register Printing and Flags Logic (#1920)
* Added rz_analysis_get_address_bits() instead of arch-specific hacks in core
* flags are only set for address-sized registers
* dr/ar show registers of any size by default, but hiding registers that are entirely
  covered by others
2021-11-17 11:44:14 +01:00
Anton Kochkov
036f1490d0 Move command handlers to librz/core/cmd 2021-10-18 18:00:17 +08:00
Renamed from librz/core/cmd_debug.c (Browse further)