GDB Linux GNU Linux Distribution. gdb gcc g++ -g gdb EB_01.cpp
|
|
- Aubrie Morton
- 6 years ago
- Views:
Transcription
1 B Linux GDB
2 GDB Linux GNU GPL Linux Distribution Linux E-B.1 gcc g++ -g EB_01.cpp EB_01.cpp E/EB/EB_01.cpp /**** :EB_01.cpp : *****/ #include <iostream> using namespace std; void cal_ele(int i,int *add_ary,int *mul_ary); void main(void) { int add_ary[5]={0}; int mul_ary[5]={1}; int i; for(i=1;i<10;i++) cal_ele(i,add_ary,mul_ary); for(i=0;i<5;i++) cout << "add_ary[" << i << "]=" << add_ary[i] << endl; cout << " \n"; for(i=0;i<5;i++) cout << "mul_ary[" << i << "]=" << mul_ary[i] << endl; } void cal_ele(int i,int *add_ary,int *mul_ary) { E-B-2
3 Linux GDB B } add_ary[i]=add_ary[i-1]+i; mul_ary[i]=mul_ary[i-1]*i; add_ary[0]=120 add_ary[1]=720 add_ary[2]=5040 add_ary[3]=40320 add_ary[4]= mul_ary[0]=1 mul_ary[1]=1 mul_ary[2]=2 mul_ary[3]=6 mul_ary[4]=24 segment fault (1) 0~4 add_ary 0!~4! mul_ary (2) add_ary 0,1,3,6,10 segment fault -g EB_01 g++ -g EB_01.cpp -o EB_01 (3) -g EB_01 E-B-3
4 E-B.2 -g EB_01 EB_01 GNU Red Hat Linux 7.x (5.0rh-15) (MI_OUT) Copyright 2001 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-redhat-linux"... () GDB (1) GDB EB_01 (2) () GDB (3) -q quit E-B-4
5 Linux GDB B () quit jhchen@aho:~/c_cpp/e/eb$ Tab qu Tab quit E-B.3 list run shell Linux shell GDB exit shell linux Linux shell shell ls help help all list list () list 1 /**** :EB_01.cpp : *****/ 2 #include <iostream> 3 using namespace std; 4 void cal_ele(int i,int *add_ary,int *mul_ary); 5 void main(void) 6 { E-B-5
6 7 int add_ary[5]={0}; 8 int mul_ary[5]={1}; 9 int i; 10 for(i=1;i<10;i++) () list 11 cal_ele(i,add_ary,mul_ary); 12 for(i=0;i<5;i++) 13 cout << "add_ary[" << i << "]=" << add_ary[i] << endl; 14 cout << " \n"; 15 for(i=0;i<5;i++) 16 cout << "mul_ary[" << i << "]=" << mul_ary[i] << endl; 17 } 18 void cal_ele(int i,int *add_ary,int *mul_ary) 19 { 20 add_ary[i]=add_ary[i-1]+i; () list 21 mul_ary[i]=mul_ary[i-1]*i; 22 } () quit jhchen@aho:~/c_cpp/e/eb$ (1) list 10 EB_01 22 (2) 3 list () list 7,19 7 int add_ary[5]={0}; 8 int mul_ary[5]={1}; 9 int i; 10 for(i=1;i<10;i++) 11 cal_ele(i,add_ary,mul_ary); 12 for(i=0;i<5;i++) 13 cout << "add_ary[" << i << "]=" << add_ary[i] << endl; 14 cout << " \n"; E-B-6
7 Linux GDB B 15 for(i=0;i<5;i++) 16 cout << "mul_ary[" << i << "]=" << mul_ary[i] << endl; 17 } 18 void cal_ele(int i,int *add_ary,int *mul_ary) 19 { () quit jhchen@aho:~/c_cpp/e/eb$ 7~19 list 7,19 run run () run Starting program: /root/c_cpp/e/eb/eb_01 add_ary[0]=120 add_ary[1]=720 add_ary[2]=5040 add_ary[3]=40320 add_ary[4]= mul_ary[0]=1 mul_ary[1]=1 mul_ary[2]=2 mul_ary[3]=6 mul_ary[4]=24 Program received signal SIGSEGV, Segmentation fault. 0x in?? () () quit A debugging session is active. Do you still want to close the debugger?(y or n) y E-B-7
8 run run EB_01 Ctrl + C shell Linux Shell GDB GDB Linux Shell shell Linux Shell () shell jhchen@aho:~/c_cpp/e/eb$ ls EB_01 EB_01.cpp EB_01_1.cpp EB_02.cpp jhchen@aho:~/c_cpp/e/eb$ exit exit () quit jhchen@aho:~/c_cpp/e/eb$ shell Linux Shell GDB GDB shell exit GDB quit shell shell linux Linux shell Linux Shell GDB GDB Linux Shell shell () shell ls EB_01 EB_01.cpp EB_01_1.cpp EB_02.cpp () quit jhchen@aho:~/c_cpp/e/eb$ E-B-8
9 Linux GDB B GDB shell ls Linux shell ls help help () help run Start debugged program. You may specify arguments to give it. Args may include "*", or "[...]"; they are expanded using "sh". Input and output redirection with ">", "<", or ">>" are also allowed. With no arguments, uses arguments last specified (with "run" or "set args"). To cancel previous arguments and run with no arguments, use "set args" without arguments. () quit jhchen@aho:~/c_cpp/e/eb$ GDB help run run help all all () help all ni -- Step one instruction si -- Step one instruction exactly E-B-9
10 stepping -- Specify single-stepping behavior at a tracepoint tp -- Set a tracepoint at a specified line or function or address where -- Print backtrace of all stack frames ws -- Specify single-stepping behavior at a tracepoint append binary -- Append target code/data to a raw binary file append memory -- Append contents of memory to a raw binary file append value -- Append the value of an expression to a raw binary file awatch -- Set a watchpoint for an expression break -- Set breakpoint at specified line or function catch -- Set catchpoints to catch events clear -- Clear breakpoint at specified line or function commands -- Set commands to be executed when a breakpoint is hit condition -- Specify breakpoint number N to break only if COND is true delete -- Delete some breakpoints or auto-display expressions disable -- Disable some breakpoints enable -- Enable some breakpoints hbreak -- Set a hardware assisted breakpoint ignore -- Set ignore-count of breakpoint number N to COUNT rbreak -- Set a breakpoint for all functions matching REGEXP rwatch -- Set a read watchpoint for an expression tbreak -- Set a temporary breakpoint ---Type <return> to continue, or q <return> to quit--- q Enter Enter E-B.4 E-B-10
11 Linux GDB B GDB break break break watch break () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () quit A debugging session is active. Do you still want to close the debugger?(y or n) y jhchen@aho:~/c_cpp/e/eb$ (1) break (2) run E-B-11
12 break () break cal_ele Breakpoint 1 at 0x80487e1: file EB_01.cpp, line 20. () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, cal_ele (i=1, add_ary=0xbffffaa8, mul_ary=0xbffffa94) at EB_01.cpp:20 20 add_ary[i]=add_ary[i-1]+i; () (1) break cal_ele cal_ele (2) run cal_ele (3) cal_ele mul_ary=0xbffffa94) (i=1, add_ary=0xbffffaa8, break EB_ i>=5 E-B-12
13 Linux GDB B () break 11 if i>=5 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () break 11 if i>=5 i>=5 11 () break cal_ele if i>=5 Breakpoint 1 at 0x80487e1: file EB_01.cpp, line 20. () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, cal_ele (i=5, add_ary=0xbffffaa8, mul_ary=0xbffffa94) at EB_01.cpp:20 20 add_ary[i]=add_ary[i-1]+i; () break cal_ele if i>=5 cal_ele i>=5 watch GDB watch point watch point break point GDB E-B-13
14 watch point watch point watch point watch i > 4 EB_02.cpp EB_02.cpp E/EB/EB_02.cpp /**** :EB_02.cpp : *****/ #include <iostream> using namespace std; void main(void) { int a,b,i; a=0; b=0; for(i=1;i<10;i++) { a=b+10; b=a+10; a=b+25; b=a+100; } cout << "a=" << a << "\t" << "b=" << b << endl; } a>500 break point watch point jhchen@aho:~/c_cpp/e/eb$ g++ -g EB_02.cpp -o EB_02 jhchen@aho:~/c_cpp/e/eb$ -q EB_02 () watch a > 500 No symbol "a" in current context. () break 8 Breakpoint 1 at 0x804865d: file EB_02.cpp, line 8. () run E-B-14
15 Linux GDB B Starting program: /root/c_cpp/e/eb/eb_02 Breakpoint 1, main () at EB_02.cpp:8 8 b=0; () watch a > 500 Hardware watchpoint 2: a > 500 () continue Continuing. Hardware watchpoint 2: a > 500 Old value = false New value = true main () at EB_02.cpp:12 12 b=a+10; () (1) watch a>500 GDB a a 6 (2) break point 8 break 8 GDB 8 a (3) watch a>500 GDB GDB a (4) continue GDB continue watch point 12 a> E-B.5 GDB break point watch point E-B-15
16 print whatis () break 11 if add_ary[0]>100 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () print i $1 = 6 () whatis i type = int () (1) add_ary add_ary 0,1,3,6, (120,720,5040,40320,362880) add_ary[0]>100 (2) run add_ary[0]>100 (3) i print i (4) print i GDB $1=6 i 6 (5) i whatis i GDB i i int E-B-16
17 Linux GDB B E-B.6 continue step next () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () print i $1 = 1 () continue Continuing. Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () print i $2 = 2 () next Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () print i $3 = 3 () step cal_ele (i=3, add_ary=0xbffffaa8, mul_ary=0xbffffa94) at EB_01.cpp:20 E-B-17
18 20 add_ary[i]=add_ary[i-1]+i; () step 21 mul_ary[i]=mul_ary[i-1]*i; () (1) 11 (2) run 11 (3) continue (4) next (5) step cal_ele 20 (6) step 21 E-B.7 break clear delete info breakpoints disable enable E-B-18
19 Linux GDB B info breakpoints info breakpoints () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () break 22 Breakpoint 2 at 0x : file EB_01.cpp, line 22. () break cal_ele Breakpoint 3 at 0x80487e1: file EB_01.cpp, line 20. () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 2 breakpoint keep y 0x in cal_ele(int, int *, int *) at EB_01.cpp:22 3 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () break 3 info breakpoints GDB Num Type breakpoint watchpoint Disp Enb Address What dis: keep: y: n: E-B-19
20 () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () info breakpoint Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 breakpoint already hit 1 time 2 breakpoint keep y 0x in cal_ele(int, int *, int *) at EB_01.cpp:22 3 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () 1 breakpoint already hit 1 time clear clear () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () break cal_ele Breakpoint 2 at 0x80487e1: file EB_01.cpp, line 20. () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 2 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 E-B-20
21 Linux GDB B () clear 11 Deleted breakpoint 1 () info breakpoints Num Type Disp Enb Address What 2 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () clear cal_ele Deleted breakpoint 2 () info breakpoints No breakpoints or watchpoints. () (1) clear (2) clear cal_ele cal_ele clear delete delete () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () break cal_ele Breakpoint 2 at 0x80487e1: file EB_01.cpp, line 20. () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 2 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 E-B-21
22 () delete 2 () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 () delete 2 2 break cal_ele disable disable () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () break cal_ele Breakpoint 2 at 0x80487e1: file EB_01.cpp, line 20. () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 2 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () disable 2 () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 2 breakpoint keep n 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () disable 2 2 Enb n E-B-22
23 Linux GDB B disable enable enable () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () break cal_ele Breakpoint 2 at 0x80487e1: file EB_01.cpp, line 20. () disable () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep n 0x in main at EB_01.cpp:11 2 breakpoint keep n 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () enable 2 () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep n 0x in main at EB_01.cpp:11 2 breakpoint keep y 0x080487e1 in cal_ele(int, int *, int *) at EB_01.cpp:20 () enable 2 2 Enb y E-B-23
24 enable enable once GDB enable once () break 11 Breakpoint 1 at 0x : file EB_01.cpp, line 11. () info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 0x in main at EB_01.cpp:11 () enable once 1 () info breakpoints Num Type Disp Enb Address What 1 breakpoint dis y 0x in main at EB_01.cpp:11 () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); () info breakpoints Num Type Disp Enb Address What 1 breakpoint dis n 0x in main at EB_01.cpp:11 breakpoint already hit 1 time () continue Continuing. add_ary[0]=120 add_ary[1]=720 add_ary[2]=5040 add_ary[3]=40320 E-B-24
25 Linux GDB B add_ary[4]= mul_ary[0]=1 mul_ary[1]=1 mul_ary[2]=2 mul_ary[3]=6 mul_ary[4]=24 Program received signal SIGSEGV, Segmentation fault. 0x in?? () () (1) break 11 Disp keep Enb y (2) enable once 1 1 (3) Disp dis Enb y (4) run (5) Disp dis Enb n (6) continue E-B.8 1 EB_01.cpp E-B-25
26 g++ EB_01.cpp -o EB_01 add_ary[0]=120 add_ary[1]=720 add_ary[2]=5040 add_ary[3]=40320 add_ary[4]= mul_ary[0]=1 mul_ary[1]=1 mul_ary[2]=2 mul_ary[3]=6 mul_ary[4]=24 Segment fault 2 Segment fault add_ary g++ -g EB_01.cpp -o EB_01 -g 3 GDB () 4 add_ary add_ary cal_ele 11 add_ary[0]>100 add_ary 100 () break 11 if add_ary[0]>100 Breakpoint 1 at 0x : file EB_01.cpp, line 11. E-B-26
27 Linux GDB B 5 run () run Starting program: /root/c_cpp/e/eb/eb_01 Breakpoint 1, main () at EB_01.cpp:11 11 cal_ele(i,add_ary,mul_ary); 6 11 add_arr[0] i () print i $1 = 6 7 i=6 add_arr[0] add_arr[6] mul_arr[6] GDB 5 () quit A debugging session is active. Do you still want to close the debugger?(y or n) y 8 EB_01_1.cpp /**** :EB_01_1.cpp : *****/ #include <iostream> using namespace std; void cal_ele(int i,int *add_ary,int *mul_ary); void main(void) E-B-27
28 { int add_ary[5]={0}; int mul_ary[5]={1}; int i; for(i=1;i<5;i++) cal_ele(i,add_ary,mul_ary); for(i=0;i<5;i++) cout << "add_ary[" << i << "]=" << add_ary[i] << endl; cout << " \n"; for(i=0;i<5;i++) cout << "mul_ary[" << i << "]=" << mul_ary[i] << endl; } void cal_ele(int i,int *add_ary,int *mul_ary) { add_ary[i]=add_ary[i-1]+i; mul_ary[i]=mul_ary[i-1]*i; } 9 EB_01_1.cpp Segment fault jhchen@aho:~/c_cpp/e/eb$ g++ EB_01_1.cpp -o EB_01_1 jhchen@aho:~/c_cpp/e/eb$./eb_01_1 add_ary[0]=0 add_ary[1]=1 add_ary[2]=3 add_ary[3]=6 add_ary[4]= mul_ary[0]=1 mul_ary[1]=1 mul_ary[2]=2 mul_ary[3]=6 mul_ary[4]=24 E-B-28
Program Design: Using the Debugger
rogram Design, February 2, 2004 1 Program Design: Using the Debugger A debugger is an alternative to putting print (printf in C) statements in your program, recompiling and trying to find out what values
More informationGDB QUICK REFERENCE GDB Version 4
GDB QUICK REFERENCE GDB Version 4 Essential Commands gdb program [core] debug program [using coredump core] b [file:]function run [arglist] bt p expr c n s set breakpoint at function [in file] start your
More informationECE/ME/EMA/CS 759 High Performance Computing for Engineering Applications
ECE/ME/EMA/CS 759 High Performance Computing for Engineering Applications Elements of Program Debugging Dan Negrut, 2017 ECE/ME/EMA/CS 759 UW-Madison Debugging on Euler [with gdb] Slides on gdb include
More informationUsing gdb to find the point of failure
gdb 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 g++, this is accomplished using the -g option,
More informationThe Dynamic Debugger gdb
Introduction The Dynamic Debugger gdb This handout introduces the basics of using gdb, a very powerful dynamic debugging tool. No-one always writes programs that execute perfectly every time, and while
More informationDebug for GDB Users. Action Description Debug GDB $debug <program> <args> >create <program> <args>
Page 1 of 5 Debug for GDB Users Basic Control To be useful, a debugger must be capable of basic process control. This functionally allows the user to create a debugging session and instruct the process
More informationCSE 410: Systems Programming
CSE 410: Systems Programming Recitation 4: Introduction to gdb Introduction The GNU Debugger, or gdb, is a powerful symbolic debugger. Symbolic debuggers are available for many languages and platforms,
More informationGDB 1 GDB 2 GDB. Fortran Pascal GDB 4. hoge.c. Fig. 1. calc.c. Fig GDB. GDB Debian. # apt-get install gdb
2003 advanced seminar Intelligent Systems Design Lab. 1 GDB 2003 3 31 : GDB GDB GDB 1 GDB GDB ( ) Free Software Foundation(FSF) GDB 5.3 C,C++ 1 Fortran Pascal GDB 4 GDB 2 GDB Fig. 1 hoge.c calc.c GDB Fig.
More informationLab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them.
Lab 8 Each lab will begin with a recap of last lab and a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs
More informationExercise Session 6 Computer Architecture and Systems Programming
Systems Group Department of Computer Science ETH Zürich Exercise Session 6 Computer Architecture and Systems Programming Herbstsemester 2016 Agenda GDB Outlook on assignment 6 GDB The GNU Debugger 3 Debugging..
More information1. Allowed you to see the value of one or more variables, or 2. Indicated where you were in the execution of a program
CS0449 GDB Lab What is a debugger? A debugger is a program that helps you find logical mistakes in your programs by running them in a controlled way. Undoubtedly by this point in your programming life,
More informationCMPSC 311- Introduction to Systems Programming Module: Debugging
CMPSC 311- Introduction to Systems Programming Module: Debugging Professor Patrick McDaniel Fall 2016 Debugging Often the most complicated and time-consuming part of developing a program is debugging.
More informationCMPSC 311- Introduction to Systems Programming Module: Debugging
CMPSC 311- Introduction to Systems Programming Module: Debugging Professor Patrick McDaniel Fall 2014 Debugging Often the most complicated and time-consuming part of developing a program is debugging.
More informationCSC Data Structures, Fall, 2009
An example of using gdb. CSC 237 - Data Structures, Fall, 2009 Dr. Dale E. Parson, parson@kutztown.edu, http://faculty.kutztown.edu/parson Below are listings for files timesort.cxx and queueofints.h from
More informationGDB Tutorial. Young W. Lim Tue. Young W. Lim GDB Tutorial Tue 1 / 32
GDB Tutorial Young W. Lim 2017-02-14 Tue Young W. Lim GDB Tutorial 2017-02-14 Tue 1 / 32 Outline 1 Introduction Young W. Lim GDB Tutorial 2017-02-14 Tue 2 / 32 Based on "Self-service Linux: Mastering the
More informationData and File Structures Laboratory
Tools: GDB, Valgrind Assistant Professor Machine Intelligence Unit Indian Statistical Institute, Kolkata August, 2018 1 GDB 2 Valgrind A programmer s experience Case I int x = 10, y = 25; x = x++ + y++;
More informationUNIX Makefile. C Project Library Distribution and Installation.
UNIX Makefile C Project Library Distribution and Installation. Tarballs Most non-package software is distributed in source code format. The most common format being C project libraries in compressed TAR
More informationARM DS-5. Using the Debugger. Copyright 2010 ARM. All rights reserved. ARM DUI 0446A (ID070310)
ARM DS-5 Using the Debugger Copyright 2010 ARM. All rights reserved. ARM DUI 0446A () ARM DS-5 Using the Debugger Copyright 2010 ARM. All rights reserved. Release Information The following changes have
More informationCode Review and Debugging (Lab 05)
Code Review and Debugging (Lab 05) Assignment Overview The aim of this lab is: do a code review to learn the Google Code style rules learn to debug your C++ programs. The purpose of a debugger is to allow
More informationLAB #8. GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:
LAB #8 Each lab will begin with a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is
More informationCS/COE 0449 term 2174 Lab 5: gdb
CS/COE 0449 term 2174 Lab 5: gdb What is a debugger? A debugger is a program that helps you find logical mistakes in your programs by running them in a controlled way. Undoubtedly by this point in your
More informationTips on Using GDB to Track Down and Stamp Out Software Bugs
Tips on Using GDB to Track Down and Stamp Out Software Bugs Brett Viren Physics Department MINOS Week In The Woods, 2005 Brett Viren (Brookhaven National Lab) Using GDB to Debug Ely 2005 1 / 34 Outline
More information1 A Brief Introduction To GDB
1 A Brief Introduction To GDB GDB, the GNU Project debugger, allows you to see what is going on inside another program while it executes or what another program was doing at the moment it crashed. GDB
More informationSimple C Program. Assembly Ouput. Using GCC to produce Assembly. Assembly produced by GCC is easy to recognize:
Simple C Program Helloworld.c Programming and Debugging Assembly under Linux slides by Alexandre Denault int main(int argc, char *argv[]) { } printf("hello World"); Programming and Debugging Assembly under
More informationARM DS-5. Debugger Command Reference. Copyright 2010 ARM. All rights reserved. ARM DUI 0452A (ID070310)
ARM DS-5 Debugger Command Reference Copyright 2010 ARM. All rights reserved. ARM DUI 0452A () ARM DS-5 Debugger Command Reference Copyright 2010 ARM. All rights reserved. Release Information The following
More informationLAB #8. Last Survey, I promise!!! Please fill out this really quick survey about paired programming and information about your declared major and CS.
LAB #8 Each lab will begin with a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is
More informationComputer Labs: Debugging
Computer Labs: Debugging 2 o MIEIC Pedro F. Souto (pfs@fe.up.pt) November 23, 2010 Bugs and Debugging Problem To err is human This is specially true when the human is a programmer :( Solution There is
More informationProgramming Tips for CS758/858
Programming Tips for CS758/858 January 28, 2016 1 Introduction The programming assignments for CS758/858 will all be done in C. If you are not very familiar with the C programming language we recommend
More informationChapter - 17 Debugging and Optimization. Practical C++ Programming Copyright 2003 O'Reilly and Associates Page 1
Chapter - 17 Debugging and Optimization Practical C++ Programming Copyright 2003 O'Reilly and Associates Page 1 Debugging Techniques Divide and conquer Debug only code Debug Command Line Switch Note: Use
More informationUsing the Debugger. Michael Jantz Dr. Prasad Kulkarni
Using the Debugger Michael Jantz Dr. Prasad Kulkarni 1 Debugger What is it a powerful tool that supports examination of your program during execution. Idea behind debugging programs. Creates additional
More informationGDB Tutorial. Young W. Lim Thr. Young W. Lim GDB Tutorial Thr 1 / 24
GDB Tutorial Young W. Lim 2016-09-29 Thr Young W. Lim GDB Tutorial 2016-09-29 Thr 1 / 24 Outline 1 Introduction Young W. Lim GDB Tutorial 2016-09-29 Thr 2 / 24 Based on "Self-service Linux: Mastering the
More informationDS-5 ARM. Debugger Command Reference. Version 5.3. Copyright 2010 ARM. All rights reserved. ARM DUI 0452C (ID112910)
ARM DS-5 Version 5.3 Debugger Command Reference Copyright 2010 ARM. All rights reserved. ARM DUI 0452C () ARM DS-5 Debugger Command Reference Copyright 2010 ARM. All rights reserved. Release Information
More informationCSE 351. GDB Introduction
CSE 351 GDB Introduction Lab 2 Out either tonight or tomorrow Due April 27 th (you have ~12 days) Reading and understanding x86_64 assembly Debugging and disassembling programs Today: General debugging
More informationGDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial
A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program
More informationGDB Tutorial. Young W. Lim Fri. Young W. Lim GDB Tutorial Fri 1 / 24
GDB Tutorial Young W. Lim 2016-02-19 Fri Young W. Lim GDB Tutorial 2016-02-19 Fri 1 / 24 Outline 1 Introduction Young W. Lim GDB Tutorial 2016-02-19 Fri 2 / 24 Based on Self-service Linux: Mastering the
More informationProblem Set 1: Unix Commands 1
Problem Set 1: Unix Commands 1 WARNING: IF YOU DO NOT FIND THIS PROBLEM SET TRIVIAL, I WOULD NOT RECOMMEND YOU TAKE THIS OFFERING OF 300 AS YOU DO NOT POSSESS THE REQUISITE BACKGROUND TO PASS THE COURSE.
More informationTesting and Debugging C Programming and Software Tools. N.C. State Department of Computer Science
Testing and Debugging C Programming and Software Tools N.C. State Department of Computer Science Introduction Majority of software development is testing, debugging, and bug fixing The best software developers
More informationCSE 374 Programming Concepts & Tools. Brandon Myers Winter 2015 Lecture 11 gdb and Debugging (Thanks to Hal Perkins)
CSE 374 Programming Concepts & Tools Brandon Myers Winter 2015 Lecture 11 gdb and Debugging (Thanks to Hal Perkins) Hacker tool of the week (tags) Problem: I want to find the definition of a function or
More informationCMPT 300. Operating Systems. Brief Intro to UNIX and C
CMPT 300 Operating Systems Brief Intro to UNIX and C Outline Welcome Review Questions UNIX basics and Vi editor Using SSH to remote access Lab2(4214) Compiling a C Program Makefile Basic C/C++ programming
More informationIntroduction to GDB. Lezione 9 (taken from Owen HSU material)
Introduction to GDB Lezione 9 (taken from Owen HSU material) Outline What's GDB? Why GDB? Basic GDB Commands Starting up GDB Examples What's GDB? GNU Debugger A text debugger for several language, including
More informationRed Hat Developer Tools
Red Hat Developer Tools 2018.2 Using Clang and LLVM Toolset Installing and Using Clang and LLVM Toolset Last Updated: 2018-04-26 Red Hat Developer Tools 2018.2 Using Clang and LLVM Toolset Installing
More informationCSCI0330 Intro Computer Systems Doeppner. Lab 02 - Tools Lab. Due: Sunday, September 23, 2018 at 6:00 PM. 1 Introduction 0.
CSCI0330 Intro Computer Systems Doeppner Lab 02 - Tools Lab Due: Sunday, September 23, 2018 at 6:00 PM 1 Introduction 0 2 Assignment 0 3 gdb 1 3.1 Setting a Breakpoint 2 3.2 Setting a Watchpoint on Local
More informationUsing the Command Line
1 Unit 15 Debugging COMPILATION 2 3 Using the Command Line While it has a GUI interface like your Mac or Windows PC much of its power lies in its rich set of utilities that are most easily run at the command
More informationCS354 gdb Tutorial Written by Chris Feilbach
CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that
More informationRed Hat Developer Tools
Red Hat Developer Tools 2018.4 Using Clang and LLVM Toolset Installing and Using Clang and LLVM Toolset Last Updated: 2018-11-29 Red Hat Developer Tools 2018.4 Using Clang and LLVM Toolset Installing
More informationScientific Programming in C IX. Debugging
Scientific Programming in C IX. Debugging Susi Lehtola 13 November 2012 Debugging Quite often you spend an hour to write a code, and then two hours debugging why it doesn t work properly. Scientific Programming
More informationPrinceton University COS 217: Introduction to Programming Systems GDB Tutorial and Reference for x86-64 Assembly Language
Princeton University COS 217: Introduction to Programming Systems GDB Tutorial and Reference for x86-64 Assembly Language Part 1: Tutorial Motivation Suppose you're developing the power.s program. Further
More informationPrinceton University COS 217: Introduction to Programming Systems GDB Tutorial and Reference
Princeton University COS 217: Introduction to Programming Systems GDB Tutorial and Reference Part 1: Tutorial This tutorial describes how to use a minimal subset of the gdb debugger. For more information
More informationC++ for Everyone, 2e, Cay Horstmann, Copyright 2012 John Wiley and Sons, Inc. All rights reserved. Using a Debugger WE5.
Using a Debugger WE5 W o r k E D E x a m p l e 5.2 Using a Debugger As you have undoubtedly realized by now, computer programs rarely run perfectly the first time. At times, it can be quite frustrating
More informationdbx90: Fortran debugger March 9, 2009
dbx90: Fortran debugger March 9, 2009 1 Name dbx90 a Fortran 90/95 debugger for use with the NAG Fortran compiler. 2 Usage dbx90 [option]... executable-file 3 Description dbx90 is a Fortran 90/95 debugger
More informationPermission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on
GDB Annotations Edition 0.5 May 1994 Cygnus Support Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on
More informationSection 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2
Kaifei Chen, Luca Zuccarini January 23, 2015 Contents 1 Make 2 1.1 Motivation............................................ 2 1.2 How................................................ 2 2 Git 2 2.1 Learn by
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 STEPS OF GCC STEPS file.c Preprocessor Compiler file1.o file2.o Assembler Linker executable file PREPROCESSOR PREPROCESSOR The C preprocessor is a macro processor that is
More informationBinghamton University. CS-220 Spring C Debugging Basics. No relevant text
C Debugging Basics No relevant text First Computer Bug 2 The printf debugger Insert printf statements to print debug information Build/Run Modify to print new information Advantages Simple Complete Available
More informationCS 270 Systems Programming. Debugging Tools. CS 270: Systems Programming. Instructor: Raphael Finkel
Debugging Tools CS 270: Systems Programming Instructor: Raphael Finkel Gdb: The Gnu debugger It runs on most computers and operating systems. It allows you to examine a running executable program. It does
More informationLab: Supplying Inputs to Programs
Steven Zeil May 25, 2013 Contents 1 Running the Program 2 2 Supplying Standard Input 4 3 Command Line Parameters 4 1 In this lab, we will look at some of the different ways that basic I/O information can
More informationEE 355 Lab 3 - Algorithms & Control Structures
1 Introduction In this lab you will gain experience writing C/C++ programs that utilize loops and conditional structures. This assignment should be performed INDIVIDUALLY. This is a peer evaluated lab
More informationCSE 351 Section 4 GDB and x86-64 Assembly Hi there! Welcome back to section, we re happy that you re here
CSE 351 Section 4 GDB and x86-64 Assembly Hi there! Welcome back to section, we re happy that you re here x86-64 Assembly Language Assembly language is a human-readable representation of machine code instructions
More informationGDB cheatsheet - page 1
Running # gdb [core dump] Start GDB (with optional core dump). # gdb --args Start GDB and pass arguments # gdb --pid Start GDB and attach to process. set args
More informationIntroduction to Programming
Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines
More informationomp critical #pragma omp critical x = x + 1; !$OMP CRITICAL X = X + 1!$OMP END CRITICAL
omp critical The code inside a CRITICAL region is executed by only one thread at a time. The order is not specified. This means that if a thread is currently executing inside a CRITICAL region and another
More informationDS-5 ARM. Debugger Command Reference. Version Copyright ARM. All rights reserved. ARM DUI 0452P (ID091713)
ARM DS-5 Version 5.16 Debugger Command Reference Copyright 2010-2013 ARM. All rights reserved. ARM DUI 0452P () ARM DS-5 Debugger Command Reference Copyright 2010-2013 ARM. All rights reserved. Release
More informationCollect Linux Hardware Trace for ARMv8 User Space and Kernel Space Applications
NXP Semiconductors Document Number: AN5129 Application Note Rev. 11.3.0, 12/2017 Collect Linux Hardware Trace for ARMv8 User Space and Kernel Space Applications 1 Introduction This document describes the
More informationJordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A
Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A Name: ID#: Section #: Day & Time: Instructor: Answer all questions as indicated. Closed book/closed
More informationUsing the GNU Debugger
Using the GNU Debugger 6.828 Fall 2016 September 14, 2016 6.828 Fall 2016 Using the GNU Debugger September 14, 2016 1 / 14 Homework solution 6.828 Fall 2016 Using the GNU Debugger September 14, 2016 2
More informationUsing the GNU Debugger
Using the GNU Debugger 6.828 Fall 2014 September 10, 2014 6.828 Fall 2014 Using the GNU Debugger September 10, 2014 1 / 14 Homework solution From bootasm.s: # Set up the stack pointer and call into C.
More informationReview: Expressions, Variables, Loops, and more.
Review: Expressions, Variables, Loops, and more. 1 An Expression Evaluator Example [2] Wk02.1 Slide 1 2 Case Study : Parsing PostFix Expressions What is an expression? A series of symbols that return some
More information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More informationProgramming Studio #9 ECE 190
Programming Studio #9 ECE 190 Programming Studio #9 Concepts: Functions review 2D Arrays GDB Announcements EXAM 3 CONFLICT REQUESTS, ON COMPASS, DUE THIS MONDAY 5PM. NO EXTENSIONS, NO EXCEPTIONS. Functions
More informationdo { statements } while (condition);
Topic 4 1. The while loop 2. Problem solving: hand-tracing 3. The for loop 4. The do loop 5. Processing input 6. Problem solving: storyboards 7. Common loop algorithms 8. Nested loops 9. Problem solving:
More informationUnderstanding the Program Run
0/45 Understanding the Program Run Andreas Zeller Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken Isolating Failure Causes 1/45 So far, we have seen how to isolate causes in the environment
More informationUsing the Xcode Debugger
g Using the Xcode Debugger J Objectives In this appendix you ll: Set breakpoints and run a program in the debugger. Use the Continue program execution command to continue execution. Use the Auto window
More informationIntro to Segmentation Fault Handling in Linux. By Khanh Ngo-Duy
Intro to Segmentation Fault Handling in Linux By Khanh Ngo-Duy Khanhnd@elarion.com Seminar What is Segmentation Fault (Segfault) Examples and Screenshots Tips to get Segfault information What is Segmentation
More informationCS3210: Tutorial Session 2. Kyuhong Park-- edited by Kyle Harrigan
1 CS3210: Tutorial Session 2 Kyuhong Park-- edited by Kyle Harrigan 2 Overview Goal: Understand C and GDB Part1: C Programming Part2: GDB Part3: In-class Exercises 3 Revised Tutorial Format Recommended
More informationCS356: Discussion #5 Debugging with GDB. Marco Paolieri
CS356: Discussion #5 Debugging with GDB Marco Paolieri (paolieri@usc.edu) Schedule: Exams and Assignments Week 1: Binary Representation HW0. Week 2: Integer Operations Week 3: Floating-Point Operations
More informationIDE: Integrated Development Environment
Name: Student ID: Lab Instructor: Borja Sotomayor Do not write in this area 1 2 3 TOTAL Maximum possible points: 30 One of the goals of this lab is to introduce the Eclipse IDE, a software environment
More informationThe Linux Programming Environment. Computer Science Department Texas State University
The Linux Programming Environment Computer Science Department Texas State University TUTORIAL REQUIREMENTS... 1 INTRODUCTION... 1 COMPILATION... 1 COMMAND LINE COMPILATION... 1 Basic Compilation... 2 The
More informationDisassemble the machine code present in any memory region. Single step through each assembly language instruction in the Nios II application.
Nios II Debug Client This tutorial presents an introduction to the Nios II Debug Client, which is used to compile, assemble, download and debug programs for Altera s Nios II processor. This tutorial presents
More informationChapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved.
Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the
More informationChapter 17 - Notes Recursion
Chapter 17 - Notes Recursion I. Recursive Definitions A. Recursion: The process of solving a problem by reducing it to smaller versions of itself. B. Recursive Function: A function that calls itself. C.
More informationReading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary
Reading from and Writing to Files Section 3.12 & 13.1 & 13.5 11/3/08 CS150 Introduction to Computer Science 1 1 Files (3.12) Data stored in variables is temporary We will learn how to write programs that
More informationDEBUGGING: OBSERVING AND TRACKING
DEBUGGING: OBSERVING AND TRACKING WS 2017/2018 Martina Seidl Institute for Formal Models and Verification Observing a Program deduction tells what might happen observation tells what is actually happening
More informationSource level debugging. October 18, 2016
Source level debugging October 18, 2016 Source level debugging Source debugging is a nice tool for debugging execution problems; it can be particularly useful when working with crashed programs that leave
More informationDebugging. ICS312 Machine-Level and Systems Programming. Henri Casanova
Debugging ICS312 Machine-Level and Systems Programming Henri Casanova (henric@hawaii.edu) Debugging Even when written in high-level languages, programs have bugs Recall the thought that when moving away
More informationDebugging uclinux on Coldfire
Debugging uclinux on Coldfire By David Braendler davidb@emsea-systems.com What is uclinux? uclinux is a version of Linux for CPUs without virtual memory or an MMU (Memory Management Unit) and is typically
More informationCSE au Midterm Exam Nov. 2, 2018 Sample Solution
Question 1. (16 points) Build tools and make. We re building a C++ software back-end prototype for a new food web site. So far, we ve got the following source files with the code for two main programs
More informationGDB Tutorial. University of Waterloo
GDB Tutorial University of Waterloo Version 1.0 Caroline Kierstead and Peter A. Buhr c 2002 April 1, 2002 Permission is granted to make copies for personal or educational use 2 GDB Tutorial Contents 1
More informationToday s presentation. Git gdb Project 1
CS3214: Project 1 Today s presentation Git gdb Project 1 Project 1 Due Monday, February 20 at 11:59 PM Office hours are on course website Check Piazza for updates Git Version Control System Keep snapshots
More informationName SECTION: 12:45 2:20. True or False (12 Points)
Name SECION: 12:45 2:20 rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables
More informationgdbtui - Linux Command
tui tui - Linux Command -batch -cd= dir -f -b bps -tty= dev -s sym -e prog -se prog -c core cmds -d dir prog core procid]] SYNOPSIS -help-nx-q DESCRIPTION The purpose of a debugger such as GDB is to allow
More informationJackson State University Department of Computer Science CSC / Advanced Information Security Spring 2013 Lab Project # 5
Jackson State University Department of Computer Science CSC 439-01/539-02 Advanced Information Security Spring 2013 Lab Project # 5 Use of GNU Debugger (GDB) for Reverse Engineering of C Programs in a
More informationDebugging. John Lockman Texas Advanced Computing Center
Debugging John Lockman Texas Advanced Computing Center Debugging Outline GDB Basic use Attaching to a running job DDT Identify MPI problems using Message Queues Catch memory errors PTP For the extremely
More informationCS101 Linux Shell Handout
CS101 Linux Shell Handout Introduction This handout is meant to be used as a quick reference to get a beginner level hands on experience to using Linux based systems. We prepared this handout assuming
More informationALD Assembly Language Debugger Copyright (C) Patrick Alken
ALD Assembly Language Debugger 0.1.7 Copyright (C) 2000-2004 Patrick Alken To run type ald help Commands may be abbreviated. If a blank command is entered, the last command is repeated. Type `help '
More informationint n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;
Debugging Some have said that any monkey can write a program the hard part is debugging it. While this is somewhat oversimplifying the difficult process of writing a program, it is sometimes more time
More informationWhy Is Repetition Needed?
Why Is Repetition Needed? Repetition allows efficient use of variables. It lets you process many values using a small number of variables. For example, to add five numbers: Inefficient way: Declare a variable
More informationDebugging. P.Dagna, M.Cremonesi. May 2015
Debugging P.Dagna, M.Cremonesi May 2015 Introduction Oneofthemostwidelyusedmethodstofindoutthereasonofa strange behavior in a program is the insertion of printf or write statements in the supposed critical
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,
More informationUsing a debugger. Segmentation fault? GDB to the rescue!
Using a debugger Segmentation fault? GDB to the rescue! But first... Let's talk about the quiz Let's talk about the previous homework assignment Let's talk about the current homework assignment K findkey(v
More information