65 Commits

Author SHA1 Message Date
pancake
3645aed1a9 Rename corebind fields to coreb, for consistency with analb, iob ##abi
* This change will break some more plugins
2022-05-07 11:58:38 +02:00
Lazula
ad749a0b1a Fix static/R_API function definition formatting
* Remove spaces before parens
* Remove spaces after asterisks
2021-12-21 20:58:12 +01:00
yossizap
fd0dcd5370 Fixed failure in bp placement when no architecture plugin is available ##debug
The r_bp_get_bytes check in r_bp_add made it impossible to set a
breakpoint for an architecture without a bp plugin even though the debug
backend might support setting a breakpoint.
2020-12-03 00:15:12 -06:00
yossizap
313d4b4893 Refactor breakpoint validation (#15754) ##debug
* Added RCoreBind.syncDebugMaps() and RCoreBind.getDebugMaps() api
* Refactor breakpoint validation ##debug
* Reenable db tests and add new tests to check validity
* Add perm check to isMapped and remove map sync to improve performance
2020-01-04 01:54:24 +01:00
pancake
836ea638b7 Revert "Validate bp addr on rebase and restore instead of preventing creation ##debug (#15750)"
This reverts commit e503bdd9c212c2da221abe31091c6e9753ce018e.
2020-01-03 01:35:05 +01:00
yossizap
e503bdd9c2 Validate bp addr on rebase and restore instead of preventing creation ##debug (#15750)
This way it is possible to set breakpoints before starting debug through
'db' and the user will be notified when a breakpoint points to an
invalid map.
2020-01-03 00:57:18 +01:00
fcasal
c2f01218f2 Rebase Breakpoints for PIEs ##debug (#12801) 2019-12-06 10:52:26 +01:00
pancake
41ec949204 Fix #11112 - Rename {srwx,flags,perms} to perm. (-21 LOC)
Unify R_IO, R_BIN, R_BP, .. into R_PERM_* using 1 letter syntax
2018-09-22 11:31:45 +02:00
Fangrui Song
a93d33d23f Fix warnings in debug (#10981) 2018-08-08 12:14:47 +08:00
AsFaBw
84852de244 Fix 10811 - Improvements in gdbclient breakpoints (#10940) 2018-08-07 12:15:11 +02:00
Fangrui Song
6e776b986a Fix some warnings in debug (#10929) 2018-08-05 11:56:15 +02:00
pancake
f5f090b709 Implement named breakpoints with support for expressions 2018-06-19 12:27:57 +02:00
pancake
1288473703 Implement 'dbi addr' and dbi. 2018-06-19 11:24:56 +02:00
Abominas
b0fc578d31 Add initial temp breakpoint support (#9845) 2018-04-15 00:36:40 +02:00
pancake
2b841d27ad Fix pxj length 2017-12-17 13:48:17 +01:00
pancake
c29c6f4f0a Fix #8290 - Fix build on old compilers 2017-08-27 18:33:49 +02:00
Ren Kimura
75c34396fb Fixed dbw parse bug (#8271) 2017-08-22 20:11:59 +02:00
Ren Kimura
9862367fd0 Add drx_add/delete for watchpoint (#8244)
* Add drx_add/delete for watchpoint

* Changed breakpoint callback
2017-08-20 10:39:10 +02:00
Ren Kimura
7ce197eb44 Add initial support for hw watchpoint (#8132)
* Add initial support of hw watchpoint

* Fixed parse bug

* Fixed rwx str
2017-08-06 05:27:01 +02:00
Tiago Gasiba
f0a2d8657d Add support for conditional breakpoints running r2 commands 2016-09-01 19:11:46 +02: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
Álvaro Felipe Melchor
6b827c1563 Fix #4796 - Add dbm aka module relative breakpoints 2016-05-16 01:00:11 +02:00
pancake
80ea7427bb Indentation fixes around the previous commit and beyond 2016-05-15 10:40:57 +02:00
Joshua J. Drake
29c2670039 Fix #4560: Handle recoils well with swstep=true
When resuming after (during) recoil from a breakpoint, the swstep
implementation would fail to advance. In short, the debugger would immediately
interrupt again because r_bp_restore was re-setting the original breakpoint
just before continue. The following changes fix this issue:

1. Modify r_bp_get_in to stop including the byte after a breakpoint. This was
causing r_bp_recoil to fail because it thought there was already a breakpoint
on the next instruction.

2. Pass the real breakpoint address (pc - dbg->bpsize) to r_bp_recoil so
that r_bp_get_in can work properly. Stop adding the b->size there to keep it
going too.

3. Add a state flag to core->dbg to track that we are in the midst of a recoil.

4. When continuing from recoil (in r_debug_continue_kill), restore all
breakpoints except the one we just hit (with the new r_bp_restore_except) to
avoid hitting it again. Once we move past this instruction, that breakpoint
will be set again.
2016-05-15 10:19:24 +02:00
pancake
34a7837079 Include r_lib from r_bp 2016-04-13 14:48:17 +02:00
pancake
1b88200e31 Add support for 'interpreter' in RBin, ELF and MACH0 2015-10-22 02:13:26 +02:00
pancake
9ec625269a Fix #2904 - Implement dbm and fix breakpoint list issue 2015-10-13 05:00:20 +02:00
pancake
5993d290a0 Add dbn and db. commands 2015-08-17 01:43:45 +02:00
shuall
0807686d86 #3052 all printf member functions changed to cb_printf 2015-08-09 03:25:05 +02:00
pancake
d436d16cd4 Honor asm.bits in the RBreakpoint API 2015-06-22 12:23:38 +02:00
jvoisin
a8937732b8 Fix all 'warning: function declaration isn’t a prototype [-Wstrict-prototypes]' 2015-01-13 03:40:35 +01:00
LemonBoy
832adcd557 Make the bp api slightly saner 2014-11-17 16:24:26 +01:00
skuater
c7e0681b38 add support for dbe* / dbd* / dbte* / dbtd* 2014-10-28 17:07:48 +01:00
pancake
ef35aaaa7e Add support for indexed breakpoint management 2014-10-28 11:14:30 +01:00
pancake
8430ff1dba r_bp_get -> r_bp_get_at // .. r_bp_get_in 2014-10-28 02:28:58 +01:00
pancake
887f15b03d Add r_bp_del_all (db-*) and fix some more bugs 2014-05-08 17:38:29 +02:00
pancake
2397c956c9 Use R2_ as unique header guard prefix 2014-03-27 16:34:17 +01:00
pancake
d3af1ea077 Fix #723 - header guards conforming to C standards 2014-03-27 02:32:26 +01:00
pancake
2cbce80f2f Add __cplusplus extern "C" boilerplate everywhere 2013-06-18 12:09:23 +02:00
pancake
bc0104563b Initial support for runtime versioned libraries
- This check will ensure you are running the latest r2 version.
2013-06-14 02:51:33 +02:00
Anton Kochkov
e075a18b56 Types cleanups 2012-07-22 12:01:39 +04:00
pancake
a43068bde0 * brainfuck debugger is finally usable
- Added breakpoint and code analysis plugins for bf
  - *mem++ != mem[0]++
  - Full register get/set support
  - Support for step and continue-until-syscall
  - Work in progress breakpoint support
* Added bfvm_reset() hooked to plugin->kill
* Enhacements in r_core and r_debug for better debugger support
  - Added plugin->step_over delegate
2011-10-09 04:15:32 +02:00
pancake
a4b57487bf * Fix pkg-config-symstall
- Update all .pc files
* Fix 'pf d*' segfault
  - Show flag references in all 'pf' values
* Many bugfixes in vapis
  - Use nested namespaces instead of static classes
    - Static classes was deprecated in Vala some years ago
  - All bindings are working again
  - C++ support has been added
  - Guile is now compiled by default
* Added ./configure-langs to select which langs to use
  - Use --enable=python,perl or --disable=guile
2011-05-20 19:49:50 +02:00
Eloi Sanfelix
05b6e7d333 Added io-based bp's for SH (crashes qemu, but should be ok for userspace progs) 2011-05-11 20:11:44 +02:00
pancake
98cc88700d * Added much more detailed vapis
- Enhaces API support for valaswig bindings
  - I'm probably breaking the build
2010-10-28 00:55:07 +02:00
pancake
eb6dbb2245 * Initial draft implementation of hardware breakpoints
- use specific ptrace() calls in linux/freebsd to change regs
  - hwbp are not yet working, just basic DRX get/set
  - generic interface to handle hw bps in x86-32/64
  - needs to import DR# handling code from r1
2010-09-24 05:41:54 +02:00
pancake
773c2549ad * Initial implementation of callback commands for r_bp
- Added 'dbc' command to configure them
* Check breakpoint stop everywhere
2010-07-13 01:20:57 +02:00
pancake
761925a27c * Add bp_mips and bp_ppc plugins for r_bp
- rm plugins.cfg && ./configure-plugins required
2010-06-30 01:19:03 +02:00
pancake
bc2c79ee8d * Use RList in r_bp
- vapi updated
* Generalize the use of PrintfCallback typedef
  - used in r_bp and handled by r_cons in r_core
2010-06-30 01:13:09 +02:00
Nibble
4ead120e53 * Rename "handler" to "plugin"
* Rename */handler.c to */plugin.c
* Rename "handle" to "handler" in r_lib

--HG--
rename : libr/bp/handle.c => libr/bp/plugin.c
rename : libr/cmd/handle.c => libr/cmd/plugin.c
rename : libr/debug/handle.c => libr/debug/plugin.c
rename : libr/io/handle.c => libr/io/plugin.c
2010-05-26 18:25:35 +02:00