Production debugging of SharePoint
applications
#SPSBEUK
Wouter van Vugt
April 26th, 2014
Thanks to our sponsors!
Gold
Silver
Agenda
.NET Applications
OS
CLR
App
Common Language Runtime
Operation
• Memory management
• Thread synchronization
• Error handling
• Type Safety
Security
• C...
Type Safety
Car c = new Person()
‘Pointer type’ Pointer Object type
Circumventing type safety
Demo
Creating .NET Applications
C#, C++,
VB.NET,
F#.... (40+)
Module
PDB
Compile Link
Assembly
PDB
Executing code
C#
Machine
Code
Language richness compared
IL
Executing code with JIT Compilation
Console.WriteLine("Hi");
Console.WriteLine("There");
JIT Compiler
-Lookup IL for metho...
Executing code with JIT Compilation
Console.WriteLine("Hi");
Console.WriteLine("There");
Console metadata
static void
Writ...
Code optimization
Running non optimized code
C# Compiler – Variable Generation
C# Compiler – Variable Generation
C# Compiler – Inserting NOP
C# Compiler – Inserting NOP
C# Compiler – Branching
C# Compiler – Branching
Compile time
optimizations
Demo
Just In Time Compilation
Compiler switch C# IL Code Quality JIT Native Code Quality
/optimize- /debug- Unoptimized Optimiz...
NGEN.exe
JIT - Local variable elimination
PrintUser(GetUser(3));
Before
After
JIT – Range check elimination
static int[] _array = new int[10];
static volatile int _i;
static void Main(string[] args)
{...
JIT – Method Inlining
public class Program {
static void Main(string[] args) {
int i = 5 & 4;
}
}
Before
After
JIT – Tail Call Optimization
static void Main(string[] args)
{
TestTailCallOptimization();
}
public static void TestTailCa...
Native NGEN images are hard to debug
Loading non-precompiled assemblies
C:> SET COMPLUS_ZAPDISABLE=1
C:> NGEN uninstall My...
Preventing JIT optimization
[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0
[assembly: Debuggabl...
Debugging optimized
code
Demo
Debugging code
PDB Files
Symbol Servers
Locating debug symbols
MyAssembly.dll MyAssembly.pdb
GUID GUID
Equal
Dumpbin.exe
Prevent loading all PDBs
Visual Studio Source Server support
Configuring Symbol Locations
PDB alternate streams
SYMBOL SERVERS, SOURCE SERVERS AND
SOURCE INDEXING
Demo
Working with break points
Setting breakpoints on automatic
properties
Breakpoints on automatic properties
Debugging third party code
Enabling remote debugging
Debugging SharePoint
Demo
Thank you!
SharePoint Saturday Belgium 2014 - Production debugging of SharePoint applications
Upcoming SlideShare
Loading in …5
×

SharePoint Saturday Belgium 2014 - Production debugging of SharePoint applications

667 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
667
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

SharePoint Saturday Belgium 2014 - Production debugging of SharePoint applications

  1. 1. Production debugging of SharePoint applications #SPSBEUK Wouter van Vugt April 26th, 2014
  2. 2. Thanks to our sponsors! Gold Silver
  3. 3. Agenda
  4. 4. .NET Applications OS CLR App
  5. 5. Common Language Runtime Operation • Memory management • Thread synchronization • Error handling • Type Safety Security • Code Access Security • Data Execution Prevention (OS) • Address Space Layout Randomization (OS) Execution • Intermediate Language
  6. 6. Type Safety Car c = new Person() ‘Pointer type’ Pointer Object type
  7. 7. Circumventing type safety Demo
  8. 8. Creating .NET Applications C#, C++, VB.NET, F#.... (40+) Module PDB Compile Link Assembly PDB
  9. 9. Executing code C# Machine Code Language richness compared IL
  10. 10. Executing code with JIT Compilation Console.WriteLine("Hi"); Console.WriteLine("There"); JIT Compiler -Lookup IL for method -Compile IL to native -Modify metadata to point to compiled code -Jump to compiled code Console metadata static void WriteLine(string) JIT Compiler Address static void WriteLine() JIT Compiler Address Native CPU Instructions Native Address
  11. 11. Executing code with JIT Compilation Console.WriteLine("Hi"); Console.WriteLine("There"); Console metadata static void WriteLine(string) JIT Compiler -Lookup IL for method -Compile IL to native -Modify metadata to point to compiled code -Jump to compiled code Native Address static void WriteLine() JIT Compiler Address Native CPU Instructions
  12. 12. Code optimization
  13. 13. Running non optimized code
  14. 14. C# Compiler – Variable Generation
  15. 15. C# Compiler – Variable Generation
  16. 16. C# Compiler – Inserting NOP
  17. 17. C# Compiler – Inserting NOP
  18. 18. C# Compiler – Branching
  19. 19. C# Compiler – Branching
  20. 20. Compile time optimizations Demo
  21. 21. Just In Time Compilation Compiler switch C# IL Code Quality JIT Native Code Quality /optimize- /debug- Unoptimized Optimized /optimize- /debug+ Unoptimized Unoptimized /optimize+ /debug+ Optimized Optimized
  22. 22. NGEN.exe
  23. 23. JIT - Local variable elimination PrintUser(GetUser(3)); Before After
  24. 24. JIT – Range check elimination static int[] _array = new int[10]; static volatile int _i; static void Main(string[] args) { int[] localRef = _array; for (int i = 0; i < localRef.Length; ++i) _i += localRef[i]; } Before After
  25. 25. JIT – Method Inlining public class Program { static void Main(string[] args) { int i = 5 & 4; } } Before After
  26. 26. JIT – Tail Call Optimization static void Main(string[] args) { TestTailCallOptimization(); } public static void TestTailCallOptimization() { string s = "Test"; TailCall1(s); } static void TailCall1(string s) { Console.WriteLine(s); TailCall2(s); } static void TailCall2(string s) { Console.WriteLine(s + s); }
  27. 27. Native NGEN images are hard to debug Loading non-precompiled assemblies C:> SET COMPLUS_ZAPDISABLE=1 C:> NGEN uninstall MyAssembly
  28. 28. Preventing JIT optimization [.NET Framework Debugging Control] GenerateTrackingInfo=1 AllowOptimize=0 [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]
  29. 29. Debugging optimized code Demo
  30. 30. Debugging code
  31. 31. PDB Files
  32. 32. Symbol Servers
  33. 33. Locating debug symbols MyAssembly.dll MyAssembly.pdb GUID GUID Equal
  34. 34. Dumpbin.exe
  35. 35. Prevent loading all PDBs
  36. 36. Visual Studio Source Server support
  37. 37. Configuring Symbol Locations
  38. 38. PDB alternate streams
  39. 39. SYMBOL SERVERS, SOURCE SERVERS AND SOURCE INDEXING Demo
  40. 40. Working with break points
  41. 41. Setting breakpoints on automatic properties
  42. 42. Breakpoints on automatic properties
  43. 43. Debugging third party code
  44. 44. Enabling remote debugging
  45. 45. Debugging SharePoint Demo
  46. 46. Thank you!

×