SlideShare uma empresa Scribd logo
1 de 44
Debugging Sucks – We Make
it Suck Less
Alon Fliess
Chief Software Architect
alonf@oz-code.com
http://alonfliess.me
http://oz-code.com
About Me
• Alon Fliess:
• Chief Software Architect & Co-Founder at OzCode.
• More than 30 years of hands-on experience
• Many of them in hunting nasty bugs
• Microsoft Regional Director & Microsoft MVP
• Renowned speaker at both international and domestic events
3
How Much Does a Software Bug Cost?
NASA’s Mars Climate
Orbiter
$125 Millions
Ariane 5 Flight 501
$370 Millions
The Mariner 1 Spacecraft
$18 Millions
Heathrow Terminal 5
Opening
$125 Millions
Pentium FDIV bug
$475 Millions
Knight’s $440 Million
Error
$440 Millions
Microsoft Azure DevOps Bounty Program
Agenda
• Introduction
• Debugging – Overview
• The debugging process
• Debugger internals
• Controlling the debugger – A magical debugging show
• The future of debugging
• Summary
6
Wikipedia
• “Debugging is the process of finding and resolving bugs or defects
that prevent correct operation of computer software or a system”
• The terms "bug" and "debugging" are popularly attributed to Admiral
Grace Hopper in the 1940s
• However the term is much older:
• Thomas Edison wrote the following words in a letter to an associate in 1878:
• “It has been just so in all of my inventions. The first step is an intuition, and comes with a
burst, then difficulties arise — this thing gives out and [it is] then that
"Bugs" — as such little faults and difficulties are called — show themselves and months
of intense watching, study and labor are requisite before commercial success or failure is
certainly reached”
12/1/2014 7
The Art of Debugging
• Debugging requires:
• Deep understanding of your code
• Deep understanding of your system, environment and tools
• Abstraction layers are great for development, however
when debugging you need to dig under the hood
• Technician senses and techniques
• Gathering evidence
• Analyzing
• Trying
• Hacking
• Patching 8
The Debugging Process Overview
•Understand the context & the requirements
• Distinguish bugs and features (By Design)
•Reproduce the bug, make it fail
•Simplify the test case
•Understand the error
•Check the obvious, check the plug
• Can’t write to a read only file
The Debugging Process Overview
•Separate facts from interpretation
• Wrong interpretation leads to a dead-end
•Divide and conquer
• Trap the bug in the corner
•Use the right tool for the bug & the context
•Isolate changes - do one change at a time
• See its effect (fact), draw a conclusion (interpretation)
The Debugging Process Overview
•Consult others
•Consult your Co-workers
•Get a fresh view
•Use Google, Bing, or any web search engine
•Use Twitter, Stack Overflow or any other social
media
•Search for known bugs and issues
The Debugging Process Overview
•Bugs do not disappear
•If you didn’t fix it, it is not fixed
•If you can’t reproduce it anymore, look for what
you or others have changed
•Use Source Control
• You can create a branch for the debugging process
Fixing problems
that shouldn’t be there
Instead of creating value
for our customers
Debugging is a waste of time
Restarting debug run
• After code change
• When we’ve missed crucial information
Manually stepping through the code line-by-line
Breaking on irrelevant spots
How we waste time during debugging
Summary
•Like any other development skill, debugging is a skill
that you need to learn
•Real bugs are hard to find and solve
•Be organized, use a debugging process
•Use the right tools, consult with other people,
document the process & tell the world
.NET Debugger Options
• Visual Studio
• With OzCode!
• MDbg.exe - .NET Command line Debugger
• WinDbg + SOS.DLL|SOSEX.DLL
16
Debugger Anatomy
Wait for
debug event
Handle
debug event
Continue
debug event
Start the debuggee
or attach to it
Enter main
debugger loop
Debugger Main Loop
1. …
2. for(;;)
3. {
4. WaitForDebugEvent(DebugEv, INFINITE);
5. switch (DebugEv->dwDebugEventCode)
6. {
7. case EXCEPTION_DEBUG_EVENT:
8. switch(DebugEv->u.Exception.ExceptionRecord.
9. ExceptionCode)
10. {
11. case EXCEPTION_ACCESS_VIOLATION:
12. case …
13. }
Debugger Main Loop
1. break;
2. case CREATE_THREAD_DEBUG_EVENT:
3. dwContinueStatus =
4. OnCreateThreadDebugEvent(DebugEv);
5. break;
6. …
7. }
8. // Resume executing the thread that reported the
9. debugging event.
10. ContinueDebugEvent(DebugEv->dwProcessId,
11. DebugEv->dwThreadId,
12. dwContinueStatus);
13. }}
Demo
.NET Debugger Anatomy
• The .NET CLR wrap the native debugging API and provides a COM interface for the CLR
debugger:
• There are other debugging interfaces
20
ICorDebug Methods Description
ICorDebug::CanLaunchOrAttach Determines whether launching a new process or attaching is possible
ICorDebug::CreateProcess Launches a process and its primary thread under the control of the debugger
ICorDebug::DebugActiveProcess Attaches the debugger to an existing process.
ICorDebug::EnumerateProcesses Gets an enumerator for the processes that are being debugged
ICorDebug::GetProcess Returns the ICorDebugProcess object with the given process ID
ICorDebug::Initialize Initializes the ICorDebug object.
ICorDebug::SetManagedHandler Specifies the event handler object for managed events
ICorDebug::SetUnmanagedHandler Specifies the event handler object for unmanaged events
ICorDebug::Terminate Terminates the ICorDebug object.
Concord – The Visual Studio Debug Engine
• Documentation and Samples are
available online
• Use it to extend the Visual Studio
debugger
• Use it to develop your programming
language debugger
21
Controlling the Debugger
• There are two types of (human) debuggers:
• The: I am too tired to think  let the debugger lead and control
• The “everything is under control type”
22
Controlling the Debugger – The Execution Context
• A debuggee stops its execution when the debugger receives
a debug event
• New thread, load library, exception or special exception such as
breakpoint
• When the debuggee is paused, the debugger pauses all
other threads and the execution context points to
• The current process, current thread, current stack location, current
instruction pointer
• You can change the context in several ways
23
Controlling the Execution Context
• Using the debugger UI, you can switch between processes,
threads, and stack locations
• Within the current context of the process and thread:
• Moving the instruction pointer to
• Skip code
• Re-run code
• Setting variable values that control the execution path
• Expressions in if, switch, loop conditions
• Using Edit & Continue
24
Setting New Breakpoints
• Setting Breakpoints with Visual Studio 2015/17/19
25
Method Breakpoints
• If you type a method name (without class name)
• VS select all that matches
.NET Performance & Debugging 26
The Scientific Method
• while (still_not_fixed)
• Make it fail
• Trial and error
• Trap and isolate the bug
• Add new unit tests
• Make a hypothesis
• Collect evidence
• Prove or refine the hypothesis
• Refine the unit tests
• Fix the bug
• Run all (regression) tests
• Check-in, document 27
Identify the Bug
• Use source control and
change sets
• Divide & Conquer
• Create a simple case
• The bug is yours, unless you
find it on the Web
• In rare cases – It is other
fault
28
Demo
• Breakpoints
• Conditional
• Changing context
• Instruction Pointer
• Stack Location
• Thread
• Process
Controlling the execution context
There are some moments in life…
•After which, life is no longer the same!
• The first kiss
• Your wedding
• The first child
• The first time you saw OzCode
29
Let the Magic Begin
30
31
Demo
• Reveal
• Heads Up Display
• Magic Glance
• Search
• Breakpoints
• All Members
• Conditional
• “Property”
• Exception Trail / HUD
OzCode Main Features
Collecting Evidence
•Collect program execution data:
• Application log – need to instrument the code
• The Immediate / Command Window
• With >log
• Tracepoints
• With OzCode
• VS Watch Window / OzCode Watch Window
• VS Data Tips / OzCode Data Tips
32
33
Demo
Logging the Immediate & Command
Window – A VS Tip!
> Log "file path"
Optional Switches:
/on  Append
/off  Close file, stop logging
/overwrite  Start new log file
> open "file path"
34
Demo Export with OzCode
Tracing with Tracepoints
• Can print out any expression by surrounding with {}
• property/field/method call
• Special code can be used:
35
Tracepoint variable name Meaning
$ADDRESS Current instruction address
$CALLER Caller name of current method
$CALLSTACK The call stack at the current location
$FUNCTION Current function name
$PID Current process ID
$PNAME Current process name
$TID Current thread ID
$TNAME Current thread name
36
Demo
Trace with OzCode
• Tracepoint editor
• Tracepoint Viewer
OzCode Analysis Tools
•Finding problems in vast amount of data is hard
• You need to:
• Navigate the execution context to the right spot
• Analyze and understand LINQ queries
• Analyze and understand code execution (algorithm)
• Filter:
• The properties that are important to you
• The instances in a collection that point to the problem
• Compare object & collection state
• Save “good” state for future comparisons
• Create your own “custom expression” to surface problems
37
38
Demo
OzCode Analysis Tools
• LINQ Analysis
• Compare:
• Two objects or More
• Saved state
• Collection Filtering (next slides)
• Custom Expression (next slides)
Custom Expression Video
12/1/2014 39
OzCode Filter Collections
40
41
Demo
OzCode Analysis Tools
• Time Travel
• Live Coding
The Future of (Production) Debugging
Summary
• Debugging – Overview
• The debugging process
• Debugger internals
• Controlling the debugger – A
magical debugging show
• The future of debugging
43
Thanks!
Alon Fliess
Chief Software Architect
alonf@oz-code.com
http://alonfliess.me
http://oz-code.com

Mais conteúdo relacionado

Mais procurados

Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019
Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019
Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019Clare Macrae
 
Unit Test Your Database
Unit Test Your DatabaseUnit Test Your Database
Unit Test Your DatabaseDavid Wheeler
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesDavid Rodenas
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent codeDror Helper
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYCMike Dirolf
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy CodeAlexander Goida
 
CLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementCLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementShiny Zhu
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!Ortus Solutions, Corp
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012Yaqi Zhao
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleNoam Kfir
 
The Hunter Games: How to Find the Adversary with Event Query Language
The Hunter Games: How to Find the Adversary with Event Query LanguageThe Hunter Games: How to Find the Adversary with Event Query Language
The Hunter Games: How to Find the Adversary with Event Query LanguageRoss Wolf
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Pitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz BankowskiPitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz BankowskiAgileee
 
Static analysis as means of improving code quality
Static analysis as means of improving code quality Static analysis as means of improving code quality
Static analysis as means of improving code quality Andrey Karpov
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking frameworkPhat VU
 
C++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ LondonC++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ LondonClare Macrae
 

Mais procurados (20)

Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019
Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019
Quickly Testing Legacy Cpp Code - ACCU Cambridge 2019
 
Unit Test Your Database
Unit Test Your DatabaseUnit Test Your Database
Unit Test Your Database
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniques
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYC
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy Code
 
CLR Exception Handing And Memory Management
CLR Exception Handing And Memory ManagementCLR Exception Handing And Memory Management
CLR Exception Handing And Memory Management
 
JS and patterns
JS and patternsJS and patterns
JS and patterns
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test Automation
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
 
The Hunter Games: How to Find the Adversary with Event Query Language
The Hunter Games: How to Find the Adversary with Event Query LanguageThe Hunter Games: How to Find the Adversary with Event Query Language
The Hunter Games: How to Find the Adversary with Event Query Language
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Pitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz BankowskiPitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz Bankowski
 
Static analysis as means of improving code quality
Static analysis as means of improving code quality Static analysis as means of improving code quality
Static analysis as means of improving code quality
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
 
C++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ LondonC++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ London
 
Anti Debugging
Anti DebuggingAnti Debugging
Anti Debugging
 

Semelhante a We Make Debugging Sucks Less

Test cases and bug report v3.2
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2Andrey Oleynik
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP StackLorna Mitchell
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Dinis Cruz
 
Effective Android Development
Effective Android Development Effective Android Development
Effective Android Development Sergii Zhuk
 
Php Debugging from the Trenches
Php Debugging from the TrenchesPhp Debugging from the Trenches
Php Debugging from the TrenchesSimon Jones
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctlyDror Helper
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014FalafelSoftware
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingSteven Smith
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)Rob Hale
 
Software Qualitiy with Sonar Tool 2013_4
Software Qualitiy with Sonar Tool 2013_4Software Qualitiy with Sonar Tool 2013_4
Software Qualitiy with Sonar Tool 2013_4Max Kleiner
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing SoftwareSteven Smith
 
Visual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should knowVisual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should knowDror Helper
 
Python testing like a pro by Keith Yang
Python testing like a pro by Keith YangPython testing like a pro by Keith Yang
Python testing like a pro by Keith YangPYCON MY PLT
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best PracticesTomaš Maconko
 

Semelhante a We Make Debugging Sucks Less (20)

Test cases and bug report v3.2
Test cases and bug report v3.2Test cases and bug report v3.2
Test cases and bug report v3.2
 
Fuzzing - Part 2
Fuzzing - Part 2Fuzzing - Part 2
Fuzzing - Part 2
 
Tool up your lamp stack
Tool up your lamp stackTool up your lamp stack
Tool up your lamp stack
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP Stack
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
 
Effective Android Development
Effective Android Development Effective Android Development
Effective Android Development
 
Php Debugging from the Trenches
Php Debugging from the TrenchesPhp Debugging from the Trenches
Php Debugging from the Trenches
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
 
Software Qualitiy with Sonar Tool 2013_4
Software Qualitiy with Sonar Tool 2013_4Software Qualitiy with Sonar Tool 2013_4
Software Qualitiy with Sonar Tool 2013_4
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing Software
 
Into The Box 2020 Keynote Day 1
Into The Box 2020 Keynote Day 1Into The Box 2020 Keynote Day 1
Into The Box 2020 Keynote Day 1
 
Tdd
TddTdd
Tdd
 
Visual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should knowVisual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should know
 
Python testing like a pro by Keith Yang
Python testing like a pro by Keith YangPython testing like a pro by Keith Yang
Python testing like a pro by Keith Yang
 
Code coverage
Code coverageCode coverage
Code coverage
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
 

Mais de Alon Fliess

Generative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptxGenerative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptxAlon Fliess
 
Generating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdeviceGenerating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdeviceAlon Fliess
 
Observability and more architecture next 2020
Observability and more   architecture next 2020Observability and more   architecture next 2020
Observability and more architecture next 2020Alon Fliess
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made EasyAlon Fliess
 
Architecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour versionArchitecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour versionAlon Fliess
 
To microservice or not to microservice - ignite version
To microservice or not to microservice - ignite versionTo microservice or not to microservice - ignite version
To microservice or not to microservice - ignite versionAlon Fliess
 
Net core microservice development made easy with azure dev spaces
Net core microservice development made easy with azure dev spacesNet core microservice development made easy with azure dev spaces
Net core microservice development made easy with azure dev spacesAlon Fliess
 
DWX2018 IoT lecture
DWX2018 IoT lectureDWX2018 IoT lecture
DWX2018 IoT lectureAlon Fliess
 
Architecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft AzureArchitecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft AzureAlon Fliess
 
Azure Internet of Things
Azure Internet of ThingsAzure Internet of Things
Azure Internet of ThingsAlon Fliess
 

Mais de Alon Fliess (11)

Generative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptxGenerative AI in CSharp with Semantic Kernel.pptx
Generative AI in CSharp with Semantic Kernel.pptx
 
Generating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdeviceGenerating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdevice
 
Zionet Overview
Zionet OverviewZionet Overview
Zionet Overview
 
Observability and more architecture next 2020
Observability and more   architecture next 2020Observability and more   architecture next 2020
Observability and more architecture next 2020
 
C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made Easy
 
Architecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour versionArchitecting io t solutions with microisoft azure ignite tour version
Architecting io t solutions with microisoft azure ignite tour version
 
To microservice or not to microservice - ignite version
To microservice or not to microservice - ignite versionTo microservice or not to microservice - ignite version
To microservice or not to microservice - ignite version
 
Net core microservice development made easy with azure dev spaces
Net core microservice development made easy with azure dev spacesNet core microservice development made easy with azure dev spaces
Net core microservice development made easy with azure dev spaces
 
DWX2018 IoT lecture
DWX2018 IoT lectureDWX2018 IoT lecture
DWX2018 IoT lecture
 
Architecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft AzureArchitecting IoT solutions with Microsoft Azure
Architecting IoT solutions with Microsoft Azure
 
Azure Internet of Things
Azure Internet of ThingsAzure Internet of Things
Azure Internet of Things
 

Último

How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 

Último (20)

How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 

We Make Debugging Sucks Less

  • 1. Debugging Sucks – We Make it Suck Less Alon Fliess Chief Software Architect alonf@oz-code.com http://alonfliess.me http://oz-code.com
  • 2. About Me • Alon Fliess: • Chief Software Architect & Co-Founder at OzCode. • More than 30 years of hands-on experience • Many of them in hunting nasty bugs • Microsoft Regional Director & Microsoft MVP • Renowned speaker at both international and domestic events
  • 3. 3
  • 4. How Much Does a Software Bug Cost? NASA’s Mars Climate Orbiter $125 Millions Ariane 5 Flight 501 $370 Millions The Mariner 1 Spacecraft $18 Millions Heathrow Terminal 5 Opening $125 Millions Pentium FDIV bug $475 Millions Knight’s $440 Million Error $440 Millions
  • 5. Microsoft Azure DevOps Bounty Program
  • 6. Agenda • Introduction • Debugging – Overview • The debugging process • Debugger internals • Controlling the debugger – A magical debugging show • The future of debugging • Summary 6
  • 7. Wikipedia • “Debugging is the process of finding and resolving bugs or defects that prevent correct operation of computer software or a system” • The terms "bug" and "debugging" are popularly attributed to Admiral Grace Hopper in the 1940s • However the term is much older: • Thomas Edison wrote the following words in a letter to an associate in 1878: • “It has been just so in all of my inventions. The first step is an intuition, and comes with a burst, then difficulties arise — this thing gives out and [it is] then that "Bugs" — as such little faults and difficulties are called — show themselves and months of intense watching, study and labor are requisite before commercial success or failure is certainly reached” 12/1/2014 7
  • 8. The Art of Debugging • Debugging requires: • Deep understanding of your code • Deep understanding of your system, environment and tools • Abstraction layers are great for development, however when debugging you need to dig under the hood • Technician senses and techniques • Gathering evidence • Analyzing • Trying • Hacking • Patching 8
  • 9. The Debugging Process Overview •Understand the context & the requirements • Distinguish bugs and features (By Design) •Reproduce the bug, make it fail •Simplify the test case •Understand the error •Check the obvious, check the plug • Can’t write to a read only file
  • 10. The Debugging Process Overview •Separate facts from interpretation • Wrong interpretation leads to a dead-end •Divide and conquer • Trap the bug in the corner •Use the right tool for the bug & the context •Isolate changes - do one change at a time • See its effect (fact), draw a conclusion (interpretation)
  • 11. The Debugging Process Overview •Consult others •Consult your Co-workers •Get a fresh view •Use Google, Bing, or any web search engine •Use Twitter, Stack Overflow or any other social media •Search for known bugs and issues
  • 12. The Debugging Process Overview •Bugs do not disappear •If you didn’t fix it, it is not fixed •If you can’t reproduce it anymore, look for what you or others have changed •Use Source Control • You can create a branch for the debugging process
  • 13. Fixing problems that shouldn’t be there Instead of creating value for our customers Debugging is a waste of time
  • 14. Restarting debug run • After code change • When we’ve missed crucial information Manually stepping through the code line-by-line Breaking on irrelevant spots How we waste time during debugging
  • 15. Summary •Like any other development skill, debugging is a skill that you need to learn •Real bugs are hard to find and solve •Be organized, use a debugging process •Use the right tools, consult with other people, document the process & tell the world
  • 16. .NET Debugger Options • Visual Studio • With OzCode! • MDbg.exe - .NET Command line Debugger • WinDbg + SOS.DLL|SOSEX.DLL 16
  • 17. Debugger Anatomy Wait for debug event Handle debug event Continue debug event Start the debuggee or attach to it Enter main debugger loop
  • 18. Debugger Main Loop 1. … 2. for(;;) 3. { 4. WaitForDebugEvent(DebugEv, INFINITE); 5. switch (DebugEv->dwDebugEventCode) 6. { 7. case EXCEPTION_DEBUG_EVENT: 8. switch(DebugEv->u.Exception.ExceptionRecord. 9. ExceptionCode) 10. { 11. case EXCEPTION_ACCESS_VIOLATION: 12. case … 13. }
  • 19. Debugger Main Loop 1. break; 2. case CREATE_THREAD_DEBUG_EVENT: 3. dwContinueStatus = 4. OnCreateThreadDebugEvent(DebugEv); 5. break; 6. … 7. } 8. // Resume executing the thread that reported the 9. debugging event. 10. ContinueDebugEvent(DebugEv->dwProcessId, 11. DebugEv->dwThreadId, 12. dwContinueStatus); 13. }} Demo
  • 20. .NET Debugger Anatomy • The .NET CLR wrap the native debugging API and provides a COM interface for the CLR debugger: • There are other debugging interfaces 20 ICorDebug Methods Description ICorDebug::CanLaunchOrAttach Determines whether launching a new process or attaching is possible ICorDebug::CreateProcess Launches a process and its primary thread under the control of the debugger ICorDebug::DebugActiveProcess Attaches the debugger to an existing process. ICorDebug::EnumerateProcesses Gets an enumerator for the processes that are being debugged ICorDebug::GetProcess Returns the ICorDebugProcess object with the given process ID ICorDebug::Initialize Initializes the ICorDebug object. ICorDebug::SetManagedHandler Specifies the event handler object for managed events ICorDebug::SetUnmanagedHandler Specifies the event handler object for unmanaged events ICorDebug::Terminate Terminates the ICorDebug object.
  • 21. Concord – The Visual Studio Debug Engine • Documentation and Samples are available online • Use it to extend the Visual Studio debugger • Use it to develop your programming language debugger 21
  • 22. Controlling the Debugger • There are two types of (human) debuggers: • The: I am too tired to think  let the debugger lead and control • The “everything is under control type” 22
  • 23. Controlling the Debugger – The Execution Context • A debuggee stops its execution when the debugger receives a debug event • New thread, load library, exception or special exception such as breakpoint • When the debuggee is paused, the debugger pauses all other threads and the execution context points to • The current process, current thread, current stack location, current instruction pointer • You can change the context in several ways 23
  • 24. Controlling the Execution Context • Using the debugger UI, you can switch between processes, threads, and stack locations • Within the current context of the process and thread: • Moving the instruction pointer to • Skip code • Re-run code • Setting variable values that control the execution path • Expressions in if, switch, loop conditions • Using Edit & Continue 24
  • 25. Setting New Breakpoints • Setting Breakpoints with Visual Studio 2015/17/19 25
  • 26. Method Breakpoints • If you type a method name (without class name) • VS select all that matches .NET Performance & Debugging 26
  • 27. The Scientific Method • while (still_not_fixed) • Make it fail • Trial and error • Trap and isolate the bug • Add new unit tests • Make a hypothesis • Collect evidence • Prove or refine the hypothesis • Refine the unit tests • Fix the bug • Run all (regression) tests • Check-in, document 27 Identify the Bug • Use source control and change sets • Divide & Conquer • Create a simple case • The bug is yours, unless you find it on the Web • In rare cases – It is other fault
  • 28. 28 Demo • Breakpoints • Conditional • Changing context • Instruction Pointer • Stack Location • Thread • Process Controlling the execution context
  • 29. There are some moments in life… •After which, life is no longer the same! • The first kiss • Your wedding • The first child • The first time you saw OzCode 29
  • 30. Let the Magic Begin 30
  • 31. 31 Demo • Reveal • Heads Up Display • Magic Glance • Search • Breakpoints • All Members • Conditional • “Property” • Exception Trail / HUD OzCode Main Features
  • 32. Collecting Evidence •Collect program execution data: • Application log – need to instrument the code • The Immediate / Command Window • With >log • Tracepoints • With OzCode • VS Watch Window / OzCode Watch Window • VS Data Tips / OzCode Data Tips 32
  • 33. 33 Demo Logging the Immediate & Command Window – A VS Tip! > Log "file path" Optional Switches: /on  Append /off  Close file, stop logging /overwrite  Start new log file > open "file path"
  • 35. Tracing with Tracepoints • Can print out any expression by surrounding with {} • property/field/method call • Special code can be used: 35 Tracepoint variable name Meaning $ADDRESS Current instruction address $CALLER Caller name of current method $CALLSTACK The call stack at the current location $FUNCTION Current function name $PID Current process ID $PNAME Current process name $TID Current thread ID $TNAME Current thread name
  • 36. 36 Demo Trace with OzCode • Tracepoint editor • Tracepoint Viewer
  • 37. OzCode Analysis Tools •Finding problems in vast amount of data is hard • You need to: • Navigate the execution context to the right spot • Analyze and understand LINQ queries • Analyze and understand code execution (algorithm) • Filter: • The properties that are important to you • The instances in a collection that point to the problem • Compare object & collection state • Save “good” state for future comparisons • Create your own “custom expression” to surface problems 37
  • 38. 38 Demo OzCode Analysis Tools • LINQ Analysis • Compare: • Two objects or More • Saved state • Collection Filtering (next slides) • Custom Expression (next slides)
  • 41. 41 Demo OzCode Analysis Tools • Time Travel • Live Coding
  • 42. The Future of (Production) Debugging
  • 43. Summary • Debugging – Overview • The debugging process • Debugger internals • Controlling the debugger – A magical debugging show • The future of debugging 43
  • 44. Thanks! Alon Fliess Chief Software Architect alonf@oz-code.com http://alonfliess.me http://oz-code.com

Notas do Editor

  1. We are using early beta of the next OzCode
  2. 1. Understand the requirements 2. Make it fail 3. Simplify the test case 4. Read the right error message 5. Check the plug 6. Separate facts from interpretation 7. Divide and conquer 8. Match the tool to the bug 9. One change at a time 10. Keep an audit trail 11. Get a fresh view 12. If you didn’t fix it, it ain’t fixed 13. Cover your bugfix with a regression test
  3. 1. Understand the requirements 2. Make it fail 3. Simplify the test case 4. Read the right error message 5. Check the plug 6. Separate facts from interpretation 7. Divide and conquer 8. Match the tool to the bug 9. One change at a time 10. Keep an audit trail 11. Get a fresh view 12. If you didn’t fix it, it ain’t fixed 13. Cover your bugfix with a regression test
  4. 1. Understand the requirements 2. Make it fail 3. Simplify the test case 4. Read the right error message 5. Check the plug 6. Separate facts from interpretation 7. Divide and conquer 8. Match the tool to the bug 9. One change at a time 10. Keep an audit trail 11. Get a fresh view 12. If you didn’t fix it, it ain’t fixed 13. Cover your bugfix with a regression test
  5. 1. Understand the requirements 2. Make it fail 3. Simplify the test case 4. Read the right error message 5. Check the plug 6. Separate facts from interpretation 7. Divide and conquer 8. Match the tool to the bug 9. One change at a time 10. Keep an audit trail 11. Get a fresh view 12. If you didn’t fix it, it ain’t fixed 13. Cover your bugfix with a regression test
  6. 14 min 17min
  7. 22:00 29:00
  8. 30:00