Об отладке программ МО ВВС ИВМ и МГ СО РАН Городничев Максим Александрович.

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.
Review of Scientific Programming in C and Fortran Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
Miguel Garzon CrUise Lab - SITE. #include dynamic memory allocationdynamic memory allocation Input/output String handlingString handling Mathematical.
Gdb: GNU Debugger Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users” Third Edition, Prentice-Hall,
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 The CS-220 Development Environment.
David Notkin Autumn 2009 CSE303 Lecture 16 #preprocessor Debugging is twice as hard as writing the code in the first place. Therefore, if you write the.
12/2/05CS591-F2005, UCCS Frank Gearhart 1 Why doesn’t “gets()” get it? Or more formally: An investigation into the use of the buffer overflow vulnerability.
CSE 303 Lecture 13a Debugging C programs
Open Source/Free Software Source code is available Extensible Can be changed, modified Freely distributed Copies Modified versions Alternatives to commercial/proprietary.
Advanced Programming in the UNIX Environment Hop Lee.
Pointers Example Use int main() { int *x; int y; int z; y = 10; x = &y; y = 11; *x = 12; z = 15; x = &z; *x = 5; z = 8; printf(“%d %d %d\n”, *x, y, z);
C Slides and captured lecture (video and sound) are available at:
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.
Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://
Spring 2014 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
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.
Embedded systems debugging 25 February 2015 Lecture
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
Linux Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Copyright © 2009 Techtronics'09 by GCECT 1 Presents, De Code C De Code C is a C Programming competition, which challenges the participants to solve problems.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
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.
1 #include void silly(){ char s[30]; gets(s); printf("%s\n",s); } main(){ silly(); return 0; }
Development of Multiplatform, VR Applications Pablo Figueroa 1, Pierre Boulanger 1, H. J. Hoover 1, Mark Green 2, Robyn Taylor 1 1.University of Alberta.
Asterisk’s Installation Requirements Kernel source bison bison-devel ncurses ncurses-devel zlib zlib-devel openssl openssl-devel gnutls-devel gcc gcc-c++
Adv. UNIX: debug/141 Advanced UNIX v Objectives of these slides: –tools and techniques for debugging C code Special Topics in Comp. Eng.
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.
National Chung Cheng University,Taiwan,R.O.C eCos demo using x86 PCs I-Hung Lin Date:2004/4/29.
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.
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.
17/02/2016S. Ponce / EP-LBC1 Debugging Under Linux Sebastien Ponce Friday, 8 March 2002.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
CMSC 104, Version 8/061L14AssignmentOps.ppt Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips Reading Section.
CS252: Systems Programming Ninghui Li Based on Slides by Gustavo Rodriguez-Rivera Topic 2: Program Structure and Using GDB.
CPT: Debug/ Computer Programming Techniques Semester 1, 1998 Objective of these slides: –to talk about the various approaches to testing.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
Gnu Debugger (GDB) Topics Overview Quick Reference Card Readings: Quick Reference Card February 4, 2010 CSCE 212Honors Computer Organization.
Heap Overflows. What is a Heap? malloc(), free(), realloc() Stores global variables Automatic memory allocation/deallocation Allocated at runtime Implemented.
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.
1 © 2007 Mauro Morsiani Laboratorio di Sistemi Operativi Anno Accademico Software Development with uMPS Part 2 Mauro Morsiani Copyright © 2007.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
CSCI 4061 Recitation 2 1.
DEBUG.
Lab 2 main issues Point and line classes should NOT have their own protected “type” attributes these hide the parent (shape) classes attribute with the.
GNU Coding Guidelines Shakthi Kannan GNU Free Documentation License
Dynamic Analysis ddaa.
CSCE 212Honors Computer Organization
Software Development with uMPS
Software Development with uMPS
gdb gdb is the GNU debugger on our CS machines.
Introduction to Computer Systems
Operating System Discussion Section.
ניפוי שגיאות - 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.
GNU DEBUGGER TOOL. What is the GDB ? GNU Debugger It Works for several languages – including C/C++ [Assembly, Fortran,Go,Objective-C,Pascal]
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.
Computer Programming Techniques Semester 1, 1998
CSE 303 Concepts and Tools for Software Development
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.
Makefiles, GDB, Valgrind
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
Presentation transcript:

Об отладке программ МО ВВС ИВМ и МГ СО РАН Городничев Максим Александрович

Отладочный вывод Буферизованный вывод printf(“Программа пришла сюда\n”); std::cout << “Текст\n” Небуферизованный вывод fprintf(stderr, “Программа пришла сюда\n”); std::cerr << “Текст\n”;

Отладочный вывод Очистка буфера: Cprintf(“Text\n”); fflush(stdout); C++std::cout << “Text\n”; std::cout.flush();

Отладка в gdb. Пример ошибочной программы. #include int f() { int* p = 0; *p = 100; return *p; } void g() { printf("%d", f()); } int main() { g(); } tests]$./a.out Segmentation fault

Отладка в gdb. Компиляция. tests]$ gcc –g3 segfault.c

Отладка в gdb. Запуск программы в отладчике. tests]$ gdb./a.out GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-suse-linux"... Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run

Отладка программы в gdb. Анализ ошибки Starting program: /home/maxim/work/tests/a.out Program received signal SIGSEGV, Segmentation fault. 0x in f () at segfault.c:5 5 *p = 100; (gdb) backtrace #0 0x in f () at segfault.c:5 #1 0x c in g () at segfault.c:11 #2 0x080483a4 in main () at segfault.c:16 (gdb) print p $1 = (int *) 0x0 (gdb) quit The program is running. Exit anyway? (y or n) y

Отладка в gdb. Пошаговое выполнение. (gdb) break g Breakpoint 1 at 0x : file segfault.c, line 11. (gdb) run Starting program: /home/maxim/work/tests/a.out warning:.dynamic section for "/lib/libc.so.6" is not at the expected address warning: difference appears to be caused by prelink, adjusting expectations Breakpoint 1, g () at segfault.c:11 11 printf("%d", f()); (gdb) next Program received signal SIGSEGV, Segmentation fault. 0x in f () at segfault.c:5 5 *p = 100;

Отладка в gdb. Пошаговое выполнение. (gdb) step f () at segfault.c:4 4 int* p = 0; (gdb) list 1 #include 2 int f() 3 { 4 int* p = 0; 5 *p = 100; 6 return *p; 7 } 8 9 void g() 10{ (gdb) continue

Вопросы?