From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60959 invoked by alias); 17 Nov 2017 06:44:43 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 60943 invoked by uid 89); 17 Nov 2017 06:44:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=toy, H*r:sk:gdb@sou, enlighten, manipulate X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Nov 2017 06:44:41 +0000 Received: by mail-wm0-f43.google.com with SMTP id b189so4244497wmd.5 for ; Thu, 16 Nov 2017 22:44:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+81a7shDL/+teb3rprFnVvh460U6SchVMhaFiT6oEBs=; b=iFOG8C3lGVURilBZ8EfNnxV3pN5cWTiSvISx4n0+9KvaidAshzcLUxOgG9oHLXs5Wj sV1dbmYgeW6M294f40mkM+exhOje/1C6i8D/Vf2QSCIcRrkB8er0my1TdmsLs2ClYOTd iCz46pY/Xr7f9qFfcBXkpYd3U49B4z3GOHJ7PR3MFbrXm33q6IhTYwcXiFHo/X1U7Nnb WZWHam4y3KYh4aJPCJuLZadbIYrahHQq7xHKS58cQJ5FkxT4Htdub1dT8yf+CyJ8J6sF +otmQBFJhCo5jcLIZwvd0YMJUZsEnRUC4jL+9eG6olb15SulGLGb6dBD9MRHE2u8sjHN FeKg== X-Gm-Message-State: AJaThX6IzEtBYJkCYKJwjMP5QaJ7crfva/FhmIfVeWG6s2SO9Or7YLTj 7C2eXYh1XXYDU/093mydGexV8vz2MVeFrpTOKA== X-Google-Smtp-Source: AGs4zMZgRZ1EN3m+MROMhnhdUlk2ecEFqzpdIBdBqyoQEQHC3IaSYSSJt+QDILD4PxNiHksqcrHuINyyskIgcwlz2Vc= X-Received: by 10.80.225.77 with SMTP id i13mr6234512edl.128.1510901078869; Thu, 16 Nov 2017 22:44:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.135.140 with HTTP; Thu, 16 Nov 2017 22:44:38 -0800 (PST) From: Yubin Ruan Date: Fri, 17 Nov 2017 06:44:00 -0000 Message-ID: Subject: how GDB use ptrace to return from a function To: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00007.txt.bz2 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