Debugging with Clion and GDB

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Guidelines for working with Microsoft Visual Studio.Net.
Visual Basic Debugging Tools Appendix D 6/27/20151Dr. Monther Aldwairi.
Guidelines for working with Microsoft Visual Studio 6.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
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.
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.
Using a Debugger. SWC What is ”debugging”? An error in a computer program is often called a ”bug”… …so, to ”debug” is to find and get rid of errors in.
Debugging Projects Using C++.NET Click with the mouse button to control the flow of the presentation.
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.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
VB – Debugging Tools Appendix D. Why do we need debugging? Every program has errors, and the process of finding these errors is debugging Types of errors.
ENEE150 – 0102 ANDREW GOFFIN Testing and Debugging.
Debugging and Profiling With some help from Software Carpentry resources.
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
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.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Copyright © 2004 – 2013 Curt Hill Java Debugging In Eclipse.
NETBEANS DEBUGGER.  To create a breakpoint place the cursor at the desired location.  Go to the Run -> toogle line Breakpoint or Ctrl +F8. It creates.
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.
COP 3530 Spring2012 Data Structures & Algorithms Discussion Session Week 2.
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
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.
An introduction to the debugger And jGrasp editor-syncrasies (ideosyncrasies)
Netbeans QuickStart. Creating a project File->New Project –For now you want General->Java Application –Then fill in the project details.
HP-SEE Debugging with GDB Vladimir Slavnic Research Assistant SCL, Institute of Physics Belgrade The HP-SEE initiative.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
1 Using an Integrated Development Environment. Integrated Development Environments An Integrated Development Environment, or IDE, permits you to edit,
Dale Roberts Debugger Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and Information Science, School.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
DEBUG.
Computer System Laboratory
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Microcontroller Applications
CSE 374 Programming Concepts & Tools
Testing and Debugging.
Software Tools Recitation 1
Testing Key Revision Points.
Lab: ssh, scp, gdb, valgrind
Barb Ericson Georgia Institute of Technology Dec 2009
COMP 2710 Software Construction Introduction to GDB
Debuggers.
Test Automation For Web-Based Applications
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Tonga Institute of Higher Education
Getting Started: Developing Code with Cloud9
Debugging at Scale.
Using a Debugger 1-Jan-19.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
When your program crashes
Testing, debugging, and using support libraries
CSC235 - Visual Studio Tutorial
Debuggers and Debugging
Our Environment We will exercise on Microsoft Visual C++ v.6
Debugging Visual Basic Programs
IDE’s and Debugging.
jGRASP editor-syncrasies (idiosyncrasies)
CSE 303 Concepts and Tools for Software Development
Debugging.
By Hugues Leger / Intro to GDB debugger By Hugues Leger / 11/16/2019.
Presentation transcript:

Debugging with Clion and GDB EE312 – Week 03

Necessity of debugging Codes usually have bugs and it’s hard to get them at the first try Non-trivial bugs are hard to find by reading code No need to ask TA “why this weird error happens”

Common Debugging Techniques Embedded printing statements in the code to examine values and behavior Not flexible, hard to examine multiple values at the same time Have to edit and rebuild the project every time to test Using a debugger Can go through every single line and examine every value of interest Faster and more handy with modern debuggers.

Buggy Program arrayMax.c Compile the program with –g flag for debug information gcc –std=c99 –g –o arrayMax arrayMax.c Execute ./arrayMax “TA that’s segmentation fault”, “weird error”, “I’m clueless!” http://users.ece.utexas.edu/~meberlein/ee312/CCode/arrayMax.c

GDB – the ultimate debugger Start gdb on the executable file: gdb arrayMax List your program: (gdb) list Set breakpoint: (gdb) break <linenumber> Set breakpoint: (gdb) break <filename>:<function name> Run debugger: (gdb) run Step in: (gdb) step Step through: (gdb) next Continue: (gdb) continue GDB commands: list : list the content of the program. Shortcut: l list <line>: list lines centered around <line> list <first>,<last>: list lines from <first> to <last> (first or last can be empty as well) list +,-: list lines after or before those just listed break: set breakpoint. Shortcut: b run: start running debugger with the program. Before run, nothing of the program is executed. step: step into a function to examine what happens inside. Shortcut: s next: step over a command/function call. The function call details will be skipped. Shortcut: n continue: run the program till the next breakpoint. Shortcut: c

GDB – the ultimate debugger Print value of x: print x Pause when the value of x changes: watch x Print an array arr with length len: p *arr@len Print a char array buffer: x/s buffer If you ever need help with a command: help [command]

More Buggy Programs factorial.c Try using gdb to debug the factorial program sum.c Create a new CLion project called sum Either copy the code from sum.c into main.c or move the file into your project directory and add it to the CMakeLists.txt https://utexas.instructure.com/files/43080319/download?download_frd=1 (factorial.c) https://utexas.instructure.com/files/43079352/download?download_frd=1 (sum.c)

Clion – IDE debugger Click on line number panel to set breakpoints. Shortcut (Windows): Ctrl-F8

Clion – IDE debugger Run program in debug mode Shortcut (Windows): Shift-F9

Clion – IDE debugger Examine variable values in debug mode Step Over : F8 Step In: F7 Continue: F9 It also has GDB