Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd.

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

Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 7, 2012 CSCE 212Honors Computer Organization.
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
Utilizing the GDB debugger to analyze programs Background and application.
What is DWARF Introduction to the DWARF Format
Linking and Loading Fred Prussack CS 518. L&L: Overview Wake-up Questions Terms and Definitions / General Information LoadingLinking –Static vs. Dynamic.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Debugging with gdb David Khosid Sept 6, 2009
Gdb: GNU Debugger Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users” Third Edition, Prentice-Hall,
Introduction CS212 Dick Steflik. What is CS-212 Primarily an introduction to linear and non-linear data structures  arrays  stacks and queues  lists.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
CSE 303 Lecture 13a Debugging C programs
DDD tutorial A GDB Graphical User Interface. DDD Introduction If you find GDB difficult to use, try DDD DDD s GDB but with a Graphical User Interface.
CS 225 Lab #2 - Pointers, Copy Constructors, Destructors, and DDD.
Homework Reading –Finish K&R Chapter 1 (if not done yet) –Start K&R Chapter 2 for next time. Programming Assignments –DON’T USE and string library functions,
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.
F13 Forensic tool analysis Dr. John P. Abraham Professor UTPA.
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.
Homework Reading Programming Assignments
Debugging Cluster Programs using symbolic debuggers.
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
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.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
Python/Tango Client Binding Swig ( Vs Boost (
CSI605 Introduction to gdb. Compiling for gdb Execution I often compile as follows gcc -g -Wall -omyprog myprog.c g++ -g -Wall -omyprog myprog.c It suffices.
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.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
S OME USEFUL D EBUG C OMMANDS FOR C LEAR -S PEED S OFTWARE D EVELOPMENT K IT -- COMMANDS FROM CHAP.7 By: Pallav Laskar.
Application Debugging. Debugging methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic.
Debugging 1/6/2016. Debugging 1/6/2016 Debugging  Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a program.
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.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
17/02/2016S. Ponce / EP-LBC1 Debugging Under Linux Sebastien Ponce Friday, 8 March 2002.
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
C P ROGRAMMING T OOLS. C OMPILING AND R UNNING S INGLE M ODULE P ROGRAM.
CMSC 104, Version 8/061L14AssignmentOps.ppt Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips Reading Section.
Intro to Debugging Marwan H. Hussein, TA B.Sc., Systems & Biomedical Engineering Department, Cairo University Egypt SBE201 – Data Structures and Algorithms.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2014.
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
The World Leader in High Performance Signal Processing Solutions Toolchain Basics.
Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 4, 2010 CSCE 212Honors Computer Organization.
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.
DEBUG.
Precept I : Lab Environment, Unix, Bash, Emacs
Computer System Laboratory
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Dynamic Analysis ddaa.
Computer Architecture and Assembly Language
CSCE 212Honors Computer Organization
Debugging with gdb gdb is the GNU debugger on our CS machines.
Software Development with uMPS
CSE 351 Section 1: HW 0 + Intro to C
gdb gdb is the GNU debugger on our CS machines.
Debuggers.
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]
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2015.
Homework Reading Programming Assignments Finish K&R Chapter 1
Program Execution in Linux
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
CSE 303 Concepts and Tools for Software Development
CSCE 212Honors Computer Organization
Debugging.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2013.
Computer Architecture and System Programming Laboratory
By Hugues Leger / Intro to GDB debugger By Hugues Leger / 11/16/2019.
Presentation transcript:

Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd

Debugovaci informace gcc: ● -g, -ggdbgeneruje debugovaci informace relevantni pro gdb ● -gdwarf-4generuje debugovaci informace ve formatu dwarf-4 ● -g nastavy pozadovany format debugovacich dat ● -s odstrani mimo jine i debugovaci data

Debugovaci informace Rozdil mezi ● gcc -O0 -g ● gcc -O2 -g vypsani dwarf debug. dat pro danou binarky ● readelfvypisuje informace o ELF ● readelf -wvypise vsechny zaznamy ● readelf -wivypise dwarf zaznamy v.debug_info sekci ● readelf -w[lLiaprmfFsoR]

STABS format ● “symbol table entries” ● Peter Kessler (University of California) vytvoril format pro Pascal debugger - ?1988? ● 4 typy zaznamu: –.stabs "string",type,other,desc,value –.stabn type,other,desc,value –.stabd type,other,desc –.stabx "string",value,type,sdb-type

STABS format Cast z obsahu pogram.s souboru 18.stabs "double:t13=r1;8;0;",128,0,0,0 19.stabs "long double:t14=r1;8;0;",128,0,0,0 20.stabs "void:t15=15",128,0,0,0 21.align 4 22 LC0: 23.ascii "Hello, world!\12\0" 24.align 4 25.global _main 26.proc 1 27 _main: 28.stabn 68,0,4,LM1

DWARF format (1) ● 'Debugging With Attributed Record Formats' ● vytvoren spolu s formatem ELF ● DWARF 1 prilis pametove narocne, ne prilis rozsiren ● DWARF 2 (1990) mensi pametova narocnost, vice rozsiren ● DWARF 3 (2006) obsahuje c++ namespaces,.. ● DWARF 4 (2010) lepsi podpora c++ a optimalizoveho kodu

DWARF format (2) ● K reprezentaci promennych, typu a procedur pouzva struktury Debugging Information Entry (DIE) ● Zaznamy rozdeleny do sekci –.debug_ sekce

DWARF format (3) $ readelf -wi sdwarf2 Contents of the.debug_info section: Compilation offset 0x0: Length: 0x94 (32-bit) Version: 2 Abbrev Offset: 0 Pointer Size: 4 : Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_producer : (indirect string, offset: 0x33): GNU C (Red Hat ) DW_AT_language : 1(ANSI C) DW_AT_name : (indirect string, offset: 0x60): test.c DW_AT_comp_dir : (indirect string, offset: 0x7a): /tmp DW_AT_low_pc : 0x80483f4 DW_AT_high_pc : 0x DW_AT_stmt_list : 0x0 : Abbrev Number: 2 (DW_TAG_base_type) DW_AT_byte_size : 4 DW_AT_encoding : 7(unsigned) DW_AT_name : (indirect string, offset: 0x26): unsigned int

gdb(1) ● The GNU Project Debugger (version 7.2) ● napsan Richardem Stallmanem v roce 1986 – zakladatel GNU projektu a Free Software Foundation ● verze pouziva format DWARF (od gdb-4.3 obsahuje DWARF support) ● nyni vyvijeno skupinou “GDB Steering Committee” ● Obsahuje pouze command line interface

SPUSTENI ● gdb program ● gdb progam.c core ● gdb program $PID ZAVRENI ● q,quit, +D ● +C

gdb (2) SPUSTENI PROGRAMU ● run spustit program s defaultnimi argumenty ● run spustit program s danymi/defaultnimi argumenty ● run... outf ● killukonci spusteny program

gdb(3) PARAMETRY SPUSTENI ● set args argsnastavi seznam arg. pro nasledne spusteni programu ● show argsukaze seznam nastavenych argumentu ● set env nastavi promennou prosredi ● show env ukaze promenne prostredi

gdb(4) BREAKPOINTY ● b [file:]linenastavi breakpoint na radek linefile:]line ● b [file:]funcnastavi breakpoint na funkci function ● watch exprnastavi watchpoint na vyraz expr ● info breakukaze nastavene breakpoint ● info watchukaze nastavene watche ● delete [n]smaze breakpoint cislo n

gdb(5) DATA O ZASOBNIKU ● info localsvypise lokalni promenne ● btbacktrace

gdb(6) VYKONAVANI KODU ● c,continuepokracuj v behu programu ● s,steppokracuj do dalsi radky ● n,nextpokracuj do dalsi radky, vcettne pruchodu funkci ● n(5)proved n 5-krat za sebou ● j pokracuj do radku cislo line

gdb(7) DALSI ● p, printvytiskni hodnotu promenne ● shell proved prikaz shellu ● whatis vrati typ argumentu ● ptype vrati definici typu

ddd

ddd (2) ● Prikazovy radek

ddd(3) ● Kod programu (+ breakpointy,..)

ddd(4) ● vypis hodnot promennych