'\" t .\" This documentation, which is part of the afnix writing .\" system distribution, is free and can be distributed as .\" long as this copyright notice is left intact. .\" .\" This documentation is distributed in the hope that it .\" will be useful, but without any warranty; without even .\" the implied warranty of merchantability and fitness .\" for a particular purpose. In no event, shall the .\" copyright holder be liable for any direct, incident .\" incidental or special damages arising in any way out .\" of the use of this documentation. .\" .\" Copyright (c) 1999-2017 Amaury Darsch .\" .TH axd 1 2017-09-27 AFNIX "AFNIX Client" .SH NAME axd - afnix cross debugger .SH SYNOPSIS axd [options] file .SH OPTIONS .sp .B [h] .br prints the help message .sp .B [v] .br prints the program version .sp .B [i] path .br add a directory path to the resolver .sp .B [e] mode .br force the encoding mode .sp .B [f] runini .br run initial file .sp .B [f] emacs .br enable emacs mode .sp .B [f] assert .br enable assertion checking .sp .B [f] noseed .br do not seed the random engine .sp .B [f] seed .br seed the random engine .SH DESCRIPTION axdinvokes the AFNIX cross debugger. The axdclient permits to debug an AFNIX program by inserting breakpoint at strategic positions in the source code. During a debugging session, when a breakpoint is reached, the program is suspended and the debugger prompt is shown. Since the debugger is based on the AFNIX interpreter, the full power of the AFNIX interpreter is available at the debugger prompt. .SH VERSION The current version is the 2.8.0release. .SH SEE ALSO axc, axd, axl, .SH NOTES AFNIX comes with an extensive documentation. The documentation is available onlineor in the docdirectory in the form of formatted xhtml documents. .SH AUTHOR axdhas been written by (amaury@afnix.org) Amaury Darsch. .SH GETTING STARTED This chapter is short introduction to the cross debugger or axd. The debugger is a special interpreter that is designed to help the developer to trace an application. The debugger is designed to operate in a stand-alone mode or with Emacs. If you plan to use the debugger with Emacs, you will have to install a gud-modepackage. .PP .B A sample debugger session .br The cross debugger or axdis a special interpreter that gives the developer the opportunity to trace an application and examine the object contents during the execution. Operations normally available in a debugger are available with axd. Such operations include breakpoints, stepping, stack tracing, and many others. Because axdis built on top of the interpreter, all standard operations are supported by the debugger. .PP .I Starting the debugger .br The debugger is started with the command axd. Within Emacs, the command Meta-x axdwill do the same. When the debugger is started, an axdprompt is displayed. At this stage, there is no difference with the standard interpreter, except that a new namesetcalled axdis defined with all debugger commands. The axd:quitor axd:quitcommands will terminate the session. .sp .nf zsh> axd (axd)axd:quit .fi .sp .PP .I Debugger commands .br All debugger commands are located in the axdnameset. For example, the command to set a breakpoint is axd:break. Since typing such command can be annoying, it is possible to rebind them at your convenience. For example, the form const b axd:breakwill define the symbol bas the breakpoint command, but care should be taken with this approach if your program uses the same symbol. .PP .I Debugging session example .br The first example that demonstrates the use of axdis located in the directory exp/ref, that is part of this distribution. The platform information example 0501.alswill be used for illustration. A simple session and the original source code is given below. .sp .nf zsh> axi 0501.als major version number : minor version number : patch version number : interpreter version : ..program name : afnix operating system name : linux operating system type : unix afnix official uri : http://www.afnix.org .fi .sp The source code for this example is given below. .sp .nf # many comments before println "major version number : " interp:major-version println "minor version number : " interp:minor-version println "patch version number : " interp:patch-version println "interpreter version : " interp:version println "program name : " interp:program-name println "operating system name : " interp:os-name println "operating system type : " interp:os-type println "afnix official url : " interp:afnix-uri .fi .sp The debugger is started with the file to debug. The axd:infocommand can be used to print some information. .sp .nf zsh> axd 0501.als (axd) axd:info debugger version : ..os name : linux os type : unix initial file : 0501.als form file name : 0501.als form line number : 17 verbose mode : true max line display : 10 defined breakpoints : 0 (axd) .fi .sp Along with the version, initial file name and other information, is the form file nameand the form line numberthat indicates where the debugger is position. Another way to get this information is with the axd:listcommand that display the file at its current break position. .sp .nf (axd) axd:list 17 println "major version number : " interp:major-version 18 println "minor version number : " interp:minor-version 19 println "patch version number : " interp:patch-version 20 println "interpreter version : " interp:version 21 println "program name : " interp:program-name 22 println "operating system name : " interp:os-name 23 println "operating system type : " interp:os-type 24 println "afnix official uri : " interp:afnix-uri 25 26 (axd) .fi .sp With this in place it is possible to run the program. The axd:runcommand will do the job, but will not give you the opportunity to do something since there is no breakpoint installed. So, installing a breakpoint is simply achieved by giving the file name and line number. To make life easier, the axd:breakcommand takes also 0 or argument. Without argument, a breakpoint is set at the current position. With one integer argument, a breakpoint is set at the specified line in the current file. If the verbose mode is active (which is the default), a message is printed to indicate the breakpoint index. .sp .nf (axd) axd:break 19 setting breakpoint 0 in file 0501.als at line 19 (axd)axd:run major version number : minor version number : breakpoint 0 in file 0501.als at line 19 (axd) .fi .sp The axd:runcommand starts the program and immediately stops at the breakpoint. Note that the debugger prints a message to indicate the cause of such break. After this, stepping is achieved with the axd:nextcommand. Resuming the execution is done with the axd:continuecommand. The axd:exitor axd:quitcommand terminates the session. .sp .nf (axd)axd:next patch version number : (axd)axd:next interpreter version : --(axd)axd:continue program name : axd operating system name : linux operating system type : unix afnix official uri : http://www.afnix.org (axd)axd:quit .fi .sp .SH USING THE DEBUGGER This chapter describes in detail the usage of the cross debugger or axc. The debugger is a special application that is built on top of the interpreter. For this reason, the debugger provides the full execution environment with special commands bound into a dedicated nameset. .PP .B Invocation and termination .br The axddebugger is started by typing the command axd. Once started, the debugger reads the commands from the terminal. Since the debugger is built on top of the interpreter, any command is in fact a special form that is executed by the interpreter. The natural way to invoke the debugger is to pass the primary file to debug with eventually some arguments. .sp .nf zsh> axd PROGRAM [arguments] .fi .sp When the debugger is started, a prompt '(axd)'indicates that the session is running. The debugger session is terminated with the commands axd:exitor axd:quit. .sp .nf zsh> axd PROGRAM (axd) axd:quit zsh> .fi .sp .PP .I Debugger options .br The available options can be seen with the hoption and the current version with the voption. This mode of operations is similar to the one found with the interpreter. .sp .nf zsh> axd [h] usage: axd [options] [file] [arguments] [h] print this help message [v] print version information [i] path add a path to the resolver [e mode] force the encoding mode [f runini] run initial file [f emacs] enable emacs mode [f assert] enable assertion checks [f nopath] do not set initial path .fi .sp .PP .I Running the program .br When a program is run within the debugger, a primary file must be used to indicate where to start the program. The file name can be given either as an axdcommand argument or with the axd:loadcommand. The first available form in the primary file is used as the program starting point. .PP .I Loading the program .br The axd:loadcommand loads the primary file and mark the first available form as the starting form for the program execution. The command takes a file name as its first argument. The resolver rule apply for the file name resolution. .RS .br If the string name has the .alsextension, the string is considered to be the file name. .br If the string name has the .axcextension or no extension, the string is used to search a file that has a .alsextension or that belongs to a librarian. .RE .sp Note that these operations are also dependent on the ioption that adds a path or a librarian to the search-path. .PP .I Starting the program .br The axd:runcommand starts the program at the first available form in the primary file. The program is executed until a breakpoint or any other halting condition is reached. Generally, when the program execution is suspended, an entry into the debugger is done and the prompt is shown at the command line. .sp .nf (axd)axd:run .fi .sp The axd:runis the primary command to execute before the program can be debugged. Eventually, a file name can be used as the primary file to execute. .sp .nf (axd)axd:run "test.als" .fi .sp .PP .I Setting program arguments .br Since the debugger is built on top of the interpreter, it is possible to set directly the argument vector. The argument vector is bound to the interpreter with the qualified name interp:argv. The standard vector can be used to manipulate the argument vector. .sp .nf (axd)interp:argv:reset (axd)interp:argv:append "hello" .fi .sp In this example, the interpreter argument vector is reset and then a single argument string is added to the vector. If one wants to see the interpreter argument vector, a simple procedure can be used as shown below. .sp .nf const argc (interp:argv:length) loop (trans i 0) (< i argc) (i:++) { trans arg (interp:argv:get i) println "argv[" i "] = " arg } .fi .sp .PP .B Breakpoints operations .br Breakpoints are set with the axd:breakcommand. If a breakpoint is reached during the program execution, the program is suspended and the debugger session is resumed with a command prompt. At the command prompt, the full interpreter is available. It permits to examine symbols. .PP .I Breakpoint command .br The axd:breakcommand sets a breakpoint in a file at a specified line number. If the file is not specified, the primary file is used instead. If the line number is not specified, the first available form in the current file is used. .sp .nf (axd) axd:break "demo.als" 12 Setting breakpoint 0 in file demo.als at line 12 .fi .sp In this example, a breakpoint is set in the file demo.alsat the line number 12. The file name does not have to be the primary file. If another file name is specified, the file is loaded, instrumented and the breakpoint is set. .PP .I Viewing breakpoints .br The axd:break-infocommand reports some information about the current breakpoint setting. .sp .nf (axd) axd:break "demo.als" 12 (axd) axd:break "test.als" 18 (axd) axd:break-info Breakpoint 0 in file demo.als at line 12 Breakpoint 1 in file test.als at line 18 .fi .sp .PP .I Resuming execution .br The axd:continuecommand resumes the program execution after a breakpoint. The program execution continues until another breaking condition is reached or the program terminates. .sp .nf (axd) axd:run Breakpoint 0 in file demo.als at line 12 (axd) axd:continue .fi .sp In this example, the program is run and stopped at breakpoint 0. The axd:continuecommand resumes the program execution. .SH DEBUGGER CONTROL REFERENCE This appendix is a reference of the cross debugger or axd. The cross debugger is started with the axdcommand. All control commands are bound to the axdnameset. .PP .B break .br The axd:breakbreak command sets a breakpoint. Without argument a breakpoint is set in the current file at the current line. With a line number, the breakpoint is set in the current file. With two arguments, the first one is used as the file name and the second one is used as the line number. .PP .I Syntax .br .sp .RS axd:break axd:break "line" axd:break "file" "line" .RE .sp .nf (axd) axd:break "demo.als" 12 (axd) axd:break 25 .fi .sp The first example sets a breakpoint in the file demo.alsat line 12. The second example sets a breakpoint in the current file at line 25. Without argument, the command sets the breakpoint at the current line. The current line can be seen with the axd:infocommand. .PP .B break-info .br The axd:break-infocontrol command reports some information about the current breakpoints. .PP .I Syntax .br .sp .RS axd:break-info .RE .sp .nf (axd) axd:break "demo.als" 12 (axd) axd:break "test.als" 18 (axd) axd:break-info Breakpoint 0 in file demo.als at line 12 Breakpoint 1 in file test.als at line 18 .fi .sp In this example, two breakpoints are set. One in file demo.alsat line 12 and one in file test.alsat line 18. The axd:break-infocommand reports the current breakpoint settings. .PP .B continue .br The axd:continuecontrol command resumes the program execution after a breakpoint. The program execution continues until a breakpoint or another terminating condition is reached. .PP .I Syntax .br .sp .RS axd:continue .RE .sp .nf (axd) axd:run Breakpoint 0 in file demo.als at line 12 (axd) axd:continue .fi .sp In this example, the program is run and stopped at breakpoint 0. The axd:continuecommand resumes the program execution. .PP .B exit .br The axd:exitcommand terminates a debugger session. This command is similar to the axd:quitcommand. .PP .I Syntax .br .sp .RS axd:exit .RE .sp .nf (axd) axd:exit .fi .sp .PP .B info .br The axd:infocommand reports some debugger information. Such information includes the debugger version, the operating system, the primary input file, the primary input file source and more. .PP .I Syntax .br .sp .RS axd:info .RE .sp .nf (axd) axd:info debugger version : ..os name : linux os type : unix initial file : 0501 form file name : 0501.als form line number : 17 verbose mode : true max line display : 10 defined breakpoints : 0 .fi .sp .PP .B list .br The axd:listcommand display the form listing starting at the current session line number. The current form line number can also be seen with the axd:infocommand. The number of line is a debugger parameter. The first line to display can also be set as the first parameter. A file name can also be set. .PP .I Syntax .br .sp .RS axd:list axd:list "line" axd:list "file" "line" .RE .sp .nf (axd) axd:list (axd) axd:list 20 (axd) axd:list "file.als" 20 .fi .sp The first example shows the listing at the current debugger line. The second example starts the listing at line 20. The third example starts at line 20 with file file.als. .PP .B load .br The axd:loadcommand sets the initialor default file to be used with the axd:runcontrol command. .PP .I Syntax .br .sp .RS axd:load "file" .RE .sp .nf (axd) axd:load "demo.als" .fi .sp In this example, the file demo.alsis set as the primary file. Using the axd:infocommand will report at which line, the first available form has been found. .PP .B next .br The axd:nextcommand executes the next line in the source file. The axd:nextcommand does not take argument. .PP .I Syntax .br .sp .RS axd:next .RE .sp .nf (axd) axd:next .fi .sp .PP .B quit .br The axd:quitcommand terminates a debugger session. This command is similar to the axd:exitcommand. .PP .I Syntax .br .sp .RS axd:quit .RE .sp .nf (axd) axd:quit .fi .sp .PP .B run .br The axd:runcommand executes the default file in the slave interpreter. Without argument, the initialor default file is executed. The axd:loadcommand can be used to set the initial file. With one argument, the file name argument is used as the initial file. .PP .I Syntax .br .sp .RS axd:run axd:run "file" .RE .sp .nf (axd) axd:run (axd) axd:run "demo.als" .fi .sp The first example runs the initial file. The second example sets the initial file as demo.alsand run it.