Commit Graph

128 Commits

Author SHA1 Message Date
whitequark
c816dc7e66 Don't try to build shared libraries if configured as --without-pic.
Specifically, avoid building all plugins as non-static objects,
as well as some supplementary libraries. In fact, a large amount
of plugins was already gated to build as shared objects only with
WITHPIC=1, but this was not done consistently.
This gating has been moved to */p/Makefile.

Building these shared objects is a waste of time and breaks
the --without-pic build unless CFLAGS is forced in the make
invocation.
2018-01-11 23:09:22 +01:00
Ayman Khamouma (ak42)
00b6eccdea take bits "wildcard" into account in r_bp_size (#8994) 2017-12-10 11:28:33 +01:00
pancake
d25ae603c7 Automatically set dbg.bpsize to fix bps in arm64 2017-12-03 18:57:42 +01:00
pancake
37626f13a5 Fix #8786 - Use brk0 for arm64 breakpoints 2017-12-03 16:51:25 +01:00
Maijin
4bb5c15faa r_lib_struct_t -> RLibStruct 2017-11-10 13:38:05 +01:00
Ren Kimura
816c5ee244 Add conditional watchpoint (#8321) 2017-08-26 18:57:51 +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
SkUaTeR
c31d81da26 support for static build (#7822)
* support for static build
* improved sharard/static build
2017-06-28 22:54:40 +02:00
SkUaTeR
dc7914644e Meson improvements 2017-05-31 13:38:47 +02:00
pancake
6758e3753d Remove configure-plugins dependency for the make meson 2017-05-26 02:43:53 +02:00
SkUaTeR
9a1337512a meson.build fixes to build with MSVC 2017-05-14 23:06:00 +02:00
pancake
60f9667654 Remove support for bjam build system
- Delete all Jamroot files
2017-05-02 05:48:40 +02:00
pancake
fa671b9a16 Initial support for the Meson build system
- Integrated with current ACR
- Fix some stale fails got removed
2017-05-02 05:05:36 +02:00
alvarofe
40babe0459 Fix oob read with dbh- command 2017-04-18 19:07:14 +02:00
Ren Kimura
9a1190c112 Add bp_plugin_del and dbh- command (#7209) 2017-04-06 15:59:19 +02:00
pancake
4dc2b8b081 Add sys/sdk build script (wip) 2017-02-02 13:25:14 +01:00
pancake
94d47c79bb Completely remove all references to list.h 2016-10-27 13:33:27 +02:00
Sven Steinbauer
2996538700 Fix #5633 - Change x == NULL to correct syntax 2016-09-19 14:44:47 +02:00
dromero
d250d21385 Fix for the #5671 issue (#5704) 2016-09-06 12:02:38 +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
Joshua J. Drake
2b9edf8dc4 Fixes #5154: Stop including source-file whitespace (#5155) 2016-06-16 22:57:10 +02:00
Sven Steinbauer
8da8ad740f Cleanup fixes
* For commit comments and compiler errors
* Fixes for PR comments
* fix some "infer fixes" commits

Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2016-05-23 11:25:44 +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
Damien Zammit
632dccc217 Remove LIL_ENDIAN macro and configure option
TODO: Remove other endian cruft from:
- hashing algs
- judy
- squashfs
- grub
- tms320

Signed-off-by: Damien Zammit <damien@zamaudio.com>
2016-05-06 10:21:55 +02:00
pancake
a74fd6c25f Use non-sigill breakpoints for ARM 2016-04-22 10:18:53 +02:00
NaveenBoggarapu
4c04b98b47 few memory leaks fixed 2016-04-13 21:55:48 +02:00
Anton Kochkov
878fa8d74c Fix breakpoints listing - missing space
My smallest commit ever.
2016-04-12 13:37:33 +04:00
Álvaro Felipe Melchor
c372743315 xnu: get rid of ptrace even for attach and detach
some rework in order to handle mach message as mach_exc_server and alike does
api change in plugin debug, now the function detach receive a pointer to RDebug
trying to deallocate port when are not needed any more
2016-01-23 22:50:28 +01:00
pancake
fc8ebbebc3 Fix breakpoints issue in ARM 2016-01-11 01:43:05 +01:00
Álvaro Felipe Melchor
e9a8431b7a Fix #3890 2015-12-29 22:35:37 +01:00
Álvaro Felipe Melchor
a93e75f542 Initial merge on the reworked patch from @alvarofe 2015-11-17 01:00:09 +01:00
pancake
e15c13322d Hack for arm64 breakpoints 2015-11-13 00:29:33 +01:00
pancake
36179944fd Fixes Thumb detection from CPSR, NULL 2015-10-31 03:45:14 +01:00
pancake
d651c626ed Fix breakpoints on Thumb/ARM debugger 2015-10-31 03:07:00 +01:00
pancake
a05ac7eaa4 RDebugPlugin.arch.typeof(char*) 2015-10-22 03:11:03 +02:00
pancake
9ec625269a Fix #2904 - Implement dbm and fix breakpoint list issue 2015-10-13 05:00:20 +02:00
XVilka
720341c2df Improve -fPIC handling, take 2 2015-10-09 22:24:15 +03:00
pancake
b86bf19c85 Fix #3051 - Honor CFLAGS everywhere and fix some windows/android warnings 2015-09-14 20:43:11 +02:00
pancake
49975ccf95 Fix #3286 - Use stdbool.h 2015-09-14 02:08:31 +02:00
Álvaro Felipe Melchor
1d4ebdeb25 some refactoring & added threads field in RDebug 2015-09-01 18:45:08 +02:00
dequis
003a18aa30 A few simple memory leak fixes 2015-08-30 23:20:51 +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
fbdf0e8fde Fix some more COVs 2015-07-25 02:10:31 +02:00
Jonathan Neuschäfer
523aa3af5c add .version to all plugins 2015-07-12 19:05:33 +02:00
pancake
b5d40d11c0 Fix last coverities issues 2015-07-02 09:33:05 +02:00