Commit graph

216 commits

Author SHA1 Message Date
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
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
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
Anton Kochkov
6bdcbc5124
Fix unused variable warnings on MacOS ARM64 (#2980) 2022-08-24 18:16:39 +02:00
Florian Märkl
4e5857cacf
Meson refactor: collect modules in dict and centralize config (#2945)
Duplicated code for pkg-config and cmake configuration is avoided by
letting every rizin module register itself in a global dictionary
called "modules" which is then iterated in one place to perform any
shared logic, inspired by how qemu handles multiple targets in its meson
build system.

This is an almost pure refactor, so the resulting .pc/.cmake files
should be identical with the following exceptions:
- rz_reg.pc does not have plugindir anymore as rz_reg has no plugins.
- Some other modules have their dependencies in .pc files altered to be
  consistent with cmake.
2022-08-20 19:59:27 +02:00
wargio
a73e8ecd4d Add references and flags to constant pointers to data maps 2022-08-13 22:52:24 +02:00
Florian Märkl
e893d2fb66 Fix arm64 register access in xnu debugger
ARM_THREAD_STATE64 fetches arm_thread_state64_t but our struct was
arm_unified_thread_state_t, which adds a header. The pc in the register
profile was hacked to account for the shift, but all the x-regs were
not, so x7 had the value of x8 for example. Now we just use the specific
state for 32 or 64.
2022-08-07 19:22:40 +02: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
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
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
GustavoLCR
d3446789c7 Windows: Various fixes
* Fix some XP incompatibility
* Use wide version of APIs
* Remove unused/unnecessary function pointers
2022-07-24 21:00:51 +08:00
Riccardo Schirone
a689f0a86e librz: refactor a bit how plugins are built
Rely on RZ_ARRAY_SIZE to add librz plugins instead of NULL terminators.
2022-07-20 22:04:02 +02:00
Florian Märkl
97cc3ee4b7 Remove unused variable in xnu_debug.c 2022-07-17 20:31:32 +02:00
Florian Märkl
0d02fdd0c4 Fix rz_xnu_get_cur_thread() messing up the target's mappings
Getting the thread list with task_threads() allocates a mapping in the
caller's memory that should then be freed with vm_deallocate() later.
However rz_xnu_get_cur_thread() was passing the debuggee's task to the
deallocate rather than its own, meaning the thread list would probably
leak and the debuggee's maps would get broken if there was something at
that address.
2022-07-17 20:31:32 +02:00
Florian Märkl
f6664c2cee Fix detaching in XNU Debugger
PT_DETACH must always be called, even when killing the process.
2022-07-17 20:31:32 +02:00
Florian Märkl
e6ab93e4cc Fix attaching in XNU Debugger
ptrace with PT_ATTACHEXC will send a SIGSTOP to the process, which we then
sometimes received in the first mach_msg loop while waiting for hitting a
breakpoint, when having been already attached at this point.
See also bsd/kern/mach_process.c:287 in xnu-8020.121.3.

Correct attaching works like this, in exactly this order:
* posix_spawn the process with POSIX_SPAWN_START_SUSPENDED
* set up the Mach port for receiving exceptions
* ptrace(PT_ATTACHEXC) -> sends SIGSTOP
* wait on the Mach port until receiving the SIGSTOP msg
* call task_suspend
* reply to the msg

Then we have a beautiful process suspended right at the start in dyld.
2022-07-17 20:31:32 +02:00
Florian Märkl
584fb0e4e9 Improve logging for EXC_SOFTWARE on XNU, showing Unix signals 2022-07-17 20:31:32 +02:00
Florian Märkl
c90ebb6b68 De-include xnu_threads.c and xnu_excthreads.c
With XNU_USE_PTRACE removed, these source files can now be compiled as
standalone objects unconditionally.
2022-07-17 20:31:32 +02:00
Florian Märkl
c671083925 Remove XNU_USE_PTRACE
The ptrace-based backend is broken and has been disabled by default
since 2016.
2022-07-17 20:31:32 +02:00
Riccardo Schirone
8939fdbd7d
Use add_global_arguments instead of passing cflags/ldflags all around (#2812)
See also 66a0e22293/docs/TESTING_WITH_SANITIZERS.md (clang)
2022-07-17 21:33:51 +08:00
Anton Kochkov
b2d9429129
Remove sdb json (#1118)
* Drop sdb_json in `librz/cons/grep.c`
* Do not print the JSON key in grep
* Use proper JSON paths in tests
* Use signed number in case of RzJson in tests
* Do not add quotes for sole RZ_JSON_STRING
2022-07-12 22:48:33 +08: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
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
GustavoLCR
5a54787eee
Fix pdb.autoload crash (#2729) 2022-06-23 10:50:11 +02:00
GustavoLCR
3bc60f6800 WinKD: Add nullability/ownership markers to functions 2022-06-05 00:27:35 +08:00
GustavoLCR
951a33c490 WinKD/DMP: Use backtrace_generic() for dbt for arm and x86 2022-06-05 00:27:35 +08:00
GustavoLCR
8de1000532 Debug: Implement backtrace_generic() 2022-06-05 00:27:35 +08:00
GustavoLCR
aa8fb63b39 WinKD/Windows: Extract common parts to common_windows.c 2022-06-05 00:27:35 +08:00
GustavoLCR
f10e5d865a Debug: Allow dce in all platforms
* Used for `WinKD` and `Windows` debug
2022-06-05 00:27:35 +08:00
GustavoLCR
953ffb47fb WinKD: Switch to current process and thread 2022-06-05 00:27:35 +08:00
GustavoLCR
cd1f5469ab WinKD: Use kernel module address from version packet 2022-06-05 00:27:35 +08:00
GustavoLCR
384cbe6c9d WinKD: Set dbg.bpinmaps to false 2022-06-05 00:27:35 +08:00
GustavoLCR
c8eb8e5082 WinKD: Get x64 frames 2022-06-05 00:27:35 +08:00
GustavoLCR
811a9a2819 WinKD: Fixes for packet sending/receiving
* Ignore resent packets
* Resend packet if we didn't get an ACK
* Break if Ctrl-C is pressed
* Always wait for a state change packet in debug event wait function
2022-06-05 00:27:35 +08:00
GustavoLCR
e63faa6005 WinKD: Fix incomplete register write
* Fix register read size
2022-06-05 00:27:35 +08:00
GustavoLCR
dbed351f19 DMP/WinKD: Basic memory mapping info 2022-06-05 00:27:35 +08:00
Riccardo Schirone
ce6ac3e467 meson: use major/minor only in the lib soversion 2022-05-10 21:04:43 +02:00
GustavoLCR
a73b845304 WinKD/DMP: Use cfgSetI core bind method 2022-05-10 10:22:49 +08:00
GustavoLCR
6b95dc16ae WinKD/DMP: Quote pdbpath for idp command 2022-05-10 10:22:49 +08:00
GustavoLCR
10990d9ce9 WinKD: Fix getting kernel address in early initialization
* Use saved kernel module info gotten from `DbgKdLoadSymbolsStateChange` packet
2022-05-10 10:22:49 +08:00
GustavoLCR
a9ea591ade WinKD: Keep a cache of current thread context 2022-05-10 10:22:49 +08:00
GustavoLCR
3cabf34561 WinKD: Remove winkd_lock_tryenter()
* Use `winkd_lock_enter()` and make it possible to break it through `RzCons`
2022-05-10 10:22:49 +08:00
GustavoLCR
f423a02129 WinKD/DMP: Add verbose logging to winkd_build_profile() 2022-05-10 10:22:49 +08:00
GustavoLCR
e9cffc0afa WinKD: Create profile dynamically if not found
* Download kernel module and PDB
* Load kernel PDB info
2022-05-10 10:22:49 +08:00
GustavoLCR
61235f02a0 WinKD: Fix pids/tids cache
* Fix double-free of name in debug modules list
2022-05-10 10:22:49 +08:00
GustavoLCR
7db85c9a69 WinKD: Disable unimplemented step function 2022-05-10 10:22:49 +08:00
GustavoLCR
10cfd66598 WinKD: Avoid unnecessary re-syncing 2022-05-10 10:22:49 +08:00