From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============9037154187769290573==" MIME-Version: 1.0 From: Mark Wielaard To: elfutils-devel@lists.fedorahosted.org Subject: Re: [PATCH] Add --core-pattern option to eu-stack Date: Thu, 27 Nov 2014 12:17:39 +0100 Message-ID: <1417087059.4954.43.camel@bordewijk.wildebeest.org> In-Reply-To: 20141126144434.GB16611@host2.jankratochvil.net --===============9037154187769290573== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Wed, 2014-11-26 at 15:44 +0100, Jan Kratochvil wrote: > On Thu, 30 Oct 2014 22:55:41 +0100, Mark Wielaard wrote: > > I did have to lookup how to use this though. And I couldn't make it work > > without adding an -o option to eu-stack to explicitly redirect output > > since it seems you cannot use normal shell redirections > > in /proc/sys/kernel/core_pattern. So I had to use something like > > --output=3D/proc/%p/cwd/%i.stack. Where does the stdout of the > > core_pattern end up otherwise? > = > Nowhere as the only open fd is 0 - the piped core file: > lr-x------ 1 root root 64 Nov 26 15:23 0 -> pipe:[5401953] > = > I did not expect (and did not use) eu-stack directly in > /proc/sys/kernel/core_pattern . I put there just a shell script which en= ded > with 'exec eu-stack ...'. This is why I have put into --help the comment: > core file fd 0 must be owned only by this process (e.g. use shell exec) > = > = > > It would probably be good to have a full example usage in the --help > > message (and tell people to look at man 5 core). > = > One should IMO put into that shell script dumping of more associated > information, such as /proc/PID/fd/ and other info found in ABRT, it needs= to > find some proper appendable output file and/or unique directory etc. I d= o not > find it all suitable for eu-stack --help. That would be possibly appropr= iate > for a man page but elfutils has no man pages. The --help output is the best we have for now. So best to put documentation there IMHO. But yes, having a real manual, man or info pages for all elfutils tools would be better. If we include the option/code then it really should be usable by users. It looked usable as is with the addition of -o,--output. But I might be missing something subtle. > > > The code of core_pattern function has been suggested by Oleg Nesterov. > > = > > I was wondering if we could make this a little more generically usable > > and call it --wait-exit or something like that. So people could also use > > it outside the core_pattern if they just want to get a backtrace for a > > known thread when it exits. > = > I was trying to figure out some more generic functionality than --core-pa= ttern > but given that for core_pattern one needs to: > PTRACE_SEIZE > close(0) > waitpid() > I do not find any part of this sequence separable, do you? The close (0) is somewhat odd. I assume it signals the process is done with handling the core file data and waitpid () never returns without that? But it does seem somewhat harmless. Are there any bad side effects from closing stdin? We don't handle stdin at the moment. Although we could maybe add --core=3D- to be explicit about the core data coming from stdin. The waitpid () really is just waiting for PTRACE_EVENT_EXIT. So if you wrap that in a while loop wouldn't it just work fine too in case the user uses it with -p on a thread that they want to get the backtrace of when it exits instead of in a core file pattern handler pipe? Thanks, Mark --===============9037154187769290573==--