home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / szadb1_4 / primer.txt < prev    next >
Text File  |  1993-10-23  |  50KB  |  1,451 lines

  1.  
  2.  
  3.  
  4.  
  5.                              szadb primer
  6.  
  7.  
  8.  
  9.                            Michal Jaegermann
  10.  
  11.  
  12.  
  13.                               edited by
  14.  
  15.                             Anthony Howe
  16.  
  17.  
  18.                              8 July 1991
  19.  
  20.  
  21.  
  22.  
  23.  (this line printer approximation produced by dvi2tty and slightly edited)
  24.  
  25.  
  26.  
  27.  
  28. There is NO WARRANTY with respect to this publication, or the
  29. program it describes, and disclaim any implied or explicit suggestions
  30. of usefulness for any particular purpose.  Use this program only if
  31. you are willing to assume all risks, and damages, if any, arising as a
  32. result, even if caused by negligence or other fault.
  33.  
  34.  
  35.  
  36. Sozobon C compiler and szadb debugger are both copyright cfl1989
  37. by Sozobon Ltd. Both can be freely copied and distributed provided
  38. all copyright notices will remain intact and all modified versions will
  39. be clearly marked as such.
  40.  
  41.  
  42. Atari, ST, TOS and GEMDOS are trademarks of Atari Co.
  43. GEM is a trademark of Digital Research Co.
  44. Mark Williams C is a trademark or Mark Williams Co.
  45. Unix is a trademark of AT&T.
  46.  
  47.  
  48.  
  49.  
  50. 1   Introduction
  51.  
  52.  
  53. szadb is an assembly level debugger for programs written for
  54. the TOS operating system on the Atari ST computer.  It is
  55. primarily meant to be a companion to the freely distributed
  56. Sozobon C compiler, and can be copied and passed around under
  57. the same conditions.
  58. One of design goals of the original szadb project was to
  59. provide a debugger closely resembling adb, which is available
  60. on most Unix systems.  There are some dissimilarities which
  61. follow mostly from differences in target machines and
  62. operating systems.  Still users with an adb experience should
  63. feel right at home.
  64. The originally released version 1.0 was written by Johann
  65. Ruegg and Don Dugger.  Expanded to version 1.2 in a joint
  66. effort of Anthony Howe and Michal l Jaegermann.  Further
  67. development to version 1.4 by Michal l Jaegermann.  A document
  68. describing version 1.2 was prepared by Anthony Howe and
  69. Micha l Jaegermann.  Modified slightly by the last author to
  70. reflect changes in versions 1.3 and 1.4
  71. Version 1.2 introduced multi-command input lines, which could
  72. be attached to breakpoints and stepping commands.  Other it
  73. features included recording of a debugging sesion in a file,
  74. definitions function keys, and other assorted niceties.  In
  75. addition to original Sozobon C symbols (Alcyon C style, also a
  76. default for ST version of gcc compiler) it also accepted the
  77. symbol table formats from Mark Williams C.
  78. Version 1.3, not very widely distributed, added to this list a
  79. "GST extension" of a symbol table format, with symbols up to
  80. twenty two characters long.  Executables with such tables are
  81. produced by newer versions of gcc (ST) loader with -G option
  82. to the compiler.
  83. Version 1.4 brings much greater flexibility in supported
  84. screen displays.  In particular it is possible now to run
  85. szadb in all six TT resolutions.  Moniterm, in a tandem with a
  86. standard ST monitor, also can be used in a particularly
  87. convenient manner.
  88. If your compiler's symbol table format is not supported, or
  89. there are other changes or additions you wish to add, the
  90.  
  91.  
  92.  
  93.                                  1
  94.  
  95.  
  96.  
  97.  
  98. complete source is provided free with the debugger.
  99. The document you are reading now serves as a gentle
  100. introduction to "adb way of debugging".  It gives expanded
  101. explanations and examples but it does not cover all points
  102. described in a formal szadb description.  Read the other
  103. document in any case!
  104.  
  105.  
  106.  
  107. 2   First steps
  108.  
  109.  
  110. 2.1   Starting
  111.  
  112.  
  113. It is possible to run szadb either from a desktop or from a
  114. text shell, in either low, medium or high resolution.  In this
  115. tutorial we will assume that szadb was launched from a command
  116. line on a screen 80 characters wide (this setting affects only
  117. the layout of some displays) and that the executable is called
  118. adb.ttp, in tribute to its older brother.
  119. The simplest way of starting szadb is to type something
  120. similar to
  121.  
  122.  
  123.      adb.ttp program.ext
  124.  
  125.  
  126. where program.ext is any executable.  Note that the file
  127. extension (tos, ttp, prg) must be provided.  For debugging
  128. purposes, it is preferable to compile your program with
  129. debugger information (symbol tables).  For Sozobon pass the
  130. option -t to either cc or ld.  It is possible to debug a
  131. program without this information but this is not a trivial
  132. task.  This tutorial assumes that symbolic information is
  133. provided.
  134. For debugging purposes, it is much preferable not to strip off
  135. symbol tables.  In this tutorial we will always assume that
  136. this was not done.  To achieve that effect, while compiling
  137. with Sozobon C, pass -t flag to cc.
  138. If you do not have your favourite test program handy then you
  139. may compile from the provided sources and use for experiments
  140. a simplified version of unexpand.tos; it replaces, if
  141. possible, runs of white space from stdin with tabs and writes
  142. results on stdout.  Further examples will use that program
  143.  
  144.  
  145.  
  146.                                  2
  147.  
  148.  
  149.  
  150.  
  151. compiled by Sozobon C compiler, version 1.3, with -t and -O
  152. flags.
  153. Once the debugger is started you should see on your screen a
  154. display resembling the following:
  155.  
  156.  
  157.      Szadb version 1.3mj+ach(english)
  158.      >
  159.  
  160.  
  161. indicating that everything is in order.  The character > is
  162. the prompt.  Its presence is the most striking visual feature
  163. showing that we are not dealing with the "real" adb.
  164.  
  165.  
  166.  
  167. 2.2   Where am I?
  168.  
  169.  
  170. If you hit at this moment <Return> key szadb should respond
  171. with
  172.  
  173.  
  174.      __start:
  175.  
  176.  
  177. The debugger positioned itself at the very beginning of a
  178. loaded program.  szadb "remebers" the last command and its
  179. current location, which is known as "dot".  You may set
  180. "dot" by typing any valid expression which will evaluate to
  181. an address.  Hitting <Return> by itself repeats the last typed
  182. in command (not the executed one!  This distinction will be
  183. important later).
  184. In this version the "dot" is set to low TPA, or a starting
  185. execution address.  The initial default command is /a which
  186. will print the symbolic value of "dot" followed by a colon.
  187. To see a numerical display of the "dot" try the following:
  188.  
  189.  
  190.      .=X <Return>
  191.  
  192.  
  193. for a hexadecimal address, or
  194.  
  195.  
  196.      .=D <Return>
  197.  
  198.  
  199. for the same one in a decimal form.
  200. A note for Unix hackers.  In szadb there is no distinction
  201. objectspace and dataspace.  Therefore prefixes ?  and / in
  202. commands are equivalent.  Typing ?a will cause the same effect
  203. as typing /a.
  204.  
  205.  
  206.  
  207.                                  3
  208.  
  209.  
  210.  
  211.  
  212. Addresses are printed in a form symbol+offset, where possible.
  213. If there is no symbol table, or if offset is getting too big,
  214. you will notice that addresses are printed as hexadecimal
  215. values.  The offset limit has initialy value of 0x400 but it
  216. can be changed by $s request, in the form
  217.  
  218.  
  219.      <new_value>$s
  220.  
  221.  
  222. The default number base for commands and displays is sixteen
  223. (hexadecimal).  Please refer to the documentation on how to
  224. change the default base and use numbers in other bases.
  225. White space, which is not a part of a literal string, is not
  226. significant in szadb requests as long as a total number of
  227. characters in the command line is below an input buffer length
  228. (78 for this version).  <Return> always terminates a current
  229. line.  Try adding some blanks and tabs to previously typed
  230. commands.
  231.  
  232.  
  233.  
  234. 2.3   Disassembling
  235.  
  236.  
  237. Lets try something more exciting.  A request for printing
  238. machine language instructons is /i.  It may be preceded by a
  239. count.  Try ,4/i.  The comma is necessary and informs szadb
  240. that what follows is a number of times to repeat the request.
  241. If you will omit it then the debugger will decide that you
  242. want to start with a location 4.  If all is well then szadb
  243. will respond
  244.  
  245.       __start:
  246.                            move.l   sp,a5
  247.                            move.l   4(sp),a4
  248.                            move.l   a4,__base
  249.                            move.l   8(a4),d3
  250.  
  251.  
  252.  
  253.  After this request a default command becomes /i.  Therefore
  254. to see the next four locations it is enough to type ,4 and
  255. szadb will show
  256.  
  257.       > ,4
  258.       __start+10:
  259.                            add.l    c(a4),d3
  260.  
  261.  
  262.  
  263.                                  4
  264.  
  265.  
  266.  
  267.  
  268.                            move.l   d3,_etext
  269.                            move.l   10(a4),d3
  270.                            add.l    14(a4),d3
  271.  
  272.  
  273.  
  274. Note that the "dot" has moved.  This is a common feature of
  275. all memory examining requests.  The "dot" will be set past
  276. all already scanned memory.  If you want to look at the same
  277. memory area one more time, possibly using a different request,
  278. use & to reset your position.  It is a shorthand for the last
  279. typed in address.
  280.  
  281.  
  282.  
  283. 2.4   More on talking to szadb
  284.  
  285.  
  286. A general szadb command has a form
  287.  
  288.  
  289.      address ,count request_with_its_modifiers
  290.  
  291.  
  292. where each of three parts is optional or possibly not used.
  293. Please refer to the documentation to see all available
  294. requests.  For all practical purposes count 1 means forever.
  295. Read a little bit further before trying this.
  296. Display format modifiers can be concatenated together.  For
  297. example, the following
  298.  
  299.  
  300.      main,9/ai
  301.  
  302.  
  303. will print the first nine instructions, labelled by their
  304. addresses, starting from _main.  Like this:
  305.  
  306.       _main:               link      a6,#-6
  307.       _main+4:             movem.l  [d3-5],-(sp)
  308.       _main+8:             move.l   #_tabs,-(sp)
  309.       _main+e:             bsr       _settab
  310.       _main+12:            addq.w   #4,sp
  311.       _main+14:            clr.w    d5
  312.       _main+16:            clr.w    d3
  313.       _main+18:            move.l   #__iob,-(sp)
  314.       _main+1e:            jsr       _fgetc
  315.  
  316.  Note that the leading underscore, required to produce an
  317. internal form of a symbol main was prepended automatically.
  318.  
  319.  
  320.  
  321.                                  5
  322.  
  323.  
  324.  
  325.  
  326. To get to an address of __main, if such symbol in your program
  327. exists, you have to type its name in full.  Similar but
  328. slightly different rules will be in force if your program has
  329. a symbol table in the MWC format.
  330. If you do not know which symbols are available issue a request
  331. $e.  A display similar to the following will start to scroll
  332. accross your screen.
  333.  
  334.       > $e
  335.       __start: 77812
  336.       __exit: 778da
  337.       _gemdos: 778e2
  338.       _bios: 778ec
  339.       _xbios: 778f6
  340.       _bdos: 77900
  341.       _main: 77954
  342.       _settab: 77a72
  343.       __main: 77aac
  344.       _exit: 77b0c
  345.       ................
  346.  
  347. The general method to stop a scrolling screen for a moment is
  348. to use <^S> and any other key will continue.  A <^C> will
  349. cancel the command and any further output.  Starting with
  350. version 1.4 this includes also a paging.  This means that
  351. display stops after showing one screenful of symbols and szadb
  352. waits for your keyboard input.  Keys <q>, <Q> and <^C> break,
  353. any other key continues.  A processing of the request is
  354. finished when you will get back a standard szadb prompt of "> ".
  355.  
  356. Some hexadecimal numbers may look like symbols.  For example,
  357. if you happen to have a symbol abba in your program then szadb
  358. will understand main+abba as a request for setting the "dot"
  359. to an address which is a sum of addresses of main and abba,
  360. even if you really meant an adress at offset of 0xabba from
  361. main.  To avoid this misinterpretation it is enough to type
  362. main+0abba --- a number has a leading zero.  It the symbol
  363. abba is not defined then the ambiguity does not arise.
  364. Assuming that the default base is sixteen abba will be taken
  365. as a number.  Otherwise such expression will be not accepted
  366.  
  367.  
  368.  
  369.                                  6
  370.  
  371.  
  372.  
  373.  
  374. and you will see only an error message.  The form 0xabba has a
  375. unique meaning and always works.
  376.  
  377.  
  378.  
  379. 3   Running under szadb
  380.  
  381.  
  382. 3.1   How to run | with arguments
  383.  
  384.  
  385. To run a loaded program, with a name passed as a szadb
  386. argument, one has to type :c, which is a short for :continue.
  387. When the program is running szadb switches to the program
  388. screen which is different from that one used by the debugger.
  389. In particular, all program keyboard input will be accepted
  390. from the program screen.  Unfortunately there is no way, at
  391. least not in this version, to read the debugged program
  392. standard input from a file.  It has to be typed in.  To switch
  393. from the szadb screen the program window use <^W> and return
  394. from the visit with any other character.
  395. The program itself may have arguments.  In principle there are
  396. two methods with which they can be set.  Firstly, you may
  397. specify them when starting szadb.  Everything which follows
  398. the name of a loaded executable will be taken as its arguments
  399. and copied verbatim to its basepage.  A request $p will
  400. display the whole basepage and it will allow you to check if
  401. you really got what you expected.  szadb does not allow for
  402. any argument extending schemes and it will trunctate command
  403. lines which are too long.
  404. The second method allows you to specify arguments as an
  405. optional tail of :c request.  Once arguments were set, by any
  406. of these methods, they cannot be changed and further attempts
  407. to do so will be ignored.
  408. Since both shell command lines and the input line inside of
  409. szadb are limited in length, and partially already taken, it
  410. may appear that there is no way to fill all available basepage
  411. space with program arguments by any method, short of writing
  412. directly to a computer memory.  As we will see later this is
  413. not true, even if it requires a little bit of trickery.  (See
  414. further descriptions how to define and execute function keys.)
  415. When you are ready to quit, because you are done or lost and
  416. wish to start afresh, enter $q.  If the debugee process exited
  417. of its own accord then szadb will terminate too.
  418.  
  419.  
  420.  
  421.                                  7
  422.  
  423.  
  424.  
  425.  
  426. 3.2   Setting breakpoints
  427.  
  428.  
  429. Executing a program under a debugger is of no great use
  430. without breakpoints.  Here is the simplest way in which they
  431. can be set.
  432.  
  433.  
  434.      main:b
  435.  
  436.  
  437. We can do even better than that.  Try
  438.  
  439.  
  440.      main:b ="My first szadb breakpoint"n;.=XD;,8/ai
  441.  
  442.  
  443. Everything which follows :b on the input line will be stored
  444. and executed later on when the breakpoint is hit.  Multiple
  445. commands are separated by semicolons.  By the way, you may use
  446. semi-colons for immediate requests too.
  447. Breakpoints also can have counts.  Using as an example
  448. unexpand.tos, and a fragment of its disassembled code shown in
  449. a previous section, we may set a breakpoint
  450.  
  451.  
  452.      main+18,3:b="about to read"n
  453.  
  454.  
  455. in a main loop of this program, just before fgetc() is called.
  456. With this count an execution will stop only for every third
  457. character to be accepted.
  458. Setting a breakpoint on the top of an existing one is allowed
  459. and it will simply cause a replacement --- changing possibly a
  460. count and commands to execute.  A list of all current
  461. breakpoints, with their counts and associated commands, is
  462. produced by the $b request.  Information shown at the bottom
  463. of this list will be explained later.
  464. It is not the best idea to set a breakpoint somewhere between
  465. two program instructions.  Nothing terrible will happen
  466. immediately, but your debugging run may end up prematurely
  467. amid an utter confusion.  Sometimes it is possible to restart
  468. a wayward program by writing a needed address directly into a
  469. program counter with a address>pc request, but this is not
  470. guaranteed to work.  It is also advisable to keep breakpoints
  471. on an execution path.  They are a limited resource and there
  472. is no point wasting it.
  473.  
  474.  
  475.  
  476.  
  477.  
  478.                                  8
  479.  
  480.  
  481.  
  482.  
  483. 3.3   Displaying information
  484.  
  485.  
  486. szadb provides many ways to display information about the
  487. state of your program.  Some of these requests were detailed
  488. above.  Another is $r, which will show the contents of all
  489. registers and status flags.  If you are interested in an
  490. individual register then use something like
  491.  
  492.  
  493.      <a0=X
  494.  
  495.  
  496. Replacing above = with /, or ?, will bring a hexadecimal
  497. display of the long word stored at the location pointed to by
  498. register a0.  Careful here, the last form will move the
  499. "dot".  There are many other possible formats.  Try, for
  500. example, main,20/x  and <b,2/s .
  501. The second example uses one of four read-only variables
  502. provided by szadb, which are
  503.  
  504.  
  505.      l        lowest text address
  506.      t        length of the text segment
  507.      b        start of the bbs segment
  508.      d        length of the data segment
  509.  
  510.  
  511. With an exception of l names follow the Unix convention.  They
  512. will be particulary handy if you will have a misfortune of
  513. debugging executable without a symbol table.
  514. Formats in requests can be combined.  Let us try something
  515. like follows.
  516.  
  517.  
  518.      ="Text memory dump"2n;main,<b-main%8+1/4x4^rr|rr8cn
  519.  
  520.  
  521. and here are initial lines of a resulting display, where "."
  522. replaces all non-printable characters.
  523.  
  524.       Text memory dump
  525.  
  526.  
  527.       _main:
  528.              4e56       fffa       48e7       1c00  |  NV..H...
  529.              2f3c          6       8ae6       6100  |  /<....a.
  530.               10e       584f       4245       4243  |  ..XOBEBC
  531.              2f3c          6       88a0       4eb9  |  /<....N.
  532.                 6       7c40       584f       3800  |  ..|@XO8.
  533.  
  534.  
  535.  
  536.                                  9
  537.  
  538.  
  539.  
  540.  
  541.              b87c       ffff       6706       b87c  |  .|..g..|
  542.                 4       6612       4267       4eb9  |  ..f.BgN.
  543.                 6       77d6       544f       4cdf  |  ..w.TOL.
  544.  
  545.  
  546.  
  547.  Note that division is denoted by a % character and that 8
  548. divides a difference <b-main and not only main, since all
  549. expressions are evaluated in strict left-to-right order.
  550. Let's break down the format modifiers to see what is actually
  551. happening
  552.  
  553.  
  554.      4x        print four short words in hex,
  555.      4^        backup the "dot" by four current fields
  556.      (short words),
  557.      rr|rr     print 2 blanks, vertical bar, and 2 more
  558.      blanks,
  559.      8c        print 8 characters,
  560.      n         and a newline.
  561.  
  562.  
  563. Displays that are wider then a current screen width (40 or 80)
  564. will have lines split automatically.
  565.  
  566.  
  567.  
  568. 3.4   Recording your session
  569.  
  570.  
  571. A request $>filename starts writing a transcript of everything
  572. which shows on your screen to the file filename.  All examples
  573. longer than a couple of lines were prepared this way.  If the
  574. filename is missing then the currently opened transcript will
  575. be closed.  The output is always appended to the given file,
  576. so that it is possible to open, close, and re-open the same
  577. file any number of times.
  578. Because GEMDOS is not re-entrant it is not a very very good
  579. idea to perform an actual file write while processing a GEMDOS
  580. call.  It is nearly certain you will crash your system.  The
  581. safest course in such spots is to turn recording temporarily
  582. off.  However, transcript output is buffered by default, so
  583. actual writes occur only when the buffer is flushed when full
  584. or because the file was closed.  Therefore with proper care,
  585. one can empty the buffer prior to dangerous spots and even
  586. create a record of a GEMDOS call, provided it is not too
  587.  
  588.  
  589.  
  590.                                 10
  591.  
  592.  
  593.  
  594.  
  595. wordy.  A handy definition for a function key to do this is
  596. $>;$> (see the last section on function keys).
  597. It is advisable not to write files to your hard drive, instead
  598. use a RAM drive or a dedicated floppy (which can be
  599. reformatted in case of disaster).  Remember that a buggy
  600. program and the debugger can write anywhere.  Over system file
  601. buffers and cached File Allocation Tables as well.
  602. If you need all memory you can get it is possible to turn off
  603. transcript buffering with command line option -nb.  But then
  604. you will have to be extremely careful about possible conflicts
  605. with GEMDOS.
  606. Note!  After $>file request your default command is $> and not
  607. the last command you were executing previously.  It is
  608. possible to execute $> inadvertently by hitting <Return> or by
  609. making some mistake while typing the next line.  This will
  610. close your transcript with obvious results.  When something
  611. like thats happens, or when in doubt, issue another $>file.
  612.  
  613.  
  614.  
  615. 4   Bug hunting
  616.  
  617.  
  618. 4.1   Compiling for szadb
  619.  
  620.  
  621. Lets have a closer look at the C program below.  Its stated
  622. purpose is to replace, if possible, runs of white space with
  623. tabs.  The width of a tab is fixed and equal to a constant
  624. TABSTOP. If a text line is getting too long then substitutions
  625. are abandoned and remaining characters are copied without
  626. modifications.
  627.  
  628.  
  629.       #include <stdio.h>
  630.  
  631.  
  632.       #define MAXLIN 132
  633.       #define TABSTOP 8
  634. 5
  635.       int                 tabs[MAXLIN];
  636.  
  637.  
  638.       main ()
  639.       {
  640. 10       int             c, delay, col;
  641.  
  642.  
  643.  
  644.                                 11
  645.  
  646.  
  647.  
  648.  
  649.        void            settab ();
  650.  
  651.  
  652.        settab (tabs);
  653.  
  654.  
  655. 15     col = delay = 0;
  656.        while (EOF != (c = getchar ())) {
  657.             if (MAXLIN < col) {
  658.                 /* copy remaining characters on a line */
  659.                 do {
  660. 20                  putchar (c);
  661.                 } while ('\n' != c &&
  662.                                 EOF != (c = getchar ()));
  663.                 col = 0;
  664.             }
  665. 25          else {
  666.                 switch (c) {
  667.                 case '\t':
  668.                     while (!tabs[col])
  669.                         col++;
  670. 30              case ' ':            /* fallthrough */
  671.                     if (!tabs[col]) {
  672.                         col += 1;
  673.                         continue;   /* keep delay */
  674.                     }
  675. 35                  putchar ((delay == col) ? ' ' : '\t');
  676.                     col += 1;
  677.                     break;
  678.                 default:
  679.                     while (delay < col) {
  680. 40                      putchar (' ');
  681.                         delay += 1;
  682.                     }
  683.                     putchar (c);
  684.                     col = ('\n' == c ? 0 : col + 1);
  685. 45                  break;
  686.                 } /* switch */
  687.             } /* if (MAXLIN < col) */
  688.             delay = col;
  689.        }
  690.  
  691.  
  692.  
  693.                              12
  694.  
  695.  
  696.  
  697.  
  698. 50        exit (0);
  699.       }
  700.  
  701.  
  702.       void
  703.       settab (tab_pt)
  704. 55    short            *tab_pt;
  705.       {
  706.           int              i;
  707.  
  708.  
  709.           for (i = 0; i < MAXLIN; i++) {
  710. 60             *tab_pt++ = (0 == (i % TABSTOP));
  711.           }
  712.       }
  713.  
  714.  
  715. This program has actually two bugs.  See if you can find them
  716. just examinig the source.
  717. Here is how szadb can help.  Compile source as follows (these
  718. commands are for Sozobon C)
  719.  
  720.  
  721.      cc -t -O -o unexpand.tos unexpand.c
  722.  
  723.  
  724. Flag -O is not necessary but with this particular compiler you
  725. will probably find a disassembled code easier to follow.  You
  726. may test the compiled executable on its own source.
  727.  
  728.  
  729.      unexpand.tos <unexpand.c >output
  730.  
  731.  
  732. In the first moment the program appears to work, but a closer
  733. examination of the output reveals that the indentation is not
  734. exactly right.  Moreover, some lines start with a blank,
  735. followed by a tab, which is not really what was intended.
  736. There are also other problems.  Check yourself.  The likely
  737. suspect will be an array tabs of tabstops filled by a function
  738. settab().
  739.  
  740.  
  741.  
  742. 4.2   The first bug
  743.  
  744.  
  745. Start the program under szadb control
  746.  
  747.  
  748.      adb.ttp unexpand.tos
  749.  
  750.  
  751.  
  752.                                 13
  753.  
  754.  
  755.  
  756.  
  757. and set a breakpoint at settab+4, just after link instruction.
  758. Run the program with :c ; $C. This will produce the following
  759. display
  760.  
  761.       break at _settab+4
  762.       _settab+4:           movem.l  [d3-4],-(sp)
  763.       _settab+4(0006,8bb4)
  764.       _main+12(0001,0006,8cbe,0006,73a2)
  765.       __main+4e(? at 69cc6)
  766.  
  767.  In the absence of better information all arguments shown in
  768. the stack backtrace are assumed to be two bytes wide.  We know
  769. from the source that settab() actualy expects one pointer.
  770. Confirm that it got a right one by putting it together from
  771. two halfs and using the request 68bb4=p to print it as the
  772. symbol.  You should see _tabs in response.  To continue
  773. execution of the current function till it returns to its
  774. caller, use :f which stands for :finish.
  775. It is clear from lines 30 and 35 that the first tabstop in
  776. _tabs is expected to be on a position TABSTOP - 1 .  Dumping
  777. some initial fragment of the just initialized array we see the
  778. following:
  779.  
  780.       > tabs,3/4x
  781.       _tabs:
  782.                 1          0          0          0
  783.                 0          0          0          0
  784.                 1          0          0          0
  785.  
  786.  This is clearly wrong and one bug becomes obvious.  To repair
  787. it line 59 should be changed to
  788.  
  789.  
  790.      for (i = 1; i <= MAXLIN; i++) {...}
  791.  
  792.  
  793.  
  794. 4.3   ...and the other one
  795.  
  796.  
  797. The second bug is harder to spot, since for most of test
  798. inputs our program will work correctly.  This is a typical
  799. example of a program broken for boundary conditions.  To make
  800. it easier to track the problem set MAXLIN to some small
  801. integer (around 10 should be good), recompile the program,
  802. restart the debugging session and set a breakpoint at main+28,
  803.  
  804.  
  805.  
  806.                                 14
  807.  
  808.  
  809.  
  810.  
  811. just after a character was read.  Set this breakpoint with a
  812. count and a request to show a received character with
  813.  
  814.  
  815.      main+28,5:b <d0=cx
  816.  
  817.  
  818. With carefuly chosen input this will show where you are in the
  819. program and will skip unnecessary stops in the same time.  You
  820. have to provide an input by typing it yourself.  Remember that
  821. to repeat the last command :c it is enough to hit <Return>.
  822. For execution defaults szadb will use the most recently typed
  823. command even if some other requests were executed by
  824. breakpoints.
  825. In order to see how the received character is processed you
  826. can single step with :s, which will follow program execution.
  827. The request :n will single step like :s but will execute
  828. function calls at full speed and so have the effect of
  829. stepping over them.  Breakpoints set on skipped levels still
  830. will be obeyed.
  831. Tracing some tests inputs with the value of the variable col
  832. around MAXLIN should reveal the second error soon enough.  If
  833. you want to try it yourself, do not read further.
  834. Looking at line 17 we find a sharp less-than inequality in the
  835. test.  It should be replaced by a less-than-equal-to.
  836. Otherwise, when the value of col equals MAXLIN, and your input
  837. is "right", the program is trying to read, in lines 28 and 31,
  838. from the location &tabs[col], which is one past the end of the
  839. array.  The remaining analysis of this bug is left as an
  840. exercise to the reader.
  841.  
  842.  
  843.  
  844. 4.4   Breaking out
  845.  
  846.  
  847. Another stepping command is the :j jump request.  Its purpose
  848. it to short-circuit loops.  It behaves exactly like :n in that
  849. it skips-over function calls but unlike the :n request which
  850. follows branch instructions, the :j will place a temporary
  851. breakpoint at the instruction immediately following the
  852. current instruction in memory.  Think of :n as
  853. step-next-logical instruction and :j as step-next-physical
  854. instruction.  The idea is that you only use :j to step-out of
  855. loops where you are sitting on the loop-back branch.
  856.  
  857.  
  858.  
  859.                                 15
  860.  
  861.  
  862.  
  863.  
  864.               ...
  865.               bra      .test
  866.       .body:
  867.               ...
  868.       .test:
  869.               cmp      d0, d1
  870.               bnz      .body
  871.       .end
  872.               ...
  873.  
  874.  In the example above, if you are sitting on the bnz
  875. instruction and you wish to execute the remainder of the loop
  876. at full speed then you use the :j, which places a temporary
  877. breakpoint at the location .end.  However care must be taken
  878. when using this command because it is possible that the
  879. flow-of-control never reaches the temporary breakpoint.
  880.  
  881.                ...
  882.                bra      .snert
  883.       .never:
  884.                ...                ; might be local data here
  885.       .snert:
  886.                rts
  887.  
  888.  This is a case where NOT to use the :j command.  Basically to
  889. use the :j request you should know how your C compiler sets up
  890. its loops or where your assembler code is meant to go.  It is
  891. sometime a good idea to put a safety breakpoint somewhere you
  892. know you will end up.
  893. Because of the unusual nature of the :j request, it will not
  894. autorepeat if the next command is just a <Return> key.  Instead
  895. :n is performed.  Also it is also considered a variant of :n
  896. when attaching execution requests to stepping commands (see
  897. further down).
  898. It should be also mentioned that all stepping commands have
  899. upper case counterparts, which are noisier.  When used they
  900. return the a full register display after the step (:S is like
  901. doing :s;$r).
  902.  
  903.  
  904.  
  905.                                 16
  906.  
  907.  
  908.  
  909.  
  910. 5   More fun and games
  911.  
  912.  
  913. This section covers some finer points of szadb use.  You may
  914. put them aside when just starting first experiments with the
  915. debugger.  But probably one day you will find some of that
  916. information very useful.
  917.  
  918.  
  919.  
  920. 5.1   Advanced steps
  921.  
  922.  
  923. It was already mentioned that all stepping commands may have
  924. also attached szadb requests.  As a matter of fact there is
  925. even one default, for :f.  To get a similar effect for other
  926. steps just type what you want to be executed after a given
  927. command on the szadb input line.  For example
  928.  
  929.  
  930.      :s ="this string printed by :s command"n
  931.  
  932.  
  933. You will notice that this form of :step does not move you
  934. ahead in the program.  This gives an opportunity to set and
  935. modify requests in advance, without an immediate execution.
  936. It also saves your nerves if you are not a very good typist.
  937. To really step by one instruction forward hit <Return> and
  938. observe what will happen.  As noted before :j is a variant of
  939. :n and setting request for it will really change what is
  940. attached to :n.
  941. The example above is not tremendously useful, but tracking
  942. values of a chosen registers can be.  Or anything else that
  943. you need and that will fit on the command line.  This
  944. condition is much less limiting than it appears when used in
  945. conjunction with function keys.
  946. There are two points to remember.  There is no syntax check
  947. while you are setting requests.  Watch what you are typing if
  948. you do not want to see only error messages.  And there is
  949. nothing to prevent a direct or indirect recursion.  Since a
  950. depth of szadb stack is limited and <^C> does not always work
  951. it is better to avoid such constructs.
  952. If you came to a conclusion that the only way to change
  953. requests attached to a stepping command is to overtype them
  954. with something else then you are correct.  Moreover an empty
  955. string is not a good replacement since it causes an execution.
  956.  
  957.  
  958.  
  959.                                 17
  960.  
  961.  
  962.  
  963.  
  964. Luckily there is some other way to turn a noise off.  Try
  965. typing ::s- and similar commands for :n and :f.  Switched off
  966. requests are not gone, unless later redefined.  They can be
  967. brought back by a similar command as above in which - was
  968. replaced with +.  The default request for :f is special.  It
  969. cannot be overtyped or turned on by ::f+.  To bring it back
  970. use ::f` instead.
  971. There is one more way of request switching.  If you will type,
  972. for example, ::n_, then whatever was attached to :s will be
  973. performed also for :n, instead of a "native" command.  This
  974. gives an opportunity to create, say, a quite complicated
  975. request for :n and most of the time execute a simpler request
  976. for :s.  When an original request for :n is needed it is
  977. enough to type ::n+ to get it back.  The same mechanism works
  978. for :f, temporarily redirecting its requests "down" to the
  979. first active one.  There is no similar switching going the
  980. other way.  To gain a better understanding try all of this
  981. after defining various requests for each of stepping commands
  982. and examine effects with the $b command after every switch.
  983. It is also possible to make user breakpoint silent or not.
  984. For example
  985.  
  986.      main:b ="entering main"
  987.  
  988. main::b- and main::b+ turns the action off and on.
  989.  
  990.  
  991.  
  992. 5.2   How to use function keys
  993.  
  994.  
  995. Function keys can be defined, only once per debugging session,
  996. by reading their definitions from a file.  The name of the
  997. file can be passed on the command line with -k filename.  The
  998. file may be as simple as this
  999.  
  1000.       # flush buffers of a transcript file record
  1001.       F1 $>;$>record
  1002.  
  1003.  
  1004.       F2 ="this is pretty long string which will be ins\
  1005.       erted when you will hit function key F2"n;
  1006.       F1 ="an attempt to redefine F1\n"
  1007.  
  1008.  Note that an uppercase F, which starts key definition, has to
  1009. be in the first column and it has to be immediately followed
  1010.  
  1011.  
  1012.  
  1013.                                 18
  1014.  
  1015.  
  1016.  
  1017.  
  1018. by a valid key number.  Shifed functions keys have numbers
  1019. between 11 and 20.  A definition of <F2> is continued on the
  1020. next line since a terminating newline is escaped with a \
  1021. character.  Otherwise this continuation line would be simply
  1022. ignored.  szadb also does not pay any attention to the second
  1023. definition of <F1>.  To see a list of all function keys defined
  1024. type $k.
  1025. Defined function keys can be used in two ways.  Just hitting a
  1026. function key will insert into the current input line as many
  1027. characters from a corresponding string as it will fit.  The
  1028. resulting input text can be edited.  In order to execute a
  1029. full definition use $k followed by a key number --- always in
  1030. decimal.  For example, a request $k2 will print twice the
  1031. message, which was just defined in the function key file.
  1032. Note that there no way to specify that a function key should
  1033. execute immediately instead of waiting for a <Return>.  Also is
  1034. there no default function key file name like --- adb.key ---
  1035. so you'll have to specify the -k file option on the command line
  1036. each time or use a command alias.  Note also that requests of
  1037. a form $k<number> do not autorepeat.
  1038. It is clear that strings of commands attached to function keys
  1039. can be longer than a lenght of the input line.  Actually
  1040. around 2K will be accepted.  This is hopefuly longer than any
  1041. szadb script you ever want to write.  Especially if you take
  1042. into account that one script can call another.  Warnings
  1043. against recursion apply as well.
  1044. Such long scripts can be, of course, attached to breakpoints
  1045. or stepping commands.  They give also, previously mentioned,
  1046. opportunity to fill all available space on a base page with
  1047. command line arguments.  Just define one of function keys as
  1048.  
  1049.  
  1050.      :c <text to put on a base page>
  1051.  
  1052.  
  1053. and execute at the beggining of your session.  Coupled with a
  1054. possibility of directly modifying the memory this allows for a
  1055. preparation of scripts which will emulate any extended
  1056. arguments scheme, even if szadb directly does not support
  1057. directly any of these.
  1058.  
  1059.  
  1060.  
  1061.                                 19
  1062.  
  1063.  
  1064.  
  1065.  
  1066. 5.3   Other symbol table formats
  1067.  
  1068.  
  1069. This debugger was designed as a companion for Sozobon C and
  1070. therefore it understands its symbol table format, which was
  1071. inherited from Alcyon compiler.  The version for which this
  1072. document was written also supports MWC --- currently the
  1073. official Atari development compiler.  It will cooperate also
  1074. with the ST version of GNU compiler gcc.  If you happen to
  1075. have an older version of gcc loader it may be necessary for
  1076. you to get your hands dirty in a source code.  Even better
  1077. idea would be to update your compiler.  The current gcc loader
  1078. can optionally produce symbol tables in "GST format" where
  1079. symbols can be up to twenty two characters long.  Version 1.3
  1080. of szadb will correctly recognize and use that format as well.
  1081.  
  1082.  
  1083.  
  1084. 5.3.1  Mark Williams C support
  1085.  
  1086.  
  1087. Symbols created by MWC are outwardly different from those
  1088. produced by Sozobon C in that that names can be longer --- up
  1089. to sixteen characters --- and an underscore character is
  1090. appended instead of beeing prepended.  When szadb will detect
  1091. an MWC produced object it will apply its conventions.  That
  1092. means that if you type main it will first try to find a symbol
  1093. main.  If this fails it will search for main_ next (not for
  1094. _main).  If a symbol name has a leading underscore, or more
  1095. than one trailing, you have to type them yourself.
  1096. The debugger is trying to guess by itself which compiler
  1097. produced the current executable.  If it guesses wrong you may
  1098. always override its choice by dropping a hint on the command
  1099. line.  It consists of an -os flag for the Sozobon format and
  1100. -om for MWC. Remember that if you work in an assembler the
  1101. guessing code can always be fooled.  The flags always provide
  1102. a way to set things straight.
  1103. When writing this guessing code I had no official description
  1104. of the format used by MWC. All necessary information was
  1105. inferred from an examination of MWC produced binaries.  The
  1106. code worked so far on everything I tried, but it may happen to
  1107. be wrong for your version.  Since szadb comes complete with
  1108. source you can modify it accordingly and recompile (look for
  1109.  
  1110.  
  1111.  
  1112.                                 20
  1113.  
  1114.  
  1115.  
  1116.  
  1117. all places where a global variable swidth is modified).
  1118.  
  1119.  
  1120.  
  1121. 5.3.2  How to work with gcc
  1122.  
  1123.  
  1124. A default form of executables created by this compiler is with
  1125. a symbol table attached.  You need to use -s flag if you
  1126. really do not want it produced.  A default format for TOS
  1127. version of this compiler is basically the same as for Sozobon
  1128. C or Alcyon.  If you happen to be an owner of an old version
  1129. there is one subtle difference.  A bit which carries an
  1130. information that a symbol is global one, known as S_EXT in
  1131. szadb parlance, is not set.  This makes the debugger blind to
  1132. a symbol presence.
  1133. Here are instructions how to modify an old version of a file
  1134. ld.c which contains sources for gcc linker.  In a function
  1135. write_atari_sym(p, str) for TOS version add the following
  1136.  
  1137.  
  1138.       if (p->n_type & N_EXT)
  1139.               sym.a_type |= A_GLOBL;
  1140.  
  1141.  
  1142. just before a line which reads
  1143.  
  1144.  
  1145.       sym.a_value = p->n_value;
  1146.  
  1147.  
  1148. Recompile and reinstall linker and from this moment on szadb
  1149. recognizes gcc produced symbols.
  1150. Even better idea would be to upgrade your compiler to a newer
  1151. version.  The modification described above will be already
  1152. present, but there is more.  Currently gcc, upon a presence of
  1153. -G flag, may produce symbol tables with names up to twenty two
  1154. characters long.  Version 1.3 of szadb will correctly
  1155. recognize such symbols making for much nicer debugging (even
  1156. if this will require more typing from time to time).
  1157. Internally this is a version of Sozobon format.  Use -os flag
  1158. in case of confusion.
  1159. If for some reasons you cannot upgrade, you do not have linker
  1160. sources or you cannot recompile them --- because you do not
  1161. have enough memory, for example --- not everyting is lost.  It
  1162. is quite feasible to disable S_EXT check in setsym() (look in
  1163. the file adb1.c).  You will not notice any change for Sozobon
  1164. C created executables.  All symbols occuring in their symbol
  1165.  
  1166.  
  1167.  
  1168.                                 21
  1169.  
  1170.  
  1171.  
  1172.  
  1173. tables are actually always global.  This is not quite true for
  1174. gcc and some new, sometimes strange, symbols will appear but
  1175. usually this will not create any problems.  In order to have
  1176. only globals in a gcc produced symbol table pass -x flag
  1177. either to gcc or to its linker.
  1178.  
  1179.  
  1180.  
  1181. 5.3.3  Command line interpretation
  1182.  
  1183.  
  1184. As mentioned before szadb supports only "vanilla" command
  1185. line without any extension schemes.  Other compilers, like
  1186. gcc, may expect something different and there could be some
  1187. disagreements about an interpretation of a command line.
  1188. Usually this can be fixed quite easily.  Here is a file, named
  1189. fixargs.adb, which can be used with a command line following
  1190. this pattern
  1191.  
  1192.  
  1193.       szadb.ttp -k fixargs.adb <program> [argument, ...]
  1194.  
  1195.  
  1196. where <program> was compiled by gcc.
  1197.  
  1198.       # an example of a function keys definition file used
  1199.       # to correct an argument interpretation for gcc
  1200.       # compiled program
  1201.       F1  $k11; $k13 ; $k14; $k15; $b; :c
  1202.       F11 main:b <sp,10/x; $k12
  1203.       F12 <sp/W *(<sp+4)-3; <sp+4/W *(<sp+8)+c; <sp,10/x
  1204.       # for 16 bit
  1205.       #F12 <sp/w *(<sp+2)-3; <sp+2/W *(<sp+6)+c; <sp,10/x
  1206.       F13 getitime:b
  1207.  
  1208.  This file defines some function keys.  The fact that commands
  1209. associated with keys <F14> and <F15> do not exist, even if they
  1210. are referenced in a line for <F1>, is not harmful in any way.
  1211. You may define these keys later for your advantage.  After
  1212. szadb started hit <F1> followed by <Return>.  This will cause,
  1213. among others, an execution of a command attached to <F11>, i.e
  1214. <F1-shifted>.  This command will set a breakpoint at a start of
  1215. real program with a fixup command attached.  In turn, this
  1216. will modify your stack causing your program to see proper
  1217. arguments.  Requests in a form of <sp,10/x are added only for
  1218. reassurance and to show what really happens.
  1219.  
  1220.  
  1221.  
  1222.                                 22
  1223.  
  1224.  
  1225.  
  1226.  
  1227. The example above assumes that a symbol getitime is defined in
  1228. your program.  Replace with something which is really present
  1229. or you will see some error messages.  They are not fatal.  All
  1230. of this is not going to work if main is not present in your
  1231. symbol table.  This is not really likely for a program which
  1232. has a symbol table and was compiled from C sources, but may
  1233. happen for other languages.  Modify accordingly.
  1234.  
  1235.  
  1236.  
  1237. 5.3.4  Other compilers
  1238.  
  1239.  
  1240. If you own a compiler which produces symbolic information in
  1241. an unsupported format you can modify szadb yourself to support
  1242. it.  For a model of how to do this look for setsym() and
  1243. mwsetsym() in the file adb1.c.  Both of them call addsym()
  1244. which performs an actual insertion of a new symbol and its
  1245. value into a linked list of supported symbols.  A current
  1246. version of addsym() will handle symbol names of any length but
  1247. internally they will be chopped off to something not longer
  1248. than the current value of the global variable swidth.  Ensure
  1249. that this value is set properly for your needs.
  1250. The mechanism above can be easily extended to allow reading
  1251. some symbols and their values from a user suplied text file.
  1252. Some may find it very handy.  The current version of szadb
  1253. does not support this feature.  It is possible to roll your
  1254. own if you really need it.
  1255.  
  1256.  
  1257.  
  1258. 5.3.5  Screens of not a standard ST size
  1259.  
  1260.  
  1261. Starting with a version 1.4 szadb does not have standard ST
  1262. screen parameters embedded into its code.  Instead it reads
  1263. all necessary information from line-A variables and reserves
  1264. all needed buffers accordingly.  In particular it follows that
  1265. szadb will run correctly in all six TT resolutions.  It may
  1266. also work with different overscan utilities, provided screen
  1267. geometry variables in a machine were updated properly.  Note
  1268. that fonts used are resolution dependent but fixed for a given
  1269. resolution.  This means that putting monochrome ST into 50
  1270. line mode will not give nice results without code
  1271. modifications (see w_init() in window.c).
  1272.  
  1273.  
  1274.  
  1275.                                 23
  1276.  
  1277.  
  1278.  
  1279.  
  1280. A special support is provided for Moniterm monitors.  Because
  1281. of limitations of a Moniterm driver you will need also a
  1282. standard ST monitor connected in parallel.  In such setup your
  1283. program screen will be displayed on Moniterm and szadb will
  1284. print its information to a side monitor; no screen flipping
  1285. with <^W> is needed or possible.
  1286. Since the debugger tries to limit use of a dynamic memory
  1287. allocations the code which reserves szadb work screen and
  1288. necessary buffers does that in a "false" program space and
  1289. is located in start.s.  Should you decide to modify it for any
  1290. reasons look for comments which attempt to describe what
  1291. really happens.
  1292. Note:  despite of the fact that szadb can be used on TT the
  1293. version 1.4 is still ST debugger in that sense that it does not
  1294. support yet any of 68020/30 specific codes.  This should be
  1295. fine for most programs in the nearest future.  An expansion
  1296. will be easy and straightforward provided you will have
  1297. necessary reference handy.
  1298.  
  1299.  
  1300.  
  1301. 5.4   Customization
  1302.  
  1303.  
  1304. Some possible customizations were already mentioned.  The
  1305. other obvious one is a version of szadb without on-line help.
  1306. If you feel brave enough remove the definition of the compile
  1307. time constant HELP from the makefile.  A size of the
  1308. executables will undoubtely go down.
  1309. In order to create a version in some other language edit a
  1310. file lang.h.  It contains all messages which szadb may
  1311. display.
  1312. You can adjust to your taste some other points.  For example,
  1313. what are default requests attached to stepping commands and
  1314. what is their status (look in stepping.c for bpstat(),
  1315. findcmds(), bpt_list[]).  Which characters are used for
  1316. requests switching (see getrequs() in pcs.c).  Some features,
  1317. like support for functions keys or other symbol table formats,
  1318. can be taken out easily without affecting the whole design.
  1319. If you try to recreate szadb with another compiler you should
  1320. note that essential parts of this program were written in
  1321. assembler and may have to be translated to something your
  1322.  
  1323.  
  1324.  
  1325.                                 24
  1326.  
  1327.  
  1328.  
  1329.  
  1330. tools can accept.  Here is another point to watch for.  A
  1331. variable _BLKSIZ sets size of Malloc'ed blocks.  If a library
  1332. you use supports something similar modify accordingly.  There
  1333. are also some constructs in C code, like a static
  1334. initialization of a union member (bpt_list in stepping.c) and
  1335. an array of size 0 in a definition of struct symbol in adb.h,
  1336. which are accepted by Szozobon C but can give a hiccup to some
  1337. other compilers.  These points can be modified without undue
  1338. strain.  Otherwise the code should be pretty portable,
  1339. although it is ST specific by its very nature.
  1340.  
  1341.  
  1342.  
  1343. 5.5   Running on a verge
  1344.  
  1345.  
  1346. You may find yourself in a situation when your program wants
  1347. all memory it can get and together with the debugger does not
  1348. exactly fits into available space.  There are still some
  1349. things which can be done.
  1350. Keep in mind that szadb grabs all memory it needs before a
  1351. program to debug is loaded and it does not make any claims
  1352. later.  These requirements can be minimized.  Function key
  1353. definitions if non-existent will not use memory at all,
  1354. discounting the supporting code.  This code by itself is
  1355. mostly contained in a file fkeydefs.c and it is easy to
  1356. remove.  The flag -nc, for no commands, gives some memory for
  1357. a price of missing breakpoint requests.  A more substantial
  1358. memory chunk can be released with -nb, for no buffering on
  1359. transcript, flag.  You still can open a transcript file but
  1360. all output will be direct.  Beware of GEMDOS when using
  1361. transcripts without buffering.
  1362.  
  1363. If this does not help then there is a time to trim some fat
  1364. from szadb itself.  You will have to recompile it leaving some
  1365. features out.  On-line help is probably the first candidate.
  1366. All this effort can be wasted if you will forget about one
  1367. thing.  Due to an infamous design bug in TOS a Malloc system
  1368. call can be invoked only a small fixed number of times.  When
  1369. this pool is exhausted you will get "out of memory condition"
  1370. even if memory is still plentiful.  Therefore all allocation
  1371. functions, from smart libraries, request a memory from
  1372. the system in bigger pieces and later try to satisfy all
  1373.  
  1374.  
  1375.  
  1376.                                 25
  1377.  
  1378.  
  1379.  
  1380.  
  1381. requests chopping from an already owned resource.  The name of
  1382. the game for szadb is to use for all its needs only one chunk
  1383. of a system memory which is just big enough, so not too much
  1384. of an unused memory will be left.  The whole symbol table of a
  1385. debugged program must fit there and all szadb requests for a
  1386. space for internal structures have to be statisfied.  To
  1387. adjust sizes properly you may want to change a constant CHUNK
  1388. which is defined at the top of a file adb.c.
  1389. If everything else fail you may still try to change a value of
  1390. a global variable __STKSIZ from start.s but this would be
  1391. probably the last stand.
  1392.  
  1393.  
  1394.  
  1395. 5.6   Writing to memory
  1396.  
  1397.  
  1398. It can be done.  This is left as an exercise to the reader.
  1399. Check your documentation.
  1400.  
  1401.  
  1402.  
  1403.                                 26
  1404.  
  1405.  
  1406.  
  1407.  
  1408. Contents
  1409.  
  1410.  
  1411. 1  Introduction                                                   1
  1412.  
  1413.  
  1414. 2  First steps                                                    2
  1415.    2.1  Starting   . . . . . . . . . . . . . . . . . . . . . . .  2
  1416.    2.2  Where am I?  . . . . . . . . . . . . . . . . . . . . . .  3
  1417.    2.3  Disassembling  . . . . . . . . . . . . . . . . . . . . .  4
  1418.    2.4  More on talking to szadb   . . . . . . . . . . . . . . .  5
  1419.  
  1420.  
  1421. 3  Running under szadb                                            7
  1422.    3.1  How to run --- with arguments  . . . . . . . . . . . . .  7
  1423.    3.2  Setting breakpoints  . . . . . . . . . . . . . . . . . .  8
  1424.    3.3  Displaying information . . . . . . . . . . . . . . . . .  9
  1425.    3.4  Recording your session . . . . . . . . . . . . . . . . . 10
  1426.  
  1427.  
  1428. 4  Bug hunting                                                   11
  1429.    4.1  Compiling for szadb  . . . . . . . . . . . . . . . . . . 11
  1430.    4.2  The first bug  . . . . . . . . . . . . . . . . . . . . . 13
  1431.    4.3  . .a.nd the other one  . . . . . . . . . . . . . . . . . 14
  1432.    4.4  Breaking out . . . . . . . . . . . . . . . . . . . . . . 15
  1433.  
  1434.  
  1435. 5  More fun and games                                            17
  1436.    5.1  Advanced steps . . . . . . . . . . . . . . . . . . . . . 17
  1437.    5.2  How to use function keys . . . . . . . . . . . . . . . . 18
  1438.    5.3  Other symbol table formats . . . . . . . . . . . . . . . 20
  1439.         5.3.1  Mark Williams C support . . . . . . . . . . . . . 20
  1440.         5.3.2  How to work with gcc  . . . . . . . . . . . . . . 21
  1441.         5.3.3  Command line interpretation . . . . . . . . . . . 22
  1442.         5.3.4  Other compilers . . . . . . . . . . . . . . . . . 23
  1443.         5.3.5  Screens of not a standard ST size . . . . . . . . 23
  1444.    5.4  Customization  . . . . . . . . . . . . . . . . . . . . . 24
  1445.    5.5  Running on a verge . . . . . . . . . . . . . . . . . . . 25
  1446.    5.6  Writing to memory  . . . . . . . . . . . . . . . . . . . 26
  1447.  
  1448.  
  1449.  
  1450.                                  i
  1451.