SlideShare uma empresa Scribd logo
1 de 20
Beyond F5 - windbg Yann Schwartz -  blog.polom.com  - yann@polom.com
Oui mais pourquoi ? Déboguer dans la nature, diagnostiquer les problèmes avec un outil le plus léger possible.
Windbg   - cdb - kd Debuggingtools for Windows  http://microsoft.com/whdc/devtools/debugging Au départ, un debugger natif (user mode et kernel), frontal de bibliothèques bas niveau. windbg : debugger « graphique » cdb + kd (kernel debugger) cdb (console debugger) : idem que windbg mais en pure ligne de commande et user mode seulement kd: kernel debugger (ligne de commande) Pas d’installation nécessaire (le répertoire décompressé par l’installeur se suffit à lui-même)
sos et sosex sos (Son of Strike)  	extension pour le code managé livré avec chaque version du framework sosex 	extension non MS de sos Steve Johnson - http://www.stevestechspot.com/
sos This is how the world ends, not with a bang but a whimper.		(TS Eliot – the Hollow men) This is how sosbegins, not with a whimper but a bang. !Help
Avant de commencer .loadbysosmscorwks charge la version de sos correspondant à la version du CLR de l’appli .loadsosex charge sosex (doit être dans le répertoire de windbg/cdb) .cmdtree[path]md_tree.txt menu de racourcis personnalisable
Commandes amusantes !DumpHeap –stat  Instances du tas, regroupées par type, triées par taille totale !Threads Liste des threads managed !runaway 7 Exécute l’appli et classe les threads par temps CPU utilisé
Encore des commandes ! SyncBlk Liste des locks pris ou attendus ! ClrStack [-a|-l|-p] Call stack CLR du thread courant, et variables et arguments courants !GCRootaddr Liste récursive des instances qui font que l’instance à [addr] reste en vie
Toujours plus haut ~n Infos sur le thread n ~ns Passer au thread n ~e*!ClrStack –a Exécuter une commande sur tous les threads
sosex !dlk Détection automatique des deadlocks !refsaddr Liste des  références de et vers l’instance à addr !mln addr Type de l’objet CLR à l’adresse addr
Interlude Une brève histoire des langages de programmation user unfriendly
APL http://en.wikipedia.org/wiki/APL_%28programming_language%29 X[⍋X+.≠' ';]
J 		http://en.wikipedia.org/wiki/J_%28programming_language%29 quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^:(1<#)  times=: (1 5&(+/ .*)@:* , (+/ .* |.)) " 1 pow  =: 4 : 'times/ 1 0 , times~^:(I.|.#:y) x' " 1 0 f8a  =: {. @ (0 1r5&times) @ (-/) @ ((1r2 1r2,:1r2 _1r2)&pow) f8b  =: {:@(1 1x&pow) % 2x&^@<:
Brainfuck http://en.wikipedia.org/wiki/Brainfuck ,>,>++++++[-<--------<-------->>]  <<[                                >[->+>+<<]                         >[-<<-                             [>]>>>[<[>>>-<<<[-]]>>]<<]         >>>+                               <<[-<<+>>]                         <<<]                               >[-]>>>>[-<<<<<+>>>>>]             <<<<++++++[-<++++++++>]<.
Scripts windbg ~*e r? $t0 = @$teb; r? $t1 = @$t0+8; r? $t2 = @$t0+4; kv 100; dps poi(@$t1) poi(@$t2) ad /q *  .printf " Data Table : ${$arg1} ";  .foreach (DataColumn {!do poi(poi(poi(${$arg1}+0x18)+0x8)+0x4) -v -short}){    .printf "     Data Column : ${DataColumn} ";    $$    !do poi(${DataColumn}+0x28)    !dumpfield -field_columnName ${DataColumn} -string}.printf "";
This isyourbrain on windbgscripting
Powerdbg Frontal Powershell de pilotage de windbg http://www.codeplex.com/powerdbg powershell  –(stdin/out)->  cdb  –(tcp)->   windbg Fonctions simples pour lancer des commandes Sortie standard de cdb traitée ligne à ligne Scripts (et moteur) écrits en Powershell (une trentaine de scripts existants)
Un script Powerdb $null = Invoke-WindbgCommand .loadby sos mscorwks$output = Invoke-WindbgCommand ("!dumpheap -type " +     "System.Management.Automation.InvocationInfo -short") foreach($line in $output) {     Resolve-Member $line commandInfo.name     Resolve-Member $line scriptToken._script    Resolve-Member $line scriptToken._line} Disconnect-Windbg
Linqdbg Vaporware www.polom.com/linqdbg linqdbg (.Net) -> cdb varobjs = from instance inLinqdbg.HeapStats()             whereinstance.Type.IsAssignableFrom(typeof(Toto))             orderbyinstance.TotalSizedesc;             varleaked = from instance inobjs             	         selectinstance.GCRoot();
Ressources Debugging MS .Net 2.0 Applications, MS Press, John Robbins Windows Internals 5th edition, MS Press, Mark Russinovitch Blog de Tess Ferrandez Blog de John Robbins www.codeplex.com/powerdbg www.polom.com/linqdbg

Mais conteúdo relacionado

Mais procurados

ENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: GroovyENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: GroovyHoracio Gonzalez
 
PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introductionJean Michel
 
Interception de signal avec dump de la pile d'appel
Interception de signal avec dump de la pile d'appelInterception de signal avec dump de la pile d'appel
Interception de signal avec dump de la pile d'appelThierry Gayet
 
09 big data mapreduce
09 big data mapreduce09 big data mapreduce
09 big data mapreducePatrick Bury
 
Memory Analyzer (Eclipse Demo Camp)
Memory Analyzer (Eclipse Demo Camp)Memory Analyzer (Eclipse Demo Camp)
Memory Analyzer (Eclipse Demo Camp)Manuel Boillod
 
Presentation langage go_19022015
Presentation langage go_19022015Presentation langage go_19022015
Presentation langage go_19022015Stéphane Legrand
 
Asyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchronesAsyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchronestchappui
 

Mais procurados (9)

ENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: GroovyENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: Groovy
 
PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introduction
 
Interception de signal avec dump de la pile d'appel
Interception de signal avec dump de la pile d'appelInterception de signal avec dump de la pile d'appel
Interception de signal avec dump de la pile d'appel
 
09 big data mapreduce
09 big data mapreduce09 big data mapreduce
09 big data mapreduce
 
PostgreSQL Meetup Nantes #2
PostgreSQL Meetup Nantes #2PostgreSQL Meetup Nantes #2
PostgreSQL Meetup Nantes #2
 
Tp-jquery
Tp-jqueryTp-jquery
Tp-jquery
 
Memory Analyzer (Eclipse Demo Camp)
Memory Analyzer (Eclipse Demo Camp)Memory Analyzer (Eclipse Demo Camp)
Memory Analyzer (Eclipse Demo Camp)
 
Presentation langage go_19022015
Presentation langage go_19022015Presentation langage go_19022015
Presentation langage go_19022015
 
Asyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchronesAsyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchrones
 

Destaque

Introduction Erlang - altnet fr Juin 2013
Introduction Erlang - altnet fr Juin 2013Introduction Erlang - altnet fr Juin 2013
Introduction Erlang - altnet fr Juin 2013Yann Schwartz
 
Data Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixData Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixStefan Krawczyk
 
Samza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next LevelSamza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next LevelMartin Kleppmann
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentSven Peters
 
Starting a Collaboration Revolution
Starting a Collaboration RevolutionStarting a Collaboration Revolution
Starting a Collaboration RevolutionSven Peters
 
DDD patterns that were not in the book
DDD patterns that were not in the bookDDD patterns that were not in the book
DDD patterns that were not in the bookCyrille Martraire
 

Destaque (7)

Introduction Erlang - altnet fr Juin 2013
Introduction Erlang - altnet fr Juin 2013Introduction Erlang - altnet fr Juin 2013
Introduction Erlang - altnet fr Juin 2013
 
From Ubu to kafka
From Ubu to kafkaFrom Ubu to kafka
From Ubu to kafka
 
Data Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixData Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch Fix
 
Samza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next LevelSamza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next Level
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your Development
 
Starting a Collaboration Revolution
Starting a Collaboration RevolutionStarting a Collaboration Revolution
Starting a Collaboration Revolution
 
DDD patterns that were not in the book
DDD patterns that were not in the bookDDD patterns that were not in the book
DDD patterns that were not in the book
 

Semelhante a Beyond F5 - windbg et .Net

Réu technodejs
Réu technodejsRéu technodejs
Réu technodejsnaholyr
 
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINEIntroduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINEMarouan OMEZZINE
 
Monitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaMonitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaPatrick Allaert
 
Codedarmor 2012 - 13/11 - Dart, un langage moderne pour le web
Codedarmor 2012 - 13/11 - Dart, un langage moderne pour le webCodedarmor 2012 - 13/11 - Dart, un langage moderne pour le web
Codedarmor 2012 - 13/11 - Dart, un langage moderne pour le webcodedarmor
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database ConnectivityKorteby Farouk
 
Présentation Arduino par Christian, F5HOD
Présentation Arduino par Christian, F5HODPrésentation Arduino par Christian, F5HOD
Présentation Arduino par Christian, F5HODwebmasterref68
 
ALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et Lexer ALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et Lexer Alexandru Radovici
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation Groovyguest6e3bed
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation GroovyJS Bournival
 
PHP - get started
PHP - get startedPHP - get started
PHP - get startedmazenovi
 
Cours langage c
Cours langage cCours langage c
Cours langage ccoursuniv
 
Coat::Persistent at FPW2009
Coat::Persistent at FPW2009Coat::Persistent at FPW2009
Coat::Persistent at FPW2009Alexis Sukrieh
 
Partie1 TypeScript
Partie1 TypeScriptPartie1 TypeScript
Partie1 TypeScriptHabib Ayad
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applicationsgoldoraf
 
PHP 5.3, PHP Next
PHP 5.3, PHP NextPHP 5.3, PHP Next
PHP 5.3, PHP NextSQLI
 
Jump Camp - HTML5
Jump Camp - HTML5Jump Camp - HTML5
Jump Camp - HTML5chaudavid
 

Semelhante a Beyond F5 - windbg et .Net (20)

Réu technodejs
Réu technodejsRéu technodejs
Réu technodejs
 
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINEIntroduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
 
Monitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaMonitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et Pinba
 
Codedarmor 2012 - 13/11 - Dart, un langage moderne pour le web
Codedarmor 2012 - 13/11 - Dart, un langage moderne pour le webCodedarmor 2012 - 13/11 - Dart, un langage moderne pour le web
Codedarmor 2012 - 13/11 - Dart, un langage moderne pour le web
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Présentation Arduino par Christian, F5HOD
Présentation Arduino par Christian, F5HODPrésentation Arduino par Christian, F5HOD
Présentation Arduino par Christian, F5HOD
 
ALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et Lexer ALF 3 - Expressions régulières et Lexer
ALF 3 - Expressions régulières et Lexer
 
Apache ANT
Apache ANTApache ANT
Apache ANT
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation Groovy
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation Groovy
 
PHP - get started
PHP - get startedPHP - get started
PHP - get started
 
Cours langage c
Cours langage cCours langage c
Cours langage c
 
Coat::Persistent at FPW2009
Coat::Persistent at FPW2009Coat::Persistent at FPW2009
Coat::Persistent at FPW2009
 
Partie1 TypeScript
Partie1 TypeScriptPartie1 TypeScript
Partie1 TypeScript
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applications
 
Ruby Pour RoR
Ruby Pour RoRRuby Pour RoR
Ruby Pour RoR
 
C++ 11/14
C++ 11/14C++ 11/14
C++ 11/14
 
PHP 5.3, PHP Next
PHP 5.3, PHP NextPHP 5.3, PHP Next
PHP 5.3, PHP Next
 
Dynamic Languages
Dynamic LanguagesDynamic Languages
Dynamic Languages
 
Jump Camp - HTML5
Jump Camp - HTML5Jump Camp - HTML5
Jump Camp - HTML5
 

Beyond F5 - windbg et .Net

  • 1. Beyond F5 - windbg Yann Schwartz - blog.polom.com - yann@polom.com
  • 2. Oui mais pourquoi ? Déboguer dans la nature, diagnostiquer les problèmes avec un outil le plus léger possible.
  • 3. Windbg - cdb - kd Debuggingtools for Windows http://microsoft.com/whdc/devtools/debugging Au départ, un debugger natif (user mode et kernel), frontal de bibliothèques bas niveau. windbg : debugger « graphique » cdb + kd (kernel debugger) cdb (console debugger) : idem que windbg mais en pure ligne de commande et user mode seulement kd: kernel debugger (ligne de commande) Pas d’installation nécessaire (le répertoire décompressé par l’installeur se suffit à lui-même)
  • 4. sos et sosex sos (Son of Strike) extension pour le code managé livré avec chaque version du framework sosex extension non MS de sos Steve Johnson - http://www.stevestechspot.com/
  • 5. sos This is how the world ends, not with a bang but a whimper. (TS Eliot – the Hollow men) This is how sosbegins, not with a whimper but a bang. !Help
  • 6. Avant de commencer .loadbysosmscorwks charge la version de sos correspondant à la version du CLR de l’appli .loadsosex charge sosex (doit être dans le répertoire de windbg/cdb) .cmdtree[path]md_tree.txt menu de racourcis personnalisable
  • 7. Commandes amusantes !DumpHeap –stat Instances du tas, regroupées par type, triées par taille totale !Threads Liste des threads managed !runaway 7 Exécute l’appli et classe les threads par temps CPU utilisé
  • 8. Encore des commandes ! SyncBlk Liste des locks pris ou attendus ! ClrStack [-a|-l|-p] Call stack CLR du thread courant, et variables et arguments courants !GCRootaddr Liste récursive des instances qui font que l’instance à [addr] reste en vie
  • 9. Toujours plus haut ~n Infos sur le thread n ~ns Passer au thread n ~e*!ClrStack –a Exécuter une commande sur tous les threads
  • 10. sosex !dlk Détection automatique des deadlocks !refsaddr Liste des références de et vers l’instance à addr !mln addr Type de l’objet CLR à l’adresse addr
  • 11. Interlude Une brève histoire des langages de programmation user unfriendly
  • 13. J http://en.wikipedia.org/wiki/J_%28programming_language%29 quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^:(1<#) times=: (1 5&(+/ .*)@:* , (+/ .* |.)) " 1 pow =: 4 : 'times/ 1 0 , times~^:(I.|.#:y) x' " 1 0 f8a =: {. @ (0 1r5&times) @ (-/) @ ((1r2 1r2,:1r2 _1r2)&pow) f8b =: {:@(1 1x&pow) % 2x&^@<:
  • 14. Brainfuck http://en.wikipedia.org/wiki/Brainfuck ,>,>++++++[-<--------<-------->>] <<[ >[->+>+<<] >[-<<- [>]>>>[<[>>>-<<<[-]]>>]<<] >>>+ <<[-<<+>>] <<<] >[-]>>>>[-<<<<<+>>>>>] <<<<++++++[-<++++++++>]<.
  • 15. Scripts windbg ~*e r? $t0 = @$teb; r? $t1 = @$t0+8; r? $t2 = @$t0+4; kv 100; dps poi(@$t1) poi(@$t2) ad /q * .printf " Data Table : ${$arg1} "; .foreach (DataColumn {!do poi(poi(poi(${$arg1}+0x18)+0x8)+0x4) -v -short}){    .printf "     Data Column : ${DataColumn} ";    $$    !do poi(${DataColumn}+0x28)    !dumpfield -field_columnName ${DataColumn} -string}.printf "";
  • 16. This isyourbrain on windbgscripting
  • 17. Powerdbg Frontal Powershell de pilotage de windbg http://www.codeplex.com/powerdbg powershell –(stdin/out)-> cdb –(tcp)-> windbg Fonctions simples pour lancer des commandes Sortie standard de cdb traitée ligne à ligne Scripts (et moteur) écrits en Powershell (une trentaine de scripts existants)
  • 18. Un script Powerdb $null = Invoke-WindbgCommand .loadby sos mscorwks$output = Invoke-WindbgCommand ("!dumpheap -type " +     "System.Management.Automation.InvocationInfo -short") foreach($line in $output) {     Resolve-Member $line commandInfo.name     Resolve-Member $line scriptToken._script    Resolve-Member $line scriptToken._line} Disconnect-Windbg
  • 19. Linqdbg Vaporware www.polom.com/linqdbg linqdbg (.Net) -> cdb varobjs = from instance inLinqdbg.HeapStats()             whereinstance.Type.IsAssignableFrom(typeof(Toto))             orderbyinstance.TotalSizedesc;             varleaked = from instance inobjs         selectinstance.GCRoot();
  • 20. Ressources Debugging MS .Net 2.0 Applications, MS Press, John Robbins Windows Internals 5th edition, MS Press, Mark Russinovitch Blog de Tess Ferrandez Blog de John Robbins www.codeplex.com/powerdbg www.polom.com/linqdbg