Most servers/clients should have xml support by now so it should behave
like `dp` in any other debugger. vFile is the only way to get detailed pid info unfortunately.
Previously, when using `dp=`, the debug plugin would set a new tid based
on the requested pid, but r_debug_select would set the old tid as dbg->tid,
resulting in issues interacting with the current thread. This could also
be an issue when the requested pid/tid is invalid and the plugin selects
something else.
Previously, `dp=` wouldn't fully switch to the given process since it was
treated like `dpt` thread switching, leaving the debugger in an undefined state.
Previously, the command didn't show the pid's path, replaced the path
field with current/ppid, and showed the ppid instead of only showing the
requested process and the children of the requested process.
Previously, windbg_break would freeze waiting on a lock instead of breaking,
taks other than wait weren't breakable and read regs would freeze the
process while waiting for a mutex.
Writing registers with gdbr worked with single registers because
reg_next_diff started at delta 0 and only had to run the diff once for
the single register that was changed. When running reverse
stepping/continue, multiple registers are changed at once so
r_reg_next_diff would fail every time due to incorrect offset calculation.
The new r_reg_next_diff also support different register sizes to restore
all registers correctly.
The endianity swapping part from reg_write isn't needed since the arena
is the return value of 'g' which is already in the correct target byte
order (see: https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#read-registers-packet)
The previous gdbr implementation didn't allow interrupting background
tasks with &b since send_vcon wasn't properly configured with the cons
api. In addition to that, gdbserver doesn't support processing multiple
commands at the same time, resulting in undefined behavior once cons
were set up for vcont.
This commit adds the relevant cons api and solves the concurrency issues
by adding locks on all socket related logic.
The user was interrupted during continue and switched to a different
thread since DebugBreakProcess creates a thread that triggers a breakpoint.
With these changes the DebugBreak thread is recorded to skip the breakpoint
event afterwards.
* Fixed w32dbg breaking issues and moved break_push to w32_dbg_wait to support stepping as well
Previously, breaking would only work during 'dc' because it was pushed
in debug.c specifically for continue. This change moves the
responsibility of pushing/popping w32_break_process_wrapper to
windows_debug.c instead to support calls to w32_dbg_wait from anywhere.
* Fixed issues in windows thread switching by implementing thread attach for w32dbg =!pid
Previously the function attempted to OpenProcess even though the main
pid is already opened by __open and the fact that re-opening the main
pid wouldn't do anything. This way it attaches to new threads when
called by r_debug_select.
* Modified w32_continue to update rio->pi.dwThreadId after switching to the requested thread
Manually changing iop->pi.dwThreadId in io_w32dbg's =!pid created a
problematic scenario when w32_continue is called with the last event's
tid from dbg_wait. This solution makes sure iop->pi.dwThreadId keeps
being updated after events on other threads arrive and that w32_continue
actually uses the given tid.
* Modified w32_continue return values
In linux_attach_single_pid there is a check to avoid calling PT_ATTACH
multiple times on an already traced pid, which is an operation that
should be done only one time. The old code supposedly tried to set the
options only the first time you attach to a process, however when
debugging a process through the io_ptrace plugin, the process uses
TRACEME and the code never set the options of ptrace to intercept the
process before dying, amongst other things.
This patch addresses this issue by just always setting ptrace options.
Those options could be changed by the user during the life of the debug
session, so it's not an operation that should be done only one time.