SBL(6)                                                     SBL(6)

     NAME
          sbl - symbol table file

     DESCRIPTION
          A Limbo symbol table file provides type information for the
          module in an associated Dis executable file, for use by
          debuggers and similar applications.  They are written by the
          Limbo compiler when given the -g option.  The files conven-
          tionally have a .sbl suffix; they need not be stored in the
          same directory as the corresponding Dis file.

          The file consists of a header followed by five tables:

               header file-table pc-table type-table fn-table data-
               table

          Each table starts with a line containing a decimal count of
          the items in that table.  The count can be zero. The follow-
          ing sections describe the format of table items in each
          table.  In the description, the following terminals are
          used.

          A string is a sequence of letters, digits, and the charac-
          ters _, ., -, and >. Letters are the Unicode characters a
          through z and A through Z, and all Unicode characters with
          encoded values greater than A0 hexadecimal.

          An int is an optional minus sign followed by a sequence of
          digits, 0 to 9.

          In the following description, the presence of a space is
          represented by • and a newline by \n.  There are no other
          spaces between syntactic elements in the file format.  Other
          special characters represent themselves.

        Header
          The header consists of two items.

               header:
                    magic\n
                    module\n
               magic:
                    limbo .sbl 2.0
               module:
                    string

          There have been two previous versions of symbol table for-
          mat, distinguished by the number in magic. Version 1. was
          the original; version 1.1 added more references back to the
          source; and version 2.0 replaced the original adt table by a

     Page 1                       Plan 9            (printed 12/21/24)

     SBL(6)                                                     SBL(6)

          type table and added support for Limbo's pick construction.
          Only version 2.0 is described here; the others are obsolete.

          Module is the name of the module implemented in the Dis
          file.  Symbol file references to identifiers declared by the
          implementation module are unqualified.  A name referenced
          that is imported from any other module is preceded by m->
          where m is that module's identifier.

        File table
          The file table is a list of file names referenced by the
          rest of the tables. Each file name is terminated by a new-
          line character; within the name, any character other than a
          newline is valid.

        PC table
          The PC table relates every instruction in the Dis file to
          the source from which it was compiled.  The table is indexed
          by Dis PC to obtain a reference to the corresponding source.
          Each item consists of a source description and a statement
          reference:

               pc-item:
                    src stmt \n
               src:
                    pos,pos•
               pos:
                    file:opt line.opt char
               file, line, char, stmt:
                    int

          A source description src selects source text as a range of
          characters within lines of a source file.  File is an index
          into the file table (origin 0); line and char are positions
          within that source file, with line numbers starting at 1 and
          character positions at 0. If file or line is omitted, it is
          assumed to have the previous value, or 0 if there is no pre-
          vious value.

          Stmt is the `statement number' of the instruction.  Despite
          its name, the scope of a statement number is smaller than a
          Limbo statement: it identifies a region marked by the com-
          piler for treatment as a unit when debugging.  For instance,
          in a for statement, the initial expression, increment, test,
          and body all have unique statement numbers.  All instruc-
          tions compiled from the same region in a Limbo program have
          the same statement number.  The number is that of the inner-
          most region that contains the instruction.

        Type table
          The type table describes the Limbo adts used in the Dis
          file, both locally declared and imported.  Each entry

     Page 2                       Plan 9            (printed 12/21/24)

     SBL(6)                                                     SBL(6)

          describes a type:

               type:
                    @ type-index \n
                    a adt-item
                    p adt-item tag-table
                    t size . id-table
                    m module \n src
                    A type
                    C type
                    L type
                    R type
                    n
                    N
                    B
                    b
                    i
                    f
                    s
               type-index:
                    int

          Each leading character specifies a different Limbo type:

               @    existing type referenced by type table index (not
                    self-referential)
               A    array of type
               a    adt without pick
               B    big
               b    byte
               C    chan of type
               f    real
               i    int
               L    list of type
               m    module
               N    nil's type
               n    no type (eg, function with no return type)
               p    adt with pick
               R    ref type
               s    string
               t    tuple

          A type-index is an offset in the type table, representing
          the corresponding type.  Size is the size in bytes of a
          value of the given type.  The size of basic types is known
          and does not appear explicitly: big and real are 64 bits;
          all others including strings and reference types are 4
          bytes.  (Strings are represented internally by a pointer.)

          Each id-table is preceded by a count of the number of
          entries, followed by an id-item for each entry in the table:

     Page 3                       Plan 9            (printed 12/21/24)

     SBL(6)                                                     SBL(6)

               id-table:
                    count \n id-items
               id-item:
                    id-offset : id-name : src type \n
               id-offset:
                    int
               id-name:
                    string
               count:
                    int

          Id-offset is the number of bytes from the start of the
          enclosing object to the value of the object identified by
          id-name.

          An adt without a pick clause is described using an adt-item:

               adt-item:
                    adt-name • src size \n id-table
               adt-name:
                    string
               size:
                    int

          The id-table has an entry for every data element of adt-
          name.

          If an adt has a pick clause, the adt's type table entry uses
          the p type character.  The invariant part of the adt is
          described by an adt-item (with zero size) and the variant
          clause is described by a tag-table of the following form:

               tag-table:
                    count \n tag-items
               tag-item:
                    name : src size \n id-table
                 |  name : src \n

          The tag-table describes the variants of a Limbo adt that
          includes a pick clause.  The name is the pick tag for the
          associated alternative.  If the size and id-table are miss-
          ing, the given variant has the same description as the pre-
          vious one.

          A tuple's id-table contains id-names of the form tn, where n
          is the 0-origin index of the item in the tuple.

          Src is as previously defined above in the PC table section.

        Fn table
          The function table describes each function implemented by
          the Dis file.

     Page 4                       Plan 9            (printed 12/21/24)

     SBL(6)                                                     SBL(6)

               fn-item:
                    fn-pc : fn-name \n args locals return
               fn-pc:
                    int
               fn-name:
                    string
               args, locals:
                    id-table
               return:
                    type

          Fn-pc is the starting pc for the Dis instructions for fn-
          name. If the function is a member of an adt, the member name
          is qualified by the adt name, so that fn-name has the form
          `adt-name.member-name'.  Within the id-tables for args and
          locals, the id-offset fields give offsets relative to the
          function's activation frame.  Furthermore, no table entries
          are made for args that are declared nil (unused).

        Data table
          The data table describes the global variables in the Dis
          file. It is an id-table, with one entry for each global
          variable.

     SEE ALSO
          limbo(1), wm-deb(1), debug(2), dis(6)

     Page 5                       Plan 9            (printed 12/21/24)