From: Yubin Ruan <ablacktshirt@gmail.com>
To: gdb@sourceware.org
Subject: how GDB use ptrace to return from a function
Date: Fri, 17 Nov 2017 06:44:00 -0000 [thread overview]
Message-ID: <CAJYFCiMqA1NO-32g7_vrwpU-h7dmyPaqUe=UZzey1gfFz7ax3g@mail.gmail.com> (raw)
Hi GDB developer ;-)
I am writing a toy debugger and currently looking into the GDB source
because I want to know: after setting the tracee's registers and
trying to let it execute a function with ptrace(PTRACE_CONT, ...), how
can the tracee return to the tracer?
Currently I manipulate the tracee's stack and place a NULL return
address there (I am on X86), so that after ptrace(PTRACE_CONT, ...),
the tracee will execute a function and return, at which point a SIGSEV
is generated (because the return address is NULL), so tracee will be
caught by the tracer again.
I don't know whether GDB is using this kind of technique. If anyone
know that, can you enlighten me, and probably point me to the source?
Yubin
next reply other threads:[~2017-11-17 6:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 6:44 Yubin Ruan [this message]
2017-11-17 16:11 ` Joel Brobecker
2017-11-18 3:46 ` Yubin Ruan
2017-11-18 4:03 ` Joel Brobecker
2017-11-18 4:20 ` Yubin Ruan
2017-11-18 7:58 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJYFCiMqA1NO-32g7_vrwpU-h7dmyPaqUe=UZzey1gfFz7ax3g@mail.gmail.com' \
--to=ablacktshirt@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox