174 lines
9.4 KiB
HTML
174 lines
9.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<!-- This manual documents Guile version 3.0.10.
|
|
|
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
|
Inc.
|
|
|
|
Copyright (C) 2021 Maxime Devos
|
|
|
|
Copyright (C) 2024 Tomas Volf
|
|
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
|
copy of the license is included in the section entitled "GNU Free
|
|
Documentation License." -->
|
|
<title>High-Level Traps (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="High-Level Traps (Guile Reference Manual)">
|
|
<meta name="keywords" content="High-Level Traps (Guile Reference Manual)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content=".texi2any-real">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
<link href="index.html" rel="start" title="Top">
|
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Traps.html" rel="up" title="Traps">
|
|
<link href="Trap-States.html" rel="prev" title="Trap States">
|
|
<style type="text/css">
|
|
<!--
|
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
|
div.example {margin-left: 3.2em}
|
|
span:hover a.copiable-link {visibility: visible}
|
|
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
|
|
-->
|
|
</style>
|
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<div class="subsubsection-level-extent" id="High_002dLevel-Traps">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Previous: <a href="Trap-States.html" accesskey="p" rel="prev">Trap States</a>, Up: <a href="Traps.html" accesskey="u" rel="up">Traps</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<h4 class="subsubsection" id="High_002dLevel-Traps-1"><span>6.26.4.6 High-Level Traps<a class="copiable-link" href="#High_002dLevel-Traps-1"> ¶</a></span></h4>
|
|
|
|
<p>The low-level trap API allows one to make traps that call procedures,
|
|
and the trap state API allows one to keep track of what traps are
|
|
there. But neither of these APIs directly helps you when you want to
|
|
set a breakpoint, because it’s unclear what to do when the trap fires.
|
|
Do you enter a debugger, or mail a summary of the situation to your
|
|
great-aunt, or what?
|
|
</p>
|
|
<p>So for the common case in which you just want to install breakpoints,
|
|
and then have them all result in calls to one parameterizable procedure,
|
|
we have the high-level trap interface.
|
|
</p>
|
|
<p>Perhaps we should have started this section with this interface, as it’s
|
|
clearly the one most people should use. But as its capabilities and
|
|
limitations proceed from the lower layers, we felt that the
|
|
character-building exercise of building a mental model might be helpful.
|
|
</p>
|
|
<p>These procedures share a module with trap states:
|
|
</p>
|
|
<div class="example lisp">
|
|
<pre class="lisp-preformatted">(use-modules (system vm trap-state))
|
|
</pre></div>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-with_002ddefault_002dtrap_002dhandler"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">with-default-trap-handler</strong> <var class="def-var-arguments">handler thunk</var><a class="copiable-link" href="#index-with_002ddefault_002dtrap_002dhandler"> ¶</a></span></dt>
|
|
<dd><p>Call <var class="var">thunk</var> in a dynamic context in which <var class="var">handler</var> is the
|
|
current trap handler.
|
|
</p>
|
|
<p>Additionally, during the execution of <var class="var">thunk</var>, the VM trace level
|
|
(see <a class="pxref" href="VM-Hooks.html">VM Hooks</a>) is set to the number of enabled traps. This ensures
|
|
that traps will in fact fire.
|
|
</p>
|
|
<p><var class="var">handler</var> may be <code class="code">#f</code>, in which case VM hooks are not enabled
|
|
as they otherwise would be, as there is nothing to handle the traps.
|
|
</p></dd></dl>
|
|
|
|
<p>The trace-level-setting behavior of <code class="code">with-default-trap-handler</code> is
|
|
one of its more useful aspects, but if you are willing to forgo that,
|
|
and just want to install a global trap handler, there’s a function for
|
|
that too:
|
|
</p>
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-install_002dtrap_002dhandler_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">install-trap-handler!</strong> <var class="def-var-arguments">handler</var><a class="copiable-link" href="#index-install_002dtrap_002dhandler_0021"> ¶</a></span></dt>
|
|
<dd><p>Set the current thread’s trap handler to <var class="var">handler</var>.
|
|
</p></dd></dl>
|
|
|
|
<p>Trap handlers are called when traps installed by procedures from this
|
|
module fire. The current “consumer” of this API is Guile’s REPL, but
|
|
one might easily imagine other trap handlers being used to integrate
|
|
with other debugging tools.
|
|
</p>
|
|
<a class="index-entry-id" id="index-Breakpoints-1"></a>
|
|
<a class="index-entry-id" id="index-Setting-breakpoints"></a>
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-add_002dtrap_002dat_002dprocedure_002dcall_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">add-trap-at-procedure-call!</strong> <var class="def-var-arguments">proc</var><a class="copiable-link" href="#index-add_002dtrap_002dat_002dprocedure_002dcall_0021"> ¶</a></span></dt>
|
|
<dd><p>Install a trap that will fire when <var class="var">proc</var> is called.
|
|
</p>
|
|
<p>This is a breakpoint.
|
|
</p></dd></dl>
|
|
|
|
<a class="index-entry-id" id="index-Tracepoints"></a>
|
|
<a class="index-entry-id" id="index-Setting-tracepoints"></a>
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-add_002dtrace_002dat_002dprocedure_002dcall_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">add-trace-at-procedure-call!</strong> <var class="def-var-arguments">proc</var><a class="copiable-link" href="#index-add_002dtrace_002dat_002dprocedure_002dcall_0021"> ¶</a></span></dt>
|
|
<dd><p>Install a trap that will print a tracing message when <var class="var">proc</var> is
|
|
called. See <a class="xref" href="Tracing-Traps.html">Tracing Traps</a>, for more information.
|
|
</p>
|
|
<p>This is a tracepoint.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-add_002dtrap_002dat_002dsource_002dlocation_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">add-trap-at-source-location!</strong> <var class="def-var-arguments">file user-line</var><a class="copiable-link" href="#index-add_002dtrap_002dat_002dsource_002dlocation_0021"> ¶</a></span></dt>
|
|
<dd><p>Install a trap that will fire when control reaches the given source
|
|
location. <var class="var">user-line</var> is one-indexed, as users count lines, instead
|
|
of zero-indexed, as Guile counts lines.
|
|
</p>
|
|
<p>This is a source breakpoint.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-add_002dephemeral_002dtrap_002dat_002dframe_002dfinish_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">add-ephemeral-trap-at-frame-finish!</strong> <var class="def-var-arguments">frame handler</var><a class="copiable-link" href="#index-add_002dephemeral_002dtrap_002dat_002dframe_002dfinish_0021"> ¶</a></span></dt>
|
|
<dd><p>Install a trap that will call <var class="var">handler</var> when <var class="var">frame</var> finishes
|
|
executing. The trap will be removed from the trap state after firing, or
|
|
on nonlocal exit.
|
|
</p>
|
|
<p>This is a finish trap, used to implement the “finish” REPL command.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-add_002dephemeral_002dstepping_002dtrap_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">add-ephemeral-stepping-trap!</strong> <var class="def-var-arguments">frame handler [#:into?] [#:instruction?]</var><a class="copiable-link" href="#index-add_002dephemeral_002dstepping_002dtrap_0021"> ¶</a></span></dt>
|
|
<dd><p>Install a trap that will call <var class="var">handler</var> after stepping to a
|
|
different source line or instruction. The trap will be removed from the
|
|
trap state after firing, or on nonlocal exit.
|
|
</p>
|
|
<p>If <var class="var">instruction?</var> is false (the default), the trap will fire when
|
|
control reaches a new source line. Otherwise it will fire when control
|
|
reaches a new instruction.
|
|
</p>
|
|
<p>Additionally, if <var class="var">into?</var> is false (not the default), the trap will
|
|
only fire for frames at or prior to the given frame. If <var class="var">into?</var> is
|
|
true (the default), the trap may step into nested procedure
|
|
invocations.
|
|
</p>
|
|
<p>This is a stepping trap, used to implement the “step”, “next”,
|
|
“step-instruction”, and “next-instruction” REPL commands.
|
|
</p></dd></dl>
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="nav-panel">
|
|
<p>
|
|
Previous: <a href="Trap-States.html">Trap States</a>, Up: <a href="Traps.html">Traps</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|