Lab: ssh, scp, gdb, valgrind

Slides:



Advertisements
Similar presentations
Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Advertisements

Utilizing the GDB debugger to analyze programs Background and application.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
DEBUGGING IN THE REAL WORLD : Recitation 4.
Traffic Server Debugging using ASAN / TSAN Brian Geffon.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
CS 225 Lab #2 - Pointers, Copy Constructors, Destructors, and DDD.
Debugger Presented by 李明璋 2012/05/08. The Definition of Bug –Part of the code which would result in an error, fault or malfunctioning of the program.
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
CIS*2450 Seminar I Makefiles Debugging/Design Approaches Exception Handling Library Revision Control Designed by: Terry Moreland Updated by: Tom Crabtree.
Hank Childs, University of Oregon May 15th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / / __.
SE-3910 Real-time Systems Week 5, Class 2 – Lab turn-in page is up! – Lost-and-not-found power supply – Quick-Quiz (Ungraded) – Use interrupts in a Linux/C.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
UNIX Introduction CSCE 221H Texas A&M University.
Errors “Computer says no..”. Types of Errors Many different types of errors new ones are being invented every day by industrious programming students..
INTRODUCTION TO CSCE LAB BASIC OF COMPUTERS, C++, UNIX, AND HELLO WORLD.
Debugging and Profiling With some help from Software Carpentry resources.
C programming and compilers. At least 3 ways to compile C Using gcc in UNIX environment via chaos.cs.auckland.ac.nz Using gcc in Cygwin in Windows Using.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
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.
Debugging Computer Networks Sep. 26, 2007 Seunghwan Hong.
Hank Childs, University of Oregon April 15th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / /
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Unit - V. Debugging GNU Debugger helps you in getting information about the following: 1.If a core dump happened, then what statement or expression did.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
Debugging Lab Antonio Gómez-Iglesias Texas Advanced Computing Center.
Hank Childs, University of Oregon April 6 th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / /
Hank Childs, University of Oregon April 13 th, 2016 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / /
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Using the GNU Debugger (GDB)‏ Techzemplary Pvt.Ltd February 24 th 2008 Pranav Peshwe.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
CSCI 4061 Recitation 2 1.
Computer System Laboratory
Hank Childs, University of Oregon
Class Projects and Environment
First Day in Lab Making a C++ program
Development Environment
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
User-Written Functions
C – Multi-file development and make
Content Programming Overview The JVM A brief look at Structure
Debugging with Clion and GDB
Dynamic Analysis ddaa.
CSE 374 Programming Concepts & Tools
Testing and Debugging.
COMP280:Introduction to Software Development Week 12, Lecture 34
Programming 101 Programming for non-programmers.
Checking Memory Management
COMP 2710 Software Construction Introduction to GDB
CS 240 – Lecture 11 Pseudocode.
Recitation: C Review TA’s 19 Feb 2018.
Computer Architecture “Bomb Lab Hints”
Hank Childs, University of Oregon
Hank Childs, University of Oregon
Lab: ssh, scp, gdb, valgrind
Getting Started: Developing Code with Cloud9
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
CSCI 380: Operating Systems Lecture #11 Instructor: William Killian
Quarter 1.
Homework Reading Programming Assignments Finish K&R Chapter 1
CSCI 380: Operating Systems Instructor: William Killian
Video Notes.
Arrays.
CSE 303 Concepts and Tools for Software Development
Makefiles, GDB, Valgrind
Presentation transcript:

Lab: ssh, scp, gdb, valgrind CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / / __ \/ / |/_/ / __ `/ __ \/ __ / / / _/_// / __/ /___/ /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / /____/_/ / /__/_ __/_ __/ \____/_/ /_/_/_/|_| \__,_/_/ /_/\__,_/ \____/_/ \____//_/ /_/ Lab: ssh, scp, gdb, valgrind xkcd 1168 April 14th, 2017 University of Oregon

Unix command: ssh Problem: you're using a computer, but you want to be using a different computer … the other computer is far away the other computer is inaccessible the other computer doesn't have a display (server) etc. ssh lets you log onto another machine

Unix command: ssh Basic Use: DEMO ssh username@machine ( equivalent version using the -l flag ) ssh -l username machine     DEMO

Unix command: ssh From demo: don't need to type username / machine name / password every time! Instructions for accomplishing this could be confusing since there are potentially different steps for different systems … ask after class or come to office hours if interested.

Unix command: scp Problem: you have files on one computer, but you want those files on a different computer ... scp lets you send files from one machine to another machine

Unix command: scp Basic Use: scp source destination either source or destination might be a remote machine … examples: scp my_file name@ix.cs.uoregon.edu:~ (this copies my_file in the current working directory to HOME directory on ix) scp name@ix.cs.uoregon.edu:/absolute/path/my_other_file .        (this copies my_other_file in /absolute/path on ix to the current working directory) nothing special about these examples ... DEMO

Debugging Problem: you wrote a computer program and it doesn't work ...

Debugging Worse problem: someone else wrote a computer program and it doesn't work ...

Debugging: lots of printf Method #1: just print everything and figure it out … this works pretty good most of the time!

Debugging: lots of printf Method #1: sometimes you are in a tough spot! when I run this, I get the value 1661289645 for y

Debugging: lots of printf Method #1: sometimes you are in a tough spot! when I run this, I get 7 for the return value of my_func … but now y is 0???

Debugging: lots of printf Method #1: sometimes you are in a tough spot! This example is kind of contrived … a more typical situation (for me, at least) is that I'm reading some code and it's completely mind boggling, and putting in print statements would just take a really long time.

Debugging: gdb More options would be great! What are all the local variables defined at some point in the program? What are the values of each variable? What happens if we change the value of a variable? Method #2: gdb can do all of this! And much more!

Debugging: gdb Method #2: gdb Can inspect and modify code as it runs without recompiling! Similar program called lldb on macOS Run from the command line, but need to compile with debug info. Example: Compile: gcc -g incorrect_program.c -o bad Run: gdb bad

Debugging: gdb Example gdb session working with the previous example program. DEMO These gdb commands, and more, explained on next slide.

Debugging: gdb Useful commands in gdb: break N: set breakpoint at line N break my_func: break whenever my_func is called watch my_var: break whenever my_var is changed run: start the program continue: go until the next breakpoint next: do the next line of code step: do the next line of code, descending into function calls info locals: display local variable information backtrace: show frames leading to crash print x: print the value of variable x print *A@N: print the first N values of array A set var x=v: set the value of variable x to v

Debugging: gdb Useful commands in gdb: these are just off the top of my head. There is a lot more there, too. It can be super helpful … have fun! Story: at the start of my internship last summer, my mentor said he'd be on vacation for a week and asked me to get a program working. Running it gives one line of output: seg fault. Upon further inspection: program is 50k lines of code, built on library that's 100k lines :( It would be great to have some way to automatically detect certain errors ...

Debugging: valgrind It would be great to have some way to automatically detect certain errors … Method #3: valgrind Need to compile with debug info. Example: Compile: gcc -g incorrect_program.c -o bad Run: valgrind ./bad Might not be installed by default on macOS. Install with homebrew? Run on ix?

Debugging: valgrind Valgrind finds only a certain type of error: memory errors. This is great, though! These errors can be really tough. Let's try finding the memory errors in this program using valgrind!

Debugging: valgrind DONE!!

Debugging: valgrind

Debugging: valgrind What about the other output? Valgrind tells us that there is a "memory leak" … memory allocated on the heap that was never freed. A memory leak isn't great because the program is unable to re-use that memory, perhaps leading it to exhaust the available memory. You will have to make your last project leak free!