CSCI 1200 Data Structures
Fall 2017

  Contact Information
  Discussion Forum (LMS)

  Learning Outcomes
  iClickers in Lecture
  Course Grades

  Lecture notes
  Lab materials
  Test reviews

Weekly Schedule
  Office Hours
  Lab Times

Getting Help
  Advice from TAs
  Advice from Students

  Due Date and Time
  Late Day Policy
  HW Grading Criteria

Collaboration Policy &
Academic Integrity

C++ Development
  Code Editors & IDEs
  OS Choices
  Install WSL
  Install Cygwin
  Memory Debugging
    Dr. Memory
  Test Your Installation

  Optional Textbooks
  Web Resources
  Misc. C++ Programming
    Command Line Args
    File I/O
    string → int/float

Simple Test of Compilation

  1. To check that you're good to go, download this simple program and save it into your data structures course directory:

  2. Open a terminal and change directory to navigate to your data structures directory:

  3. Confirm you're in the right location by listing the directory contents typing:


    You should see the file temperature.cpp and maybe some other stuff.

  4. Compile the temperature program by typing:

      g++ -Wall temperature.cpp -o temperature.out

    (Alternatively, use clang++ instead of g++.) This should creates an executable named temperature.out. Type ls again to confirm the executable appeared!

  5. Now run that executable:


    And you should be able to interact with this program at the keyboard.


Simple Test of Terminating an Infinite Loop

  1. Download and save this file to your data structures directory:

  2. Compile and run this program. It should start printing dots and not stop.

  3. Now let's confirm that your computer is spending alot of CPU resources on this infinite loop. We'll view the list of all programs running on your computer sorted by CPU usage.

    • On Mac or Linux or WSL, in another terminal type:

          top -o %CPU

      You should see the program name at or near the top of the list. And it should be using a large amount of CPU (depending on the number of processors on your machine).

    • On Windows:

      1. Search for and launch "Task Manager"
      2. Click "More Details"
      3. Click on the "CPU" column

      You should see the program name at or near the top of the list. And it should be using a large amount of CPU (depending on the number of processors on your machine).

  4. Confirm that you can terminate the runaway program by pressing Ctrl-c (or Ctrl-k).


Simple Test of Memory Debugger Installation & Usage

  1. Download and save this short (intentionally buggy) program:

  2. Follow the instructions for your system to compile this program for Memory Debugging. You'll need to add a few additional compiler flags, and you may need to use a different compiler.

  3. Now run the program under the memory debugger and locate the report generated by the memory debugger. (It may be printed directly to the terminal and/or saved to a file.)

NOTE: The memory debugger report contains lots of data which can be intimidating the first time you see it. This tiny program has 4 different errors! We'll discuss the code, and the errors, and how to understand this report a few weeks into the term.


Simple Test of the Traditional Debugger

  1. Launch the temperature program (or another executable) inside of the gdb debugger:

        gdb ./temperature.out
  2. At the gdb prompt, start the program:

  3. If the program is still running, press Ctrl-C. To see the stack backtrace of the program (listing the functions you are in the middle of), type:

  4. Finally, close gdb:


    (You will have to press 'y' if the program is still running.)

If you're using LLVM's clang++ instead of g++, you'll also use LLVM's lldb instead of gdb. The above commands are the same (just substitute lldb for gdb), and many of the other commands are similar:

     A handy table of the different gdb/lldb commands

NOTE: The traditional debugger has many powerful features that you should learn over the term. Follow online tutorials and ask for help in lab and office hours to most effectively debug your programming assignments.