Introduction to Computer Systems

Slides:



Advertisements
Similar presentations
University of Washington Procedures and Stacks II The Hardware/Software Interface CSE351 Winter 2013.
Advertisements

Machine/Assembler Language Putting It All Together Noah Mendelsohn Tufts University Web:
Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 7, 2012 CSCE 212Honors Computer Organization.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
September 22, 2014 Pengju (Jimmy) Jin Section E
Memory & Storage Architecture Seoul National University Computer Architecture “ Bomb Lab Hints” 2nd semester, 2014 Modified version : The original.
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
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.
Recitation 2: Assembly & gdb Andrew Faulring Section A 16 September 2002.
Recitation: Bomb Lab June 5, 2015 Dipayan Bhattacharya.
Gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and.
Debugging Cluster Programs using symbolic debuggers.
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
Assembly, Stacks, and Registers Kevin C. Su 9/26/2011.
Carnegie Mellon Introduction to Computer Systems /18-243, spring 2009 Recitation, Jan. 14 th.
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
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.
Goals: To gain an understanding of assembly To get your hands dirty in GDB.
Lecture 2: Basic Instructions EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
Carnegie Mellon Recitation: Bomb Lab 21 Sep 2015 Monil Shah, Shelton D’Souza.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Debugging Xin Tong. GDB GNU Project debugger Allows you to see what is going on `inside' another program while it executes or crashed. (Faster than printing.
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.
Assembly and Bomb Lab : Introduction to Computer Systems Recitation 4: Monday, Sept. 16, 2013 Marjorie Carlson Section A.
1 Carnegie Mellon Assembly and Bomb Lab : Introduction to Computer Systems Recitation 4, Sept. 17, 2012.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
GDB Introduction And Lab 2
Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 4, 2010 CSCE 212Honors Computer Organization.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Instructions for test_function
Instruction Set Architecture
Recitation 5: Attack Lab
Machine-Level Programming I: Basics
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Static and dynamic analysis of binaries
Credits and Disclaimers
Recitation: Bomb Lab _______________ 18 Sep 2017.
More GDB, Intro to x86 Calling Conventions, Control Flow, & Lab 2
Dynamic Analysis ddaa.
Computer Architecture and Assembly Language
Recitation: Attack Lab
CSCE 212Honors Computer Organization
Debugging with gdb gdb is the GNU debugger on our CS machines.
Recitation: Bomb Lab _______________ 06 Feb 2017.
Malware Incident Response  Dynamic Analysis - 2
The Stack & Procedures CSE 351 Spring 2017
gdb gdb is the GNU debugger on our CS machines.
Recitation: Attack Lab
Computer Architecture “Bomb Lab Hints”
Debuggers.
Recitation: Attack Lab
Getting Started Download the tarball for this session. It will include the following files: driver 64-bit executable driver.c C driver source bomb.h declaration.
Getting Started Download the tarball for this session. It will include the following files: driver 64-bit executable driver.c C driver source bomb.h declaration.
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
Reverse Engineering for CTFs
Get To Know Your Compiler
Reversing an Executable
Machine-Level Programming II: Basics Comp 21000: Introduction to Computer Organization & Systems Spring 2016 Instructor: John Barr * Modified slides.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
CSCE 212Honors Computer Organization
Debugging.
Getting Started Download the tarball for this session. It will include the following files: driver 64-bit executable driver.c C driver source bomb.h declaration.
Credits and Disclaimers
Visual Studio x64 C Compiler function entrance code
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
Computer Architecture and System Programming Laboratory
Recitation: Bomb Lab Your TAs September 16th 2019.
By Hugues Leger / Intro to GDB debugger By Hugues Leger / 11/16/2019.
Presentation transcript:

15-213 Introduction to Computer Systems With Your TA!

GDB, Assembly Code, & Bomblab Recitation 2 Monday September 13th, 2010

Schedule News GDB Assembly Code Bomblab Bomblab Example

News Datalab will be graded by next Monday Scores will show up on Autolab. Questions? Complaints? Email the TA that graded your lab. (Their andrewID will appear at the bottom of your feedback) TA's will rotate So no one TA will grade two of your labs. Labs will be hand graded and handed back in recitation Please update your Autolab profile specifying which recitation you will pick up your lab in.

GDB

Gnu DeBugger Step through program execution Examine values of program variables. Trap system signals (such as SIGSEGV) Set breakpoints to halt execution at any point Watch variables to see when they change.

GDB Example (gdb) list 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(){ 5 int a,b,c; 6 7 a = 4; 8 b = 10; 9 c = a*b; 10 11 printf("A is %d, b is %d, and c is%d \n",a,b,c); 12 13 return 0; 14 } (gdb) break simple.c:9 Breakpoint 1 at 0x804839e: file simple.c, line 9. (gdb) run Starting program: 15213/rec2/a.out Breakpoint 1, main () at simple.c:9 9 c = a*b; (gdb) print a $1 = 4 (gdb) print b $2 = 10 (gdb) print c $3 = 134513642 (gdb) where #0 main () at simple.c:9 (gdb) continue Continuing. A is 4, b is 10, and c is 40 Program exited normally.

Some GDB Commands run [arg1 [arg2 [...]]] executes the program with specified arguments break [file.c:]line# | functionName | memAddr sets a break point breaks execution BEFORE executing the statement!!!! print varName | $register prints a variable or register's value. stepi step through one instruction in assembly

Some GDB Commands (cont) disas [function] show the disassembly of the current code (or the function) continue continue program execution after stopping at a breakpoint. info break | registers | ..... shows information about breakpoints/registers/....

Assembly Code

x86 Assembly Variables ==> Registers %esp -> Stack Pointer %ebp -> Stack Base Pointer %eax -> Function Return Value %eip -> Instruction Pointer (a bunch of other ones)

x86_64 Assembly Variables ==> Registers %rsp -> Stack Pointer %rbp -> Stack Base Pointer %rax -> Function Return Value %rip -> Instruction Pointer %rdi, %rsi, %rdx, %rcx -> Function Arguments (and a bunch-bunch more)

Assembly Addressing ( R ) ==> *(Reg(R)) The memory at address stored in register R D( R ) ==> *(Reg(R)+D) The memory at the address ( R + (constant D)) ex: 4(%eax) ==> *(%eax + 4) D(Rb,Ri,S) ==> *(Reg(Rb) + Reg(Ri)*S + D) Constant Displacement 'D' Base Register 'Rb' Index Register 'Ri' Scale (1,2,4,8..)

Addressing Examples

Arithmetic Operations

Examples C function with some simple math Lets examine the assembly code both unoptimized and optimized Step through this code with GDB

Bomblab

Bomblab Solve a series of stages by finding the password for a function We give you a compiled binary You read the assembly code to figure out the passwords

Bomblab Hints If it blows up, you're doing it wrong! Use GDB to step through the program, following execution and watching what happens to variables Figure out what checks are made and how to pass them

Bomblab Example Lets return to the example we had and try to get it to return certain output values.

A note on Bomblab You can usually make some guesses and solve each stage that way. But, if you are stuck, just work through each line of assembly and try to re-construct the C-code.

Final Thoughts There is LOTS of documentation for this stuff on the internet. Become comfortable with GDB, you'll have to use it a lot. Remember: Office Hours: Mon-Thurs: 5:30-7:30pm in WeH 5207 15-213-staff@cs.cmu.edu !!!

kthxbai