CS 403: Programming Languages - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

CS 403: Programming Languages

Description:

Compile with gcc -g. Example: gcc -g -o myProgram myprogram.c ... Example: gdb myProgram. MP1. Complete write-up available on the class website ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 13
Provided by: csUa
Category:

less

Transcript and Presenter's Notes

Title: CS 403: Programming Languages


1
CS 403 Programming Languages
  • Lecture 4
  • Fall 2004
  • Department of Computer Science
  • University of Alabama
  • Joel Jones

2
Outline
  • Symbol Tables
  • Activation Records
  • GDB
  • Reading Questions for Next Class

3
Symbol Tables (Cont.)
  • A hash table can be added to the previous data
    structure to accelerate the search.
  • Elements with the same name are linked from top
    to bottom.
  • Search start at the entry of the hash table and
    proceeds through the linked list until the end of
    the list is reached (old_id) or until the link
    list refers to an element below scope_marker(LL -
    1) (new_id)

4
Symbol Tables (Cont.)
  • This approach does not work in some cases.
  • Consider the with statement of Pascal and Modula
    2.
  • Date RECORD day 1..31
  • mo month
  • yr CARDINAL
  • END
  • d1 Date
  • WITH d1 DO
  • day10 moSep yr1981
  • END
  • is equivalent to
  • d1.day10 d1.moSep d1.yr1981

5
Symbol Tables
6
Symbol Tables (Cont.)
7
The binding of referencing environments
  • Shallow binding the referencing environment of a
    routine is not created until the subroutine is
    actually called.
  • Deep binding the program binds the environment
    at the time the subroutine is passed as a
    parameter.
  • Deep binding is implemented by creating an
    explicit representation of a referencing
    environment and bundling it together with a
    reference to the subroutine. Closure

8
Activation Records for Nested Routines
9
GDB
  • GDB Gnu DeBugger
  • Preparation
  • Compile with gcc -g
  • Example gcc -g -o myProgram myprogram.c
  • Run the program under control of gdb
  • Example gdb myProgram

10
MP1
  • Complete write-up available on the class website
  • Basic Idea write 1 or more programs and
    associated GDB scripts that demonstrate object
    (generic, not OO) lifetimes and scopes
  • GDB scripts should print out addresses, values of
    variables, etc.

11
Demonstration of GDB
  • Create program
  • Compile it
  • Run under gdb
  • Print some variables
  • Show automatically running script
  • gdb -x gdbCmdFile myProgram

12
Reading for Next Class
  • Skim the following, paying particular attention
    to how to print the addresses of variables
  • Debugging with GDB The GNU Source Level Debugger
  • http//www.gnu.org/manual/gdb-5.1.1/gdb.html
  • GDB Quick Reference Card
  • http//www.refcards.com/download/gdb-refcard-lette
    r.pdf
Write a Comment
User Comments (0)
About PowerShow.com