The Corner of Coding - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

The Corner of Coding

Description:

... debugger ... You can attack debugger to arbitrary processes. debugging. Symbols: the ... environment: working directory, attach debugger or not. I much ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 13
Provided by: law82
Category:

less

Transcript and Presenter's Notes

Title: The Corner of Coding


1
The Corner of Coding
  • con su amigo
  • Luke Wagner

2
Debug, _DEBUG, and debugging
  • Debugging shouldnt be a crutch, but sometimes
    its majorly useful.
  • Debug means several things in different
    contexts, important to know what they are

3
The Preprocessor
  • Conditionally compiled code for extra checking at
    a performance cost
  • ifdef _DEBUG
  • if (expensive_validity_check())
  • endif
  • Traditionally, _DEBUG
  • You can have pass global defines to the
    compiler cl.exe /D _DEBUG test.cpp

4
The Preprocessor
  • Great for checking things you never ever ever
    expect to go wrong, everywhere.
  • ifdef _DEBUG
  • define assert(exp) / do a check here /
  • else
  • define assert(exp) __noop
  • endif
  • However, not a replacement for real error handling

5
debugging
  • Process that uses special OS features to help the
    programmer
  • Attaching a debugger for
  • stepping, call stack, checking values,
    breakpoints, first/second chance exceptions, etc
  • You can attack debugger to arbitrary processes

6
debugging
  • Symbols the keys to the kingdom

Cowspeed 100000Cowangry true
Debugger
01100100100100100111001100101010010101010100101010
010010
Debugged process
Symbols
struct Cow int speed bool angry
double yipe
int foo
7
debugging with Visual Studio
  • Compilation produces .exe and .pdb (Program
    Debug Database)
  • To debug AND use symbols
  • Same absolute location
  • Same directory
  • A bunch of other places

8
debugging with Visual Studio
  • Most important trick ever
  • Tools?Options?Debugger?Native?Load DLL Exports
    true
  • Solution Proprties?Common Properties?Debug Symbol
    Files
  • Add this path
  • srvc\some_pathhttp//msdl.microsoft.com/downloa
    d/symbols
  • See symbols loaded (or not) with these on or off
  • Debug?Windows?Modules
  • Public symbols for C/C runtime Win32

9
Lastly
  • Build settings (Debug or Release are common
    defaults)
  • Optimization (makes symbols quirky, possibly
    expose optimizer bugs (rarely))
  • Which libraries you link to
  • Language features settings
  • Test environment working directory, attach
    debugger or not

10
I much prefer to assumpt()
define assumpt(exp) assert(true)
11
Youre not serious are you?
12
  • What will happen next??
  • Will Danny eat the cute little puppy?!!
  • Find out next week
Write a Comment
User Comments (0)
About PowerShow.com