Commit Graph

297 Commits

Author SHA1 Message Date
Tiago Gasiba
f0a2d8657d Add support for conditional breakpoints running r2 commands 2016-09-01 19:11:46 +02:00
pancake
722e568d66 Implement drb[1,2,4,8] 2016-08-31 11:25:18 +02:00
Tiago Gasiba
3e21569722 Fix dbic <num> <cmd> Arg parsing 2016-08-28 15:48:38 +02:00
Wladimir J. van der Laan
fb196362e1 Handle NULL strings in r_bin_demangle (#5587) 2016-08-23 13:11:30 +02:00
javierprtd
56636c8d09 Update dmh 2016-08-08 18:42:18 +02:00
pancake
9b053064fd Fix dmp command for OSX and make it work with 1 parm instead of 3 2016-07-26 16:54:18 +02:00
pancake
2a2226978e Fix dmi on OSX and minor cydia tweak 2016-07-26 15:17:07 +02:00
Álvaro Felipe Melchor
01fe87d467 fix coverity and some coding style 2016-07-21 22:56:58 +02:00
Jeffrey Crowell
951f110524 fix build 2016-07-13 00:41:38 -04:00
Jeffrey Crowell
b89bde9df9 reindent cmd_debug.c and fix tons of memleaks 2016-07-13 00:35:13 -04:00
Álvaro Felipe Melchor
7a2f32c281 compile dmh only with linux 2016-07-12 23:04:32 +02:00
javierprtd
07f0502c98 new commands dmh 2016-07-12 23:04:32 +02:00
monosource
b21603cfeb libr/core/cmd_debug: using r_core_cmd_help for "de" 2016-07-12 21:31:42 +02:00
n4☠0r
b353733041 dmhc update (#5311)
* dmhc update: chunk flags and data dump support
2016-07-08 11:00:38 +02:00
pancake
e971fd810e Implement dmh* and fix some indents in previous commit 2016-07-06 23:59:29 +02:00
n4x0r
2a84841a67 dmhc feature for dmh extension update (#5302) 2016-07-06 23:41:43 +02:00
Álvaro Felipe Melchor
79601b4949 dmh - show heap info (#5251) 2016-07-05 22:48:48 +02:00
pancake
59524ac8c4 Fix #4665 - Add wxs and fix crash in dbg println 2016-06-29 00:41:46 +02:00
Jeffrey Crowell
c145740030 replace r_cons_printf("%s\n",p) r_cons_println(p)
move from 10% of code in vfprintf to just 6% \o/ for simple tests of r2
-c "aaa" -q /bin/ls
2016-06-26 00:52:03 -04:00
Joshua J. Drake
722c62827b Major rework to the native debugger (esp on Linux) (#5185)
The major contribution here is completely re-worked breakpoint hit/recoil
handling. This work fixes #4907 and lays the ground work for future native
debugger improvements (multi-threading, etc).

* Give a human friendly type to enums
* Change many wait functions to return RDebugReasonType
* Better return checking (from r_debug_reg_sync, r_bp_restore)
* Optimized register synchronization
* Lots of comments and whitespace changes
* Improved inferior death detection

Handle EXIT_PID events differently than DEAD process events

* Move breakpoint/recoil handling to wait/cont/step

Rather than handing breakpoint related things inside cmd_debug.c, do that
inside the r_debug API functions. This seems like the most logical place for it
to live since it should apply to just about any platform/architecture.  This
also centralizes calling into "cmd.bp" handling via the CoreBind callback.

* Track how the caller wishes to continue

It turns out that handling break point recoils is very complicated. The ptrace
API on Linux returns SIGTRAP for just about every type of operation (not just
breakpoints getting hit). Add the "recoil_mode" flag to indicate whether we are
single-stepping or continuing and whether or not we are inside the recoil.

* Proper handling for swstep=true

Since r_debug_step_soft calls r_debug_continue, it's already hitting the recoil
case there. Move the recoil handling from r_debug_step to r_debug_step_hard
only.

For the swstep=true case, special handling is required inside r_debug_recoil.
By resetting all of the breakpoints except the one we just hit, we ensure we
can step the original instruction and hit the new swstep breakpoint. Add a new
bp function called r_bp_restore_except to do this.

To make matters worse, we cannot use a BreakpointItem pointer because that
leads to a use-after-free condition. Instead, we the breakpoint address
instead.

Now breakpoints should work regardless of the swtep setting.

* Always call the recoil before continuing

Some callers of r_debug_continue might not have ever inserted any breakpoints
before. If we don't restore breakpoints before each call to the underlying
continue we won't hit them.

* Hide software step breakpoint events from the user

When a breakpoint even happens due to a software-step, hide it from the user.
They aren't really breakpoints as far as they are concerned.

* Improve process exit handling on Linux

There are three types of process exiting events on Linux:

1. PTRACE_EVENT_EXIT occurs just before a process exits. It's not possible to
prevent it from exiting, but it can be used to inspect the pre-exit state.
2. The process can exit for a variety of reasons and we can notice when we call
waitpid(2).
3. The process could die randomly on us :-/

On Windows, h->wait will return R_DEBUG_REASON_EXIT_PID, but it's more likely
on Linux to find out the process is already dead.

* Check more bits within waitpid status

We can often make a decision about what happened strictly by looking at the
status returned from waitpid. In other cases, we need to call
r_debug_handle_signals.

If we reach the end of this function without knowing what happened, consider it
an error.
2016-06-22 10:34:45 +02:00
Joshua J. Drake
b03c1e2b3e Improve dkp and drp
Distinguish between "dXX" and "dXXYY" or "dXX?". Treat the latter two the same.
This provides the least surprise to the user when they mistype something.

Improve default handling in arp/drp

* Adds a new command "drp." for showing the register profile size.
* Provides better help for drpXXX commands.
* Provides help in the default case (eg. drpz)
* Fixes indentation
* Provides correct help strings for arp vs. drp

Improve default handling for "dko"

* Rework "dko" handling to simplify
* Use r_core_cmd_help
* Show help when things like "dkox" are used
* Prevent allocation/free when not necessary
2016-06-20 15:28:40 +02:00
Joshua J. Drake
16c27891a0 Switch to r_sys_perror for errors and fix two typos 2016-06-20 15:24:19 +02:00
ekse
60220bc525 Check that a required argument was passed for a couple of commands. (#5166) 2016-06-17 23:17:24 +02:00
Joshua J. Drake
0431a0efdf Properly handle forks on Linux 2.5.46+ (#5153)
Linux 2.5.46 made changes to the ptrace(2) API to inform a tracer when various
events occur. These are known as PTRACE_EVENTs. Start handling PTRACE_EVENTs
by:

 * Handling PTRACE_EVENT_FORK and PTRACE_EVENT_EXIT
 * For _FORK, stores the newly created pid in dbg->forked_pid
 * Add the "dpc" command to select the most recently forked child process.
 * Add the "dpc*" command to show the recently forked process' pid.

Additional minor changes to white space are included.

NOTE: This partially addresses #3549. It does handleLinux before 2.5.46.
2016-06-17 04:20:18 +02:00
Joshua J. Drake
9f570114c7 Add "clone" to the "dcf" command (#5161)
Previously, "dcf" didn't not consider that "clone" may be used to create child
processes. Look for that and also update the text shown to the user.
2016-06-17 04:19:31 +02:00
pancake
911fef209a Implement afbr and * sub-variants to list return addresses of current function 2016-06-17 02:50:01 +02:00
Joshua J. Drake
9c21df9272 Minor cleanups to process handling (#5152)
* Fixed 'dpk' handling (signal wasn't being groked)
* Mostly comments added
* Some eprintfs added
2016-06-17 01:59:10 +02:00
Joshua J. Drake
691dd0a5c5 Make "dbt" output aligned to columns based on dbg->bits (#5151)
* Make "dbt" output aligned to columns based on dbg->bits
* Add spaces between sizeof and paren
2016-06-16 22:57:44 +02:00
Joshua J. Drake
285cd3b32f Minor tweaks to breakpoint handling
* Fix "dbm" help string
* Save <module>+<offset> as the name when using dbm
* Fix allocation patterns for "module"
* Remove commented out code
* White space fixes
2016-06-16 12:36:17 +02:00
pancake
608b79d2b4 Finally fix the build on osx-ppc 2016-06-06 17:30:07 +02:00
pancake
d3394d5a7a Fix latest 28 COVs 2016-06-02 03:19:31 +02:00
pancake
62ca3a6d63 Fix #5021 - dbc argument parsing issue 2016-05-27 13:14:43 +02:00
pancake
b28d5e0a9c Fix android build 2016-05-23 21:54:42 +02:00
pancake
4de93b2703 Fix coredump file generation 2016-05-21 15:11:16 +02:00
pancake
7ad752f038 Remove the sandbox and fix more bugs in linux-core 2016-05-21 14:40:09 +02:00
Anton Kochkov
c75b584c7e Fix CID 1355257 2016-05-17 10:15:51 +03:00
pancake
c94145242f Fix #4739 - Do not run cmd.bp twice 2016-05-16 23:17:03 +02:00
Álvaro Felipe Melchor
6b827c1563 Fix #4796 - Add dbm aka module relative breakpoints 2016-05-16 01:00:11 +02:00
Riccardo Schirone
ed80f726f6 core/graph: remove esil modes
core/cmd_debug: use just one if instead of two nested
2016-05-04 10:18:20 +02:00
pancake
4546355af3 Add support for ascii-art debug tracing call graphs 2016-05-04 00:43:08 +02:00
Jeffrey Crowell
9518841434 refactor includes (#4757) 2016-05-03 04:52:41 +02:00
pancake
9f7f9f0ce8 Fix #4673 - dpt sync with help msg 2016-04-21 15:21:56 +02:00
pancake
17b0458ab6 Fix #4654 - Access debug map boundaries via $D and $DD 2016-04-17 19:28:43 +02:00
Jeffrey Crowell
aef5a179e8 disable dumping core if you're not actually dbging
fixes #4618
2016-04-12 12:38:17 -04:00
pancake
30ae724e89 Fix /V argument parsing 2016-04-10 23:17:16 +02:00
Anton Kochkov
d09eaaed33 Fix CID 1352383 2016-04-09 16:00:36 +03:00
Anton Kochkov
96c5783b5d Fix CID 1354257 2016-04-09 15:56:08 +03:00
pancake
d1636fb175 Fix #4553 - e cfg.debug=true forces native 2016-04-08 03:40:53 +02:00
Daniel Domínguez
71beec242e Coredump generation for Mach0 binaries 2016-04-05 12:03:59 +02:00
Maijin
071d17d034 fix help for arn and drn 2016-04-04 22:01:37 +02:00