zsh-users
 help / color / mirror / code / Atom feed
* A question about debugging zsh using set -x to an independent log file
@ 2017-04-22 23:56 Steven Lu
  2017-04-23  3:58 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Lu @ 2017-04-22 23:56 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

I have a very highly instrumented zsh and am experiencing a particular
heisenbug. The zsh process just exits for no apparent reason. I have set
the OS to produce coredumps and this did not generate any when the issue
was reproduced.

I think that a reasonable approach to debugging that is very likely to
produce useful results is to use the set -x option to show each command
that ran. then at least I can see what area of plugins might be implicated.

The problem is that this is a heisenbug and it comes and goes, the shell
will be simply unusable when the xtrace output is there, and I can't really
use the shell effectively if I redirect stderr to a file. So I am hoping
there is a way to get the xtrace output and ONLY the xtrace output into a
separate file. If there is no feature in place I still expect that there
should be an easy way to patch zsh to allow me this.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: A question about debugging zsh using set -x to an independent log file
  2017-04-22 23:56 A question about debugging zsh using set -x to an independent log file Steven Lu
@ 2017-04-23  3:58 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2017-04-23  3:58 UTC (permalink / raw)
  To: zsh-users

On Apr 22,  7:56pm, Steven Lu wrote:
} 
} The problem is that this is a heisenbug and it comes and goes, the shell
} will be simply unusable when the xtrace output is there, and I can't really
} use the shell effectively if I redirect stderr to a file.

You probably want to use a trap on the DEBUG pseudo-signal, e.g.,

    TRAPDEBUG() {
      print -r -- "$ZSH_DEBUG_CMD" >> your_trace_file
    }

Or for closer congruence to set -x

    trap '{ print -nP -- "$PS4"
            print -r -- "$ZSH_DEBUG_CMD" } >> your_trace_file' DEBUG

This requires "setopt DEBUG_BEFORE_CMD" but unless you've deliberately
unset that, it is set by default.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-23  3:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-22 23:56 A question about debugging zsh using set -x to an independent log file Steven Lu
2017-04-23  3:58 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).