a.k.a how we test Your code

Slides:



Advertisements
Similar presentations
Technotronics GCECT '091 Decode C This is a C Programming event, where you will be given problems to solve using C only. You will be given a Linux system.
Advertisements

Recitation By yzhuang, sseshadr. Agenda Debugging practices – GDB – Valgrind – Strace Errors and Wrappers – System call return values and wrappers – Uninitialization.
Functions and scope Confidence In scope Reference: K&K textbook, Chapter 4.
DEBUGGING IN THE REAL WORLD : Recitation 4.
1 Pointers (Walls & Mirrors - Beginning of Chapter 4)
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.
CSE 303 Lecture 13a Debugging C programs
CS 225 Lab #2 - Pointers, Copy Constructors, Destructors, and DDD.
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.
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.
August 7, 2003Serguei A. Mokhov, 1 gcc Tutorial COMP 444/5201 Revision 1.1 Date: January 25, 2004.
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.
C Tutorial Session #2 Type conversions More on looping Common errors Control statements Pointers and Arrays C Pre-processor Makefile Debugging.
Addresses in Memory When a variable is declared, enough memory to hold a value of that type is allocated for it at an unused memory location. This is.
CS 241 Section Week #2 9/9/10. 2 Topics This Section MP1 issues MP2 overview Process creation using fork()‏ Debugging tools: valgrind, gdb.
C++ Data Types Structured array struct union class Address pointer reference Simple IntegralFloating char short int long enum float double long double.
Data Structures Using C++ 2E Chapter 3 Pointers. Data Structures Using C++ 2E2 Objectives Learn about the pointer data type and pointer variables Explore.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes.
Agenda Attack Lab C Exercises C Conventions C Debugging
CSCI Rational Purify 1 Rational Purify Overview Michel Izygon - Jim Helm.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Jonas M. Larsen Memory debugging Recipe profiling.
1 Splint: A Static Memory Leakage tool Presented By: Krishna Balasubramanian.
Debugging. Outline Announcements: –HW II due Fridayl db.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Hank Childs, University of Oregon April 15th, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / /
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 10 – C: the heap and manual memory management.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
1 Recall that... char str [ 8 ]; str is the base address of the array. We say str is a pointer because its value is an address. It is a pointer constant.
Debugging: Tips and Tools Also, Aloha Recitation Wednesday, February 7th, 2007.
CMSC 104, Version 8/061L14AssignmentOps.ppt Assignment Operators Topics Increment and Decrement Operators Assignment Operators Debugging Tips Reading Section.
CSE 333 – SECTION 2 Memory Management. Questions, Comments, Concerns Do you have any? Exercises going ok? Lectures make sense? Homework 1 – START EARLY!
Recap Resizing the Vector Push_back function Parameters passing Mechanism Primitive Arrays of Constants Multidimensional Arrays The Standard Library string.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Code improvement: Coverity static analysis Valgrind dynamic analysis GABRIELE COSMO CERN, EP/SFT.
Dynamic Instrumentation - Valgrind  Developed by Julian Seward at/around Cambridge University,UK  Google-O'Reilly Open Source Award for "Best Toolmaker"
NULL pointer assignment error- AGNEL ANTO. What is NULL pointer assignment error ? My program comes up with the message 'Null pointer assignment' after.
Instructions for test_function
CMSC 341 Lecture 2 – Dynamic Memory and Pointers (Review)
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
Debugging Memory Issues
CSE 374 Programming Concepts & Tools
Recitation 6: C Review 30 Sept 2016.
CSE 374 Programming Concepts & Tools
Software Design and Development
Checking Memory Management
C Basics.
gdb gdb is the GNU debugger on our CS machines.
Lab: ssh, scp, gdb, valgrind
Operating System Discussion Section.
Recitation: C Review TA’s 19 Feb 2018.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
Dynamic Instrumentation - Valgrind
Lab: ssh, scp, gdb, valgrind
ניפוי שגיאות - Debugging
Common C Programming Errors, GDB Debugging
Chapter 15 Pointers, Dynamic Data, and Reference Types
Local Variables, Global Variables and Variable Scope
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
a.k.a how we test Your code
C Programming Lecture-8 Pointers and Memory Management
CISC 361 Operating Systems Midterm Review
CSE 303 Concepts and Tools for Software Development
Chapter 15 Debugging.
Debugging.
Makefiles, GDB, Valgrind
Presentation transcript:

a.k.a how we test Your code Debugging a.k.a how we test Your code

Some methods Making the compiler (gcc) “furious” Valgrind gdb Tools provided by the IDE 2017

gcc -Wall – show ‘most’ of the default compiler warnings -Wextra – show even more of the default compiler warnings -pedantic – strict ISO C -Wunreachable-code – code, that will never be run -Wfloat-equal – floating point comparisons -Wshadow – two variables with the same name in the same scope -Wconversion – possible errors due to different types -Wmissing-declaration – no previous declaration of function prototype -g – debugging symbols e.t.c. 2017

gdb It can run code line by line You can observe the values of your variables See the last lines executed before program crash Manually assigning values to variables e.t.c. More on the subject: man gdb internet 2017

Valgrind – identifying memory issues For now: Using uninitialized variables Reading from memory locations not belonging to you Writing to memory locations not belonging to you Using NULL pointers Using invalid pointers In the future: Memory leaks (lost pointers) Unreleased resources Recurring frees to resources e.t.c 2017

How to use it? Additional flag to compilation -g (same for gdb) gcc -g -o myprogram codefile.c -Wall -g adds debugging symbols to the compiled binary so that you can for example find the line number that causes the error To run it valgrind --tool=memcheck --leak-check=full ./myprogram 2017