| 1 |
@node Environment |
| 2 |
@section Environment |
| 3 |
|
| 4 |
@menu |
| 5 |
* Environment - Dictionary:: |
| 6 |
* Environment - C Reference:: |
| 7 |
@end menu |
| 8 |
|
| 9 |
@node Environment - Dictionary |
| 10 |
@subsection Dictionary |
| 11 |
@lspindex disassemble |
| 12 |
@lspindex ed |
| 13 |
@lspindex trace |
| 14 |
|
| 15 |
@defun disassemble function-designator* |
| 16 |
Display the assembly code of a function |
| 17 |
@paragraph Synopsis |
| 18 |
@table @var |
| 19 |
@item function-designator |
| 20 |
A symbol which is bound to a function in the global environment, or a lambda form |
| 21 |
@end table |
| 22 |
@paragraph Description |
| 23 |
As specified in ANSI @bibcite{ANSI} this function outputs the internal representation of a compiled function, or of a lambda form, as it would look after being compiled. |
| 24 |
|
| 25 |
ECL only has a particular difference: it has two different compilers, one based on bytecodes and one based on the C language. The output will thus depend on the arguments and on which compiler is active at the moment in which this function is run. |
| 26 |
|
| 27 |
@itemize |
| 28 |
@item If the argument is a bytecompiled function or a lambda form, it will be processed by the active compiler and the appropriate output (bytecodes or C) will be shown. |
| 29 |
@item If the argument is a C-compiled form, disassembling the function by showing its C source code is not possible, since that would require saving not only the lambda form of the function, but also the precise configuration of the compiler when the function was compiled. Hence no output will be shown. |
| 30 |
@end itemize |
| 31 |
@end defun |
| 32 |
|
| 33 |
@defun ed x? |
| 34 |
Invoke an editor on the file or object specified by @var{x}. |
| 35 |
@paragraph Synopsis |
| 36 |
(ed @var{x?}) |
| 37 |
@table @var |
| 38 |
@item x |
| 39 |
@code{nil}, a file path, or an object to edit. |
| 40 |
@end table |
| 41 |
|
| 42 |
@paragraph Description |
| 43 |
Starts the editor (on a file or an object if named). Functions from the list @var{ext:*ed-functions*} are called in order with @var{x} as an argument until one of them returns non-@code{nil}; these functions are responsible for signalling a @code{file-error} to indicate failure to perform an operation on the file system. If no function returns a non-@code{nil} value or @var{ext:*ed-functions*} is @code{nil} then a @code{simple-error} will be signalled. |
| 44 |
|
| 45 |
The Common Lisp specification states that the @var{x} argument is either @code{nil}, a function name, or an instance of @var{string} or @var{pathname} and that a @var{type-error} may be signalled if is not one of these types. ECL does not check the type of @var{x} and thus permits any object to be passed to the hook functions. This allows for the possibility of editing other objects that have a representation in source code such as class definitions. Therefore, the hook functions should not make any assumptions about the type of @var{x} and should instead return @code{nil} if there is not an approriate edit method for a specific value of @var{x}. |
| 46 |
|
| 47 |
By default @var{ext:*ed-functions*} contains a single function that attempts to run the program named in the environment variable @code{EDITOR}. If this environment variable is not set then the fallback program is @code{vi}. |
| 48 |
@end defun |
| 49 |
|
| 50 |
@defmac trace function-name* |
| 51 |
Follow the execution of functions |
| 52 |
@paragraph Synopsis |
| 53 |
(trace @var{function-name*}) |
| 54 |
@table @var |
| 55 |
@item function-name |
| 56 |
@{@var{symbol} | (@var{symbol} [@var{option} @var{form}]*)@} |
| 57 |
@item symbol |
| 58 |
A symbol which is bound to a function in the global environment. Not evaluated. |
| 59 |
@item option |
| 60 |
One of @code{:break}, @code{:break-after}, @code{:cond-before}, @code{:cond-after}, @code{:cond}, @code{:print}, @code{:print-after}, @code{:step} |
| 61 |
@item form |
| 62 |
A lisp form evaluated in an special environment (or a list of forms for |
| 63 |
@code{:print} and @code{:print-after}). |
| 64 |
@item returns |
| 65 |
List of symbols with traced functions. |
| 66 |
@end table |
| 67 |
|
| 68 |
@paragraph Description |
| 69 |
Causes one or more functions to be traced. Each @var{function-name} can be a symbol which is bound to a function, or a list containing that symbol plus additional options. If the function bound to that symbol is called, information about the arguments and output of this function will be printed. Trace options will modify the amount of information and when it is printed. |
| 70 |
|
| 71 |
Not that if the function is called from another function compiled in the same file, tracing might not be enabled. If this is the case, to enable tracing, recompile the caller with a @code{notinline} declaration for the called function. |
| 72 |
|
| 73 |
@code{trace} returns a name list of those functions that were traced by the call to @code{trace}. If no @var{function-name} is given, @code{trace} simply returns a name list of all the currently traced functions. |
| 74 |
|
| 75 |
Trace options cause the normal printout to be suppressed, or cause extra information to be printed. Each option is a pair of an option keyword and a value form. If an already traced function is traced again, any new options replace the old options and a warning might be printed. The lisp @var{form} accompanying the option is evaluated in an environment where @var{sys::args} contains the list of arguments to the function. |
| 76 |
|
| 77 |
The following options are defined: |
| 78 |
@table @asis |
| 79 |
@item @code{:cond}, @code{:cond-before}, @code{:cond-after} |
| 80 |
If @code{:cond-before} is specified, then @code{trace} does nothing unless @var{form} evaluates to true at the time of the call. @code{:cond-after} is similar, but suppresses the initial printout, and is tested when the function returns. @code{:cond} tries both before and after. |
| 81 |
@item @code{:step} |
| 82 |
If @var{form} evaluates to true, the stepper is entered. |
| 83 |
@item @code{:break}, @code{:break-after} |
| 84 |
If specified, and @var{form} evaluates to true, then the debugger is invoked at the start of the function or at the end of the function according to the respective option. |
| 85 |
@item @code{:print}, @code{:print-after} |
| 86 |
In addition to the usual printout, the result of evaluating each entry |
| 87 |
of the list of forms contained in @var{form} is printed at the start of |
| 88 |
the function or at the end of the function, depending on the option. |
| 89 |
@end table |
| 90 |
@end defmac |
| 91 |
|
| 92 |
See also the following example: |
| 93 |
|
| 94 |
@exindex @code{trace} usage |
| 95 |
@example |
| 96 |
> (defun abc (x) |
| 97 |
(if (>= x 10) |
| 98 |
x |
| 99 |
(abc (+ x (abc (1+ x)))))) |
| 100 |
> (trace abc) |
| 101 |
|
| 102 |
> (abc 9) |
| 103 |
1> (ABC 9) |
| 104 |
| 2> (ABC 10) |
| 105 |
| <2 (ABC 10) |
| 106 |
| 2> (ABC 19) |
| 107 |
| <2 (ABC 19) |
| 108 |
<1 (ABC 19) |
| 109 |
19 |
| 110 |
> (untrace abc) |
| 111 |
|
| 112 |
(ABC) |
| 113 |
;; Break if the first argument of the function is greater than 10 |
| 114 |
> (trace (abc :break (>= (first si::args) 10))) |
| 115 |
|
| 116 |
((ABC :BREAK (>= (FIRST SI::ARGS) 10))) |
| 117 |
> (abc 9) |
| 118 |
1> (ABC 9) |
| 119 |
| 2> (ABC 10) |
| 120 |
|
| 121 |
Condition of type: SIMPLE-CONDITION |
| 122 |
tracing ABC |
| 123 |
Available restarts: |
| 124 |
|
| 125 |
1. (CONTINUE) Return from BREAK. |
| 126 |
2. (RESTART-TOPLEVEL) Go back to Top-Level REPL. |
| 127 |
|
| 128 |
Broken at ABC. In: #<process TOP-LEVEL 0x1842f80>. |
| 129 |
>> |
| 130 |
@end example |
| 131 |
|
| 132 |
@node Environment - C Reference |
| 133 |
@subsection C Reference |
| 134 |
|
| 135 |
@subsubsection ANSI Dictionary |
| 136 |
Common Lisp and C equivalence |
| 137 |
|
| 138 |
@multitable @columnfractions .3 .7 |
| 139 |
@headitem Lisp symbol @tab C function |
| 140 |
@item @clhs{f_dec_un.htm,decode-universal-time} @tab cl_object cl_decode_universal_time(cl_narg narg, cl_object universal_time, ...) |
| 141 |
@item @clhs{f_encode.htm,encode-universal-time} @tab cl_object cl_encode_universal_time(cl_narg narg, cl_object second, cl_object minute, cl_object hour, cl_object date, cl_object month, cl_object year, ...) |
| 142 |
@item @clhs{f_get_un.htm,get-universal-time} @tab cl_object cl_get_universal_time(void) |
| 143 |
@item @clhs{f_get_un.htm,get-decoded-time} @tab cl_object cl_get_decoded_time(void) |
| 144 |
@item @clhs{f_sleep.htm,sleep} @tab cl_object cl_sleep(cl_object seconds) |
| 145 |
@item @clhs{f_apropo.htm,apropos} @tab cl_object cl_apropos(cl_narg narg, cl_object string, ...) |
| 146 |
@item @clhs{f_apropo.htm,apropos-list} @tab cl_object cl_apropos_list(cl_narg narg, cl_object string, ...) |
| 147 |
@item @clhs{f_descri.htm,describe} @tab cl_object cl_describe(cl_narg narg, cl_object object, ...) |
| 148 |
@item @clhs{f_desc_1.htm,describe-object} @tab [Only in Common Lisp] |
| 149 |
@item @clhs{f_get_in.htm,get-internal-real-time} @tab cl_object cl_get_internal_real_time(void) |
| 150 |
@item @clhs{f_get__1.htm,get-internal-run-time} @tab cl_object cl_get_internal_run_time(void) |
| 151 |
@item @clhs{f_disass.htm,disassemble} @tab [Only in Common Lisp] |
| 152 |
@item @clhs{f_docume.htm,documentation} @tab [Only in Common Lisp] |
| 153 |
@item @clhs{f_room.htm,room} @tab [Only in Common Lisp] |
| 154 |
@item @clhs{f_ed.htm,ed} @tab [Only in Common Lisp] |
| 155 |
@item @clhs{f_inspec.htm,inspect} @tab cl_object cl_inspect(cl_object object) |
| 156 |
@item @clhs{f_dribbl.htm,dribble} @tab cl_object cl_dribble(cl_narg narg, ...) |
| 157 |
@item @clhs{f_lisp_i.htm,lisp-implementation-type} @tab cl_object cl_lisp_implementation_type(void) |
| 158 |
@item @clhs{f_lisp_i.htm,lisp-implementation-version} @tab cl_object cl_lisp_implementation_version(void) |
| 159 |
@item @clhs{f_short_.htm,short-site-name} @tab cl_object cl_short_site_name() |
| 160 |
@item @clhs{f_short_.htm,long-site-name} @tab cl_object cl_long_site_name() |
| 161 |
@item @clhs{f_mach_i.htm,machine-instance} @tab cl_object cl_machine_instance() |
| 162 |
@item @clhs{f_mach_t.htm,machine-type} @tab cl_object cl_machine_type() |
| 163 |
@item @clhs{f_mach_v.htm,machine-version} @tab cl_object cl_machine_version() |
| 164 |
@item @clhs{f_sw_tpc.htm,software-type} @tab cl_object cl_software_type() |
| 165 |
@item @clhs{f_sw_tpc.htm,software-version} @tab cl_object cl_software_version() |
| 166 |
@item @clhs{f_user_h.htm,user-homedir-pathname} @tab cl_object cl_user_homedir_pathname(cl_narg narg, ...) |
| 167 |
@end multitable |