File: debug-internals.tex

package info (click to toggle)
sbcl 2%3A2.2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 45,620 kB
  • sloc: lisp: 466,598; ansic: 34,134; sh: 5,019; asm: 2,124; makefile: 418; pascal: 207; cpp: 27
file content (765 lines) | stat: -rw-r--r-- 27,787 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
\chapter{Debugger Programmer's Interface}
\label{debug-internals}

The debugger programmers interface is exported from from the
\code{DEBUG-INTERNALS} or \code{DI} package.  This is a CMU
extension that allows debugging tools to be written without detailed
knowledge of the compiler or run-time system.

Some of the interface routines take a code-location as an argument.  As
described in the section on code-locations, some code-locations are
unknown.  When a function calls for a \var{basic-code-location}, it
takes either type, but when it specifically names the argument
\var{code-location}, the routine will signal an error if you give it an
unknown code-location.


\section{DI Exceptional Conditions}

Some of these operations fail depending on the availability debugging
information.  In the most severe case, when someone saved a Lisp image
stripping all debugging data structures, no operations are valid.  In
this case, even backtracing and finding frames is impossible.  Some
interfaces can simply return values indicating the lack of information,
or their return values are naturally meaningful in light missing data.
Other routines, as documented below, will signal
\code{serious-condition}s when they discover awkward situations.  This
interface does not provide for programs to detect these situations other
than by calling a routine that detects them and signals a condition.
These are serious-conditions because the program using the interface
must handle them before it can correctly continue execution.  These
debugging conditions are not errors since it is no fault of the
programmers that the conditions occur.

\subsection{Debug-conditions}

The debug internals interface signals conditions when it can't adhere
to its contract.  These are serious-conditions because the program
using the interface must handle them before it can correctly continue
execution.  These debugging conditions are not errors since it is no
fault of the programmers that the conditions occur.  The interface
does not provide for programs to detect these situations other than
calling a routine that detects them and signals a condition.


\begin{deftp}{Condition}{debug-condition}{}

This condition inherits from serious-condition, and all debug-conditions
inherit from this.  These must be handled, but they are not programmer errors.
\end{deftp}


\begin{deftp}{Condition}{no-debug-info}{}

This condition indicates there is absolutely no debugging information
available.
\end{deftp}


\begin{deftp}{Condition}{no-debug-function-returns}{}

This condition indicates the system cannot return values from a frame since
its debug-function lacks debug information details about returning values.
\end{deftp}


\begin{deftp}{Condition}{no-debug-blocks}{}
This condition indicates that a function was not compiled with debug-block
information, but this information is necessary necessary for some requested
operation.
\end{deftp}

\begin{deftp}{Condition}{no-debug-variables}{}
Similar to \code{no-debug-blocks}, except that variable information was
requested.
\end{deftp}

\begin{deftp}{Condition}{lambda-list-unavailable}{}
Similar to \code{no-debug-blocks}, except that lambda list information was
requested.
\end{deftp}

\begin{deftp}{Condition}{invalid-value}{}

This condition indicates a debug-variable has \kwd{invalid} or \kwd{unknown}
value in a particular frame.
\end{deftp}


\begin{deftp}{Condition}{ambiguous-variable-name}{}

This condition indicates a user supplied debug-variable name identifies more
than one valid variable in a particular frame.
\end{deftp}


\subsection{Debug-errors}

These are programmer errors resulting from misuse of the debugging tools'
programmers' interface.  You could have avoided an occurrence of one of these
by using some routine to check the use of the routine generating the error.


\begin{deftp}{Condition}{debug-error}{}
This condition inherits from error, and all user programming errors inherit
from this condition.
\end{deftp}


\begin{deftp}{Condition}{unhandled-condition}{}
This error results from a signalled \code{debug-condition} occurring
without anyone handling it.
\end{deftp}


\begin{deftp}{Condition}{unknown-code-location}{}
This error indicates the invalid use of an unknown-code-location.
\end{deftp}


\begin{deftp}{Condition}{unknown-debug-variable}{}

This error indicates an attempt to use a debug-variable in conjunction with an
inappropriate debug-function; for example, checking the variable's validity
using a code-location in the wrong debug-function will signal this error.
\end{deftp}


\begin{deftp}{Condition}{frame-function-mismatch}{}

This error indicates you called a function returned by
\code{preprocess-for-eval}
on a frame other than the one for which the function had been prepared.
\end{deftp}


\section{Debug-variables}

Debug-variables represent the constant information about where the system
stores argument and local variable values.  The system uniquely identifies with
an integer every instance of a variable with a particular name and package.  To
access a value, you must supply the frame along with the debug-variable since
these are particular to a function, not every instance of a variable on the
stack.

\begin{defun}{}{debug-variable-name}{\args{\var{debug-variable}}}
  
  This function returns the name of the \var{debug-variable}.  The
  name is the name of the symbol used as an identifier when writing
  the code.
\end{defun}


\begin{defun}{}{debug-variable-package}{\args{\var{debug-variable}}}
  
  This function returns the package name of the \var{debug-variable}.
  This is the package name of the symbol used as an identifier when
  writing the code.
\end{defun}


\begin{defun}{}{debug-variable-symbol}{\args{\var{debug-variable}}}
  
  This function returns the symbol from interning
  \code{debug-variable-name} in the package named by
  \code{debug-variable-package}.
\end{defun}


\begin{defun}{}{debug-variable-id}{\args{\var{debug-variable}}}
  
  This function returns the integer that makes \var{debug-variable}'s
  name and package name unique with respect to other
  \var{debug-variable}'s in the same function.
\end{defun}


\begin{defun}{}{debug-variable-validity}{%
    \args{\var{debug-variable} \var{basic-code-location}}}
  
  This function returns three values reflecting the validity of
  \var{debug-variable}'s value at \var{basic-code-location}:
  \begin{Lentry}
  \item[\kwd{valid}] The value is known to be available.
  \item[\kwd{invalid}] The value is known to be unavailable.
  \item[\kwd{unknown}] The value's availability is unknown.
  \end{Lentry}
\end{defun}


\begin{defun}{}{debug-variable-value}{\args{\var{debug-variable}
      \var{frame}}}
  
  This function returns the value stored for \var{debug-variable} in
  \var{frame}.  The value may be invalid.  This is \code{SETF}'able.
\end{defun}


\begin{defun}{}{debug-variable-valid-value}{%
    \args{\var{debug-variable} \var{frame}}}
  
  This function returns the value stored for \var{debug-variable} in
  \var{frame}.  If the value is not \kwd{valid}, then this signals an
  \code{invalid-value} error.
\end{defun}


\section{Frames}

Frames describe a particular call on the stack for a particular thread.  This
is the environment for name resolution, getting arguments and locals, and
returning values.  The stack conceptually grows up, so the top of the stack is
the most recently called function.

\code{top-frame}, \code{frame-down}, \code{frame-up}, and
\code{frame-debug-function} can only fail when there is absolutely no
debug information available.  This can only happen when someone saved a
Lisp image specifying that the system dump all debugging data.


\begin{defun}{}{top-frame}{}
  
  This function never returns the frame for itself, always the frame
  before calling \code{top-frame}.
\end{defun}


\begin{defun}{}{frame-down}{\args{\var{frame}}}
  
  This returns the frame immediately below \var{frame} on the stack.
  When \var{frame} is the bottom of the stack, this returns \nil.
\end{defun}


\begin{defun}{}{frame-up}{\args{\var{frame}}}
  
  This returns the frame immediately above \var{frame} on the stack.
  When \var{frame} is the top of the stack, this returns \nil.
\end{defun}


\begin{defun}{}{frame-debug-function}{\args{\var{frame}}}
  
  This function returns the debug-function for the function whose call
  \var{frame} represents.
\end{defun}


\begin{defun}{}{frame-code-location}{\args{\var{frame}}}
  
  This function returns the code-location where \var{frame}'s
  debug-function will continue running when program execution returns
  to \var{frame}.  If someone interrupted this frame, the result could
  be an unknown code-location.
\end{defun}


\begin{defun}{}{frame-catches}{\args{\var{frame}}}
  
  This function returns an a-list for all active catches in
  \var{frame} mapping catch tags to the code-locations at which the
  catch re-enters.
\end{defun}


\begin{defun}{}{eval-in-frame}{\args{\var{frame} \var{form}}}
  
  This evaluates \var{form} in \var{frame}'s environment.  This can
  signal several different debug-conditions since its success relies
  on a variety of inexact debug information: \code{invalid-value},
  \code{ambiguous-variable-name}, \code{frame-function-mismatch}.  See
  also \funref{preprocess-for-eval}.
\end{defun}

%   \begin{defun}{}{return-from-frame}{\args{\var{frame} \var{values}}}
%     
%     This returns the elements in the list \var{values} as multiple
%     values from \var{frame} as if the function \var{frame} represents
%     returned these values.  This signals a
%     \code{no-debug-function-returns} condition when \var{frame}'s
%     debug-function lacks information on returning values.
%     
%     \i{Not Yet Implemented}
%   \end{defun}


\section {Debug-functions}

Debug-functions represent the static information about a function determined at
compile time---argument and variable storage, their lifetime information,
etc.  The debug-function also contains all the debug-blocks representing
basic-blocks of code, and these contains information about specific
code-locations in a debug-function.

\begin{defmac}{}{do-debug-function-blocks}{%
    \args{(\var{block-var} \var{debug-function} \mopt{result-form})
      \mstar{form}}}
  
  This executes the forms in a context with \var{block-var} bound to
  each debug-block in \var{debug-function} successively.
  \var{Result-form} is an optional form to execute for a return value,
  and \code{do-debug-function-blocks} returns \nil if there is no
  \var{result-form}.  This signals a \code{no-debug-blocks} condition
  when the \var{debug-function} lacks debug-block information.
\end{defmac}


\begin{defun}{}{debug-function-lambda-list}{\args{\var{debug-function}}}
  
  This function returns a list representing the lambda-list for
  \var{debug-function}.  The list has the following structure:
  \begin{example}
    (required-var1 required-var2
    ...
    (:optional var3 suppliedp-var4)
    (:optional var5)
    ...
    (:rest var6) (:rest var7)
    ...
    (:keyword keyword-symbol var8 suppliedp-var9)
    (:keyword keyword-symbol var10)
    ...
    )
  \end{example}
  Each \code{var}\var{n} is a debug-variable; however, the symbol
  \kwd{deleted} appears instead whenever the argument remains
  unreferenced throughout \var{debug-function}.
  
  If there is no lambda-list information, this signals a
  \code{lambda-list-unavailable} condition.
\end{defun}


\begin{defmac}{}{do-debug-function-variables}{%
    \args{(\var{var} \var{debug-function} \mopt{result})
      \mstar{form}}}
  
  This macro executes each \var{form} in a context with \var{var}
  bound to each debug-variable in \var{debug-function}.  This returns
  the value of executing \var{result} (defaults to \nil).  This may
  iterate over only some of \var{debug-function}'s variables or none
  depending on debug policy; for example, possibly the compilation
  only preserved argument information.
\end{defmac}


\begin{defun}{}{debug-variable-info-available}{\args{\var{debug-function}}}
  
  This function returns whether there is any variable information for
  \var{debug-function}.  This is useful for distinguishing whether
  there were no locals in a function or whether there was no variable
  information.  For example, if \code{do-debug-function-variables}
  executes its forms zero times, then you can use this function to
  determine the reason.
\end{defun}


\begin{defun}{}{debug-function-symbol-variables}{%
    \args{\var{debug-function} \var{symbol}}}
  
  This function returns a list of debug-variables in
  \var{debug-function} having the same name and package as
  \var{symbol}.  If \var{symbol} is uninterned, then this returns a
  list of debug-variables without package names and with the same name
  as \var{symbol}.  The result of this function is limited to the
  availability of variable information in \var{debug-function}; for
  example, possibly \var{debug-function} only knows about its
  arguments.
\end{defun}


\begin{defun}{}{ambiguous-debug-variables}{%
    \args{\var{debug-function} \var{name-prefix-string}}}
  
  This function returns a list of debug-variables in
  \var{debug-function} whose names contain \var{name-prefix-string} as
  an initial substring.  The result of this function is limited to the
  availability of variable information in \var{debug-function}; for
  example, possibly \var{debug-function} only knows about its
  arguments.
\end{defun}


\begin{defun}{}{preprocess-for-eval}{%
    \args{\var{form} \var{basic-code-location}}}
  
  This function returns a function of one argument that evaluates
  \var{form} in the lexical context of \var{basic-code-location}.
  This allows efficient repeated evaluation of \var{form} at a certain
  place in a function which could be useful for conditional breaking.
  This signals a \code{no-debug-variables} condition when the
  code-location's debug-function has no debug-variable information
  available.  The returned function takes a frame as an argument.  See
  also \funref{eval-in-frame}.
\end{defun}


\begin{defun}{}{function-debug-function}{\args{\var{function}}}
  
  This function returns a debug-function that represents debug
  information for \var{function}.
\end{defun}


\begin{defun}{}{debug-function-kind}{\args{\var{debug-function}}}
  
  This function returns the kind of function \var{debug-function}
  represents.  The value is one of the following:
  \begin{Lentry}
  \item[\kwd{optional}] This kind of function is an entry point to an
    ordinary function.  It handles optional defaulting, parsing
    keywords, etc.
  \item[\kwd{external}] This kind of function is an entry point to an
    ordinary function.  It checks argument values and count and calls
    the defined function.
  \item[\kwd{top-level}] This kind of function executes one or more
    random top-level forms from a file.
  \item[\kwd{cleanup}] This kind of function represents the cleanup
    forms in an \code{unwind-protect}.
  \item[\nil] This kind of function is not one of the above; that is,
    it is not specially marked in any way.
  \end{Lentry}
\end{defun}


\begin{defun}{}{debug-function-function}{\args{\var{debug-function}}}
  
  This function returns the Common Lisp function associated with the
  \var{debug-function}.  This returns \nil{} if the function is
  unavailable or is non-existent as a user callable function object.
\end{defun}


\begin{defun}{}{debug-function-name}{\args{\var{debug-function}}}
  
  This function returns the name of the function represented by
  \var{debug-function}.  This may be a string or a cons; do not assume
  it is a symbol.
\end{defun}


\section{Debug-blocks}

Debug-blocks contain information pertinent to a specific range of code in a
debug-function.

\begin{defmac}{}{do-debug-block-locations}{%
    \args{(\var{code-var} \var{debug-block} \mopt{result})
      \mstar{form}}}
  
  This macro executes each \var{form} in a context with \var{code-var}
  bound to each code-location in \var{debug-block}.  This returns the
  value of executing \var{result} (defaults to \nil).
\end{defmac}


\begin{defun}{}{debug-block-successors}{\args{\var{debug-block}}}
  
  This function returns the list of possible code-locations where
  execution may continue when the basic-block represented by
  \var{debug-block} completes its execution.
\end{defun}


\begin{defun}{}{debug-block-elsewhere-p}{\args{\var{debug-block}}}
  
  This function returns whether \var{debug-block} represents elsewhere
  code.  This is code the compiler has moved out of a function's code
  sequence for optimization reasons.  Code-locations in these blocks
  are unsuitable for stepping tools, and the first code-location has
  nothing to do with a normal starting location for the block.
\end{defun}


\section{Breakpoints}

A breakpoint represents a function the system calls with the current frame when
execution passes a certain code-location.  A break point is active or inactive
independent of its existence.  They also have an extra slot for users to tag
the breakpoint with information.

\begin{defun}{}{make-breakpoint}{%
    \args{\var{hook-function} \var{what} \keys{\kwd{kind} \kwd{info}
        \kwd{function-end-cookie}}}}
  
  This function creates and returns a breakpoint.  When program
  execution encounters the breakpoint, the system calls
  \var{hook-function}.  \var{hook-function} takes the current frame
  for the function in which the program is running and the breakpoint
  object.
  
  \var{what} and \var{kind} determine where in a function the system
  invokes \var{hook-function}.  \var{what} is either a code-location
  or a debug-function.  \var{kind} is one of \kwd{code-location},
  \kwd{function-start}, or \kwd{function-end}.  Since the starts and
  ends of functions may not have code-locations representing them,
  designate these places by supplying \var{what} as a debug-function
  and \var{kind} indicating the \kwd{function-start} or
  \kwd{function-end}.  When \var{what} is a debug-function and
  \var{kind} is \kwd{function-end}, then hook-function must take two
  additional arguments, a list of values returned by the function and
  a function-end-cookie.
  
  \var{info} is information supplied by and used by the user.
  
  \var{function-end-cookie} is a function.  To implement function-end
  breakpoints, the system uses starter breakpoints to establish the
  function-end breakpoint for each invocation of the function.  Upon
  each entry, the system creates a unique cookie to identify the
  invocation, and when the user supplies a function for this argument,
  the system invokes it on the cookie.  The system later invokes the
  function-end breakpoint hook on the same cookie.  The user may save
  the cookie when passed to the function-end-cookie function for later
  comparison in the hook function.
  
  This signals an error if \var{what} is an unknown code-location.
  
  {\em Note: Breakpoints in interpreted code or byte-compiled code are
    not implemented.  Function-end breakpoints are not implemented for
    compiled functions that use the known local return convention
    (e.g. for block-compiled or self-recursive functions.)}

\end{defun}


\begin{defun}{}{activate-breakpoint}{\args{\var{breakpoint}}}
  
  This function causes the system to invoke the \var{breakpoint}'s
  hook-function until the next call to \code{deactivate-breakpoint} or
  \code{delete-breakpoint}.  The system invokes breakpoint hook
  functions in the opposite order that you activate them.
\end{defun}


\begin{defun}{}{deactivate-breakpoint}{\args{\var{breakpoint}}}
  
  This function stops the system from invoking the \var{breakpoint}'s
  hook-function.
\end{defun}


\begin{defun}{}{breakpoint-active-p}{\args{\var{breakpoint}}}
  
  This returns whether \var{breakpoint} is currently active.
\end{defun}


\begin{defun}{}{breakpoint-hook-function}{\args{\var{breakpoint}}}
  
  This function returns the \var{breakpoint}'s function the system
  calls when execution encounters \var{breakpoint}, and it is active.
  This is \code{SETF}'able.
\end{defun}


\begin{defun}{}{breakpoint-info}{\args{\var{breakpoint}}}
  
  This function returns \var{breakpoint}'s information supplied by the
  user.  This is \code{SETF}'able.
\end{defun}


\begin{defun}{}{breakpoint-kind}{\args{\var{breakpoint}}}

  This function returns the \var{breakpoint}'s kind specification.
\end{defun}


\begin{defun}{}{breakpoint-what}{\args{\var{breakpoint}}}
  
  This function returns the \var{breakpoint}'s what specification.
\end{defun}


\begin{defun}{}{delete-breakpoint}{\args{\var{breakpoint}}}
  
  This function frees system storage and removes computational
  overhead associated with \var{breakpoint}.  After calling this,
  \var{breakpoint} is useless and can never become active again.
\end{defun}


\section{Code-locations}

Code-locations represent places in functions where the system has correct
information about the function's environment and where interesting operations
can occur---asking for a local variable's value, setting breakpoints,
evaluating forms within the function's environment, etc.

Sometimes the interface returns unknown code-locations.  These
represent places in functions, but there is no debug information
associated with them.  Some operations accept these since they may
succeed even with missing debug data.  These operations' argument is
named \var{basic-code-location} indicating they take known and unknown
code-locations.  If an operation names its argument
\var{code-location}, and you supply an unknown one, it will signal an
error.  For example, \code{frame-code-location} may return an unknown
code-location if someone interrupted Lisp in the given frame.  The
system knows where execution will continue, but this place in the code
may not be a place for which the compiler dumped debug information.

\begin{defun}{}{code-location-debug-function}{\args{\var{basic-code-location}}}
  
  This function returns the debug-function representing information
  about the function corresponding to the code-location.
\end{defun}


\begin{defun}{}{code-location-debug-block}{\args{\var{basic-code-location}}}
  
  This function returns the debug-block containing code-location if it
  is available.  Some debug policies inhibit debug-block information,
  and if none is available, then this signals a \code{no-debug-blocks}
  condition.
\end{defun}


\begin{defun}{}{code-location-top-level-form-offset}{%
    \args{\var{code-location}}}
  
  This function returns the number of top-level forms before the one
  containing \var{code-location} as seen by the compiler in some
  compilation unit.  A compilation unit is not necessarily a single
  file, see the section on debug-sources.
\end{defun}


\begin{defun}{}{code-location-form-number}{\args{\var{code-location}}}
  
  This function returns the number of the form corresponding to
  \var{code-location}.  The form number is derived by walking the
  subforms of a top-level form in depth-first order.  While walking
  the top-level form, count one in depth-first order for each subform
  that is a cons.  See \funref{form-number-translations}.
\end{defun}


\begin{defun}{}{code-location-debug-source}{\args{\var{code-location}}}
  
  This function returns \var{code-location}'s debug-source.
\end{defun}


\begin{defun}{}{code-location-unknown-p}{\args{\var{basic-code-location}}}
  
  This function returns whether \var{basic-code-location} is unknown.
  It returns \nil{} when the code-location is known.
\end{defun}


\begin{defun}{}{code-location=}{\args{\var{code-location1}
      \var{code-location2}}}
  
  This function returns whether the two code-locations are the same.
\end{defun}


\section{Debug-sources}

Debug-sources represent how to get back the source for some code.  The
source is either a file (\code{compile-file} or \code{load}), a
lambda-expression (\code{compile}, \code{defun}, \code{defmacro}), or
a stream (something particular to \cmucl{}, \code{compile-from-stream}).

When compiling a source, the compiler counts each top-level form it
processes, but when the compiler handles multiple files as one block
compilation, the top-level form count continues past file boundaries.
Therefore \code{code-location-top-level-form-offset} returns an offset
that does not always start at zero for the code-location's
debug-source.  The offset into a particular source is
\code{code-location-top-level-form-offset} minus
\code{debug-source-root-number}.

Inside a top-level form, a code-location's form number indicates the
subform corresponding to the code-location.

\begin{defun}{}{debug-source-from}{\args{\var{debug-source}}}
  
  This function returns an indication of the type of source.  The
  following are the possible values:
  \begin{Lentry}
  \item[\kwd{file}] from a file (obtained by \code{compile-file} if
    compiled).
  \item[\kwd{lisp}] from Lisp (obtained by \code{compile} if
    compiled).
  \item[\kwd{stream}] from a non-file stream (\cmucl{} supports
    \code{compile-from-stream}).
  \end{Lentry}
\end{defun}


\begin{defun}{}{debug-source-name}{\args{\var{debug-source}}}
  
  This function returns the actual source in some sense represented by
  debug-source, which is related to \code{debug-source-from}:
  \begin{Lentry}
  \item[\kwd{file}] the pathname of the file.
  \item[\kwd{lisp}] a lambda-expression.
  \item[\kwd{stream}] some descriptive string that's otherwise
    useless.
\end{Lentry}
\end{defun}


\begin{defun}{}{debug-source-created}{\args{\var{debug-source}}}
  
  This function returns the universal time someone created the source.
  This may be \nil{} if it is unavailable.
\end{defun}


\begin{defun}{}{debug-source-compiled}{\args{\var{debug-source}}}
  
  This function returns the time someone compiled the source.  This is
  \nil{} if the source is uncompiled.
\end{defun}


\begin{defun}{}{debug-source-root-number}{\args{\var{debug-source}}}
  
  This returns the number of top-level forms processed by the compiler
  before compiling this source.  If this source is uncompiled, this is
  zero.  This may be zero even if the source is compiled since the
  first form in the first file compiled in one compilation, for
  example, must have a root number of zero---the compiler saw no other
  top-level forms before it.
\end{defun}


\section{Source Translation Utilities}

These two functions provide a mechanism for converting the rather
obscure (but highly compact) representation of source locations into an
actual source form:

\begin{defun}{}{debug-source-start-positions}{\args{\var{debug-source}}}
  
  This function returns the file position of each top-level form as a
  vector if \var{debug-source} is from a \kwd{file}.  If
  \code{debug-source-from} is \kwd{lisp} or \kwd{stream}, or the file
  is byte-compiled, then the result is \false{}.
\end{defun}


\begin{defun}{}{form-number-translations}{\args{\var{form}
      \var{tlf-number}}}
  
  This function returns a table mapping form numbers (see
  \code{code-location-form-number}) to source-paths.  A source-path
  indicates a descent into the top-level-form \var{form}, going
  directly to the subform corresponding to a form number.
  \var{tlf-number} is the top-level-form number of \var{form}.
\end{defun}


\begin{defun}{}{source-path-context}{%
    \args{\var{form} \var{path} \var{context}}}
  
  This function returns the subform of \var{form} indicated by the
  source-path.  \var{Form} is a top-level form, and \var{path} is a
  source-path into it.  \var{Context} is the number of enclosing forms
  to return instead of directly returning the source-path form.  When
  \var{context} is non-zero, the form returned contains a marker,
  \code{\#:****HERE****}, immediately before the form indicated by
  \var{path}.
\end{defun}