Ptrace reset a breakpoint
<p>I am having trouble resetting a process after I have hit a breakpoint with Ptrace.  I am essentially wrapping <a href="https://github.com/eliben/code-for-blog/blob/master/2011/debuggers_part2_code/bp_manual.c" rel="nofollow">this code</a> in python.<br>
I am running this on 64 bit Ubuntu.</p>

<p>I understand the concept of resetting the data at the location and decrementing the instruction pointer, but after I get the trap signal and do that, my process is not finishing.
Code snippet:  </p>

<pre><code># Continue to bp
res = libc.ptrace(PTRACE_CONT,pid,0,0)
libc.wait(byref(wait_status))

if _wifstopped(wait_status):
    print('Breakpoint hit. Signal: %s' % (strsignal(_wstopsig(wait_status))))
else:
    print('Error process failed to stop')
    exit(1)

# Reset Instruction pointer
data = get_registers(pid)
print_rip(data)
data.rip -= 1
res = set_registers(pid,data)

# Verify rip
print_rip(get_registers(pid))
# Reset Instruction
out = set_text(pid,c_ulonglong(addr),c_ulonglong(initial_data))

if out != 0:
    print_errno()

print_text(c_ulonglong(addr),c_ulonglong(get_text(c_void_p(addr))))
</code></pre>

<p>And I run a PTRACE_DETACH right after returning from this code.
When I run this, it hits the breakpoint the parent process returns successfully, but the child does not resume and finish its code.
If I comment out the call to the breakpoint function it just attaches ptrace to the process and then detaches it, and the program runs fine.<br>
The program itself is just a small c program that prints 10 times to a file.  </p>

<p><a href="http://pastebin.com/iZrxTv6L" rel="nofollow">Full code is in this paste</a></p>

<p>Is there an error anyone sees with my breakpoint code? </p>