TA: Maya Rodrig Our C++ guru: Nic Bone

Slides:



Advertisements
Similar presentations
Utilizing the GDB debugger to analyze programs Background and application.
Advertisements

Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Linux/g++: Maze solving in CSE326. Linux machines at U. W. Machine Names: Ceylon, Sumatra, Fiji, Tahiti
1 Basics of Linux On linux machine: Login at your home directory Open a “shell” or “terminal” or “xterm” workspace (4) On windows machine Intall linux.
UNIX By Darcy Tatlock. 1. Successful Log Into Unix To actively manipulate your website you need to be logged in. Without being logged in you cannot enter.
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Looks like DOS…but more powerful.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
The Unix Environment and Compiling. Getting Set Up Your programs will be compiled and tested on the Departmental server ‘linprog’ The linprog servers.
CprE 288 – Quick intro for compiling C in Linux
Overview of Linux CS3530 Spring 2014 Dr. José M. Garrido Department of Computer Science.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Unix Command Project Justin Rogers for LS 560 Spring 2015.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Unix Basics Chapter 4.
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
Carnegie Mellon Linux Boot Camp Jenna MacCarley, Peter Pearson, Shashank Goyal 9/19/2015.
TAMU CSCE 313 (the basics). Basic Unix/Linux programming Accessing CS systems  PuTTY (putty.exe) – a Telnet and SSH client  Common hosts: unix.cs.tamu.edu.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
Unix and Samba By: IC Labs (Raj Kidambi). What is Unix?  Unix stands for UNiplexed Information and Computing System. (It was originally spelled "Unics.")
Unix Commands PowerPoint Presentation developed for LS 560 Information Technology online class - University of Alabama by Debey Sklenar TENacious Cohort.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
Introduction to Programming Using C An Introduction to Operating Systems.
Using the “CLI” Unix / Linux Preparation Course June 9, 2013 Lusaka, Zambia.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
Object Oriented Programming COP3330 / CGS5409.  Assignment Submission Overview  Compiling with g++  Using Makefiles  Misc. Review.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
 Simple UNIX commands  I/O techniques in C++  Solutions to Lab#0 problems  Solutions to Lab#1 problems 1.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
1 CS101 Fall 2001 Lecture 1 In order to write a program, you must first telnet to your pegasus account and login either from a Rutgers computer in a lab,
 Prepared by: Eng. Maryam Adel Abdel-Hady
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Learning Unix/Linux Based on slides from: Eric Bishop.
Object Oriented Programming COP3330 / CGS5409.  Assignment Submission Overview  Compiling with g++  Using Makefiles  Misc. Review.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
Review Why do we use protection levels? Why do we use constructors?
Overview of Linux Fall 2016 Dr. Donghyun Kim
ENEE150 Discussion 01 Section 0101 Adam Wang.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
First Day in Lab Making a C++ program
CS1010: Intro Workshop.
Introducing the UNIX Operating System.
Development Environment Basics
Chapter 11 Command-Line Master Class
Prepared by: Eng. Maryam Adel Abdel-Hady
UNIX The Basics Source:
Andy Wang Object Oriented Programming in C++ COP 3330
The Command Prompt Commands are the way to “do things” in Unix
Guide To UNIX Using Linux Third Edition
The Linux Operating System
Editor, Compiler, Linker, Debugger, Makefiles
CSE 374 Programming Concepts & Tools
Basic UNIX OLC Training.
Using Linux Commands Lab 3.
Intro to UNIX System and Homework 1
Computer Architecture “Bomb Lab Hints”
Getting Started: Developing Code with Cloud9
Andy Wang Object Oriented Programming in C++ COP 3330
Using emacs and G++ at U. W.
Linux Shell Script Programming
Command line.
Stata Basic Course Lab 2.
CSE 303 Concepts and Tools for Software Development
Appendix F C Programming Environment on UNIX Systems
Video Notes.
Debugging.
Presentation transcript:

TA: Maya Rodrig Our C++ guru: Nic Bone CSE 326 TA: Maya Rodrig Our C++ guru: Nic Bone

Linux machines at UW Machine Names: Ceylon, Sumatra, Fiji, Tahiti http://www.cs.washington.edu/lab/facilities/instr-labs.html Access Use X-terminals in back of Sieg 329 (click on one of the Linux machines) Use Windows machines

Opening an XTERM on a Windows machine Log into the CSEPCLAB domain Start -> Programs -> Reflection -> Reflection X “X Client Manager” should open Select the “linux.rxc” connection template Select the KERBERIZED TELNET method Enter the host name (fiji, ceylon, tahiti, sumatra) Click Connect An XTERM should open (if not, ask for help)

Unix Manual: ‘man’ Keys: q – exit man Page Up Page Down The command: apropos copy Finds all man pages that contain the word “copy” in their descriptions. Useful for finding out about a command. Keys: q – exit man Page Up Page Down

Make Project Directory fiji% mkdir cse326 fiji% cd cse326 fiji% mkdir proj1 fiji% cd proj1 fiji% pwd /homes/iws/rodrig/cse326/proj1 fiji% ls /homes/iws/rodrig/cse326/proj1 fiji% More UNIX commands are at: http://www.cs.washington.edu/education/courses/cse326/00wi/unix/unix.html

Look at files in a class directory

File Permissions ‘w’ here means I can write to the files, but no-one else can

chmod (thanks to Nic Bone) > I'm having trouble understanding the man files. How would I change permission to > -rwxr--r-- > > What's the syntax? The easy-to-remember way to do this is to type: % chmod a+r file % chmod u+wx file % chmod go-wx file Meaning of the symbols: r: read w: write x: execute u: user g: group o: other a: all three (u, g, and o) +: add this permission -: remove this permission You can also set the permissions with one command using a numeric code of three numbers in the range 0-7. The first number corresponds to user permissions, the second to group permissions, and the third to other (or world) permissions. Read permission is +4, write permission is +2, and execute permission is +1. So to change permission to -rwxr--r--, we would type: % chmod 744 file Nic.

How to compile the program

How to run your program ./ is important. By default, Linux won’t search the current directory for a program. So you have to explicitly tell it (eventually, you can change your PATH environment variable) < means get the input from the file to the right (inputs/maze1.txt), instead of the keyboard. If you don’t put this in, the program will expect you to type the input on the keyboard – quite a hassle!

Edit runmaze.cpp – forgot & Darn, now we lost this shell until we close emacs

Edit runmaze.cpp Current line number

Emacs keys CTRL-X S (hold down control for both letters) CTRL-X C Save your work CTRL-X C Exit emacs CTRL-G Abort current command (if you accidentally typed something wrong) More: (Quick intro) http://www.cs.washington.edu/education/courses/cse326/00wi/unix/emacs.html (official documentation) http://www.lns.cornell.edu/public/COMP/info/emacs/emacs_toc.html

Intro to make – project file dependencies

2 lines from Makefile runmaze : runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o g++ -o runmaze -g runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o -L/usr/X11R6/lib -lX11 runmaze (executable file) is dependant on a bunch of object files If runmaze doesn’t exist, or is out of date (relative to object files), here’s how to build it WARNING: this is a tab character. It has to be tab, and can’t be spaces. Those are the rules.

g++ linking command line -o runmaze Call the output file ‘runmaze’ (instead of a.out, which is the default) -g Include debugging information, so you can use a debugger -L/usr/X11R6/lib -lX11 Include X-Windows libraries (for visualization part) g++ -o runmaze -g runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o -L/usr/X11R6/lib -lX11

2 lines for runmaze.cpp (well, technically runmaze.o) runmaze.o : runmaze.cpp Maze.h SquareMaze.h MazeRunner.h RandomMazeRunner.h VisualizeSquareMazeRunner.h g++ -Wall -c -g runmaze.cpp The object file runmaze.o depends on runmaze.cpp + some .h files The infamous tab character strikes again! If runmaze.o doesn’t exist, or is out of date relative to the files past the colon ( : ), here’s how to build it with g++.

g++ compiling flags -c -Wall -g Only compile, don’t link – we’ll let make decide when to link. -Wall g++ will give us all of the Warnings it can think of. Maybe it’ll help us find a bug quickly. -g Add debugging information. Is this the g as in –g? Who knows?

So you want to add a .h file Add the .h file to every .o file of a .cpp file that #includes the .h file, directly or indirectly. runmaze.o : runmaze.cpp Maze.h SquareMaze.h MazeRunner.h RandomMazeRunner.h VisualizeSquareMazeRunner.h Fictitious.h g++ -Wall -c -g runmaze.cpp MazeRunner.o : MazeRunner.cpp Maze.h MazeRunner.h Fictitious.h g++ -Wall -c -g MazeRunner.cpp RandomMazeRunner.o : RandomMazeRunner.cpp Maze.h MazeRunner.h RandomMazeRunner.h g++ -Wall -c -g RandomMazeRunner.cpp But RandomMazeRunner.cpp doesn’t #include Fictitious.h (in our example)

Adding a .cpp file runmaze : runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o Bogus.o g++ -o runmaze -g runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o Bogus.o -L/usr/X11R6/lib -lX11 Bogus.o : Bogus.cpp Bogus.h Maze.h MazeRunner.h g++ -Wall -c -g Bogus.cpp Add .o file to dependencies of executable program Also, add .o file to list of files to link in (must do both) Tell make how to make Bogus.o

Debugging Recommendations: Add print statements (or cout<<) so you can see what your program is doing. Make them check a global variable (doDebug), so you can turn them off & on (make sure debugging is off before turning in your project). Use gdb (see below) Use xxgdb (has dinky graphical user interface)

start it/set a couple of breakpoints break gdbSquareMaze::getStartMazeNode is the form for putting a breakpoint on a C++ class method.

Run program in gdb To see more commands, the help command is help or look at the extra information pointers near the beginning of these slides.

More info 326 Computing page (more info on these tools) GNU Info pages http://www.cs.washington.edu/education/courses/cse326/00wi/computing.html GNU Info pages http://www.lns.cornell.edu/public/COMP/info/ Friendly people in lab / other students man command