From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118638 invoked by alias); 26 Aug 2016 12:01:55 -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 118620 invoked by uid 89); 26 Aug 2016 12:01:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Probably, gather, piping, Hx-languages-length:1459 X-HELO: mail-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Aug 2016 12:01:44 +0000 Received: by mail-wm0-f46.google.com with SMTP id i5so115809675wmg.0 for ; Fri, 26 Aug 2016 05:01:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=idS8nZQyv3LoO23CHB0g5+b5iO1BrJxpBoPAdJInDUU=; b=OLNPqejQj2hNlBc1+Cctf9SvOJYvbG/VKQA+WxzTQWXzy5Wj+vR64MXkaO/cCKb0ab FsKTij9rXEqtj4KUq7R1CuXiJeagREtAuvntI5dVnD7xkim7Hry+p86orZUMlqQb98kS rh4N8hhDIQNlpr6p2BlHF9Vl0pebXBQXuYRcgg9ANnykpRXJsanKuRrl+SnXe2b7F1Dc MIf5vS7EgPwHQ4BgKgJIx7rtwuu9wSsA6DOqkxHT09eO3RXevXu0Y2FAL6EMlrmwacBJ aHStaUv4aoPxHxC0bj0Ej0RQbFrUNFTeOE7GiOkIsku+DNtk0etIY8waJKgBFF6BJoJz ePAA== X-Gm-Message-State: AE9vXwPGu1vrYQ173PWdPGSW8ceMDxGYWU72G634DQG2jDP8i+yr61CUG5fNP711zwrJJlw41+3YRBG/MUhYZw== X-Received: by 10.28.206.8 with SMTP id e8mr3496494wmg.57.1472212902670; Fri, 26 Aug 2016 05:01:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.93.167 with HTTP; Fri, 26 Aug 2016 05:01:42 -0700 (PDT) In-Reply-To: References: From: vijay nag Date: Fri, 26 Aug 2016 12:01:00 -0000 Message-ID: Subject: Re: collecting data from a coring process To: Paul Marquess Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg00048.txt.bz2 On Fri, Aug 26, 2016 at 2:36 PM, Paul Marquess wrote: > I have an existing Linux application that uses gdb to collect data from a process if it cores. Currently I've been doing that with gdb after the core is written to disk. No problem there. > > The requirements have now changed and it won't be possible to allow the core file to be written to disk. That means I need a way to (somehow) get gdb to collect the data while the process is still in memory. > > My first thought was to add a script in /proc/sys/kernel/core_pattern to catch the process as it is coring. Then I get gdb to attach to the PID of the process that is about to core. Unfortunately, when I tried that, gdb gives me this error > > Unable to attach: program terminated with signal SIGSEGV, Segmentation fault. > No stack. > > That seems to imply that by the time /proc/sys/kernel/core_pattern kicks in it is too late to use the PID with gdb. > > Anyone know of a way to do this? Preferably one that doesn't involve changing the process itself. > > cheers > Paul You can do one of the following 1) Why not dump the information that you are looking for into a file in the process signal handler ? 2) RTFM core file piping on linux (Probably you've done this already ?) - The idea may seem dangerous, but you can try inserting sleep in the script for sometime till you gather whatever information that is required.