Cp4349 debugging autodesk product plug ins
Download
1 / 34

- PowerPoint PPT Presentation


  • 99 Views
  • Uploaded on

CP4349 - Debugging Autodesk® Product Plug-ins. Two bytes meet. The first byte asks, “Are you ill?” The second byte replies, “No, just feeling a bit off .”. Kevin Vandecar Principal Developer Consulting Engineer – M&E Sparks Autodesk Developer Network. bio: Kevin Vandecar.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '' - frieda


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Cp4349 debugging autodesk product plug ins
CP4349 - Debugging Autodesk® Product Plug-ins

Two bytes meet. The first byte asks, “Are you ill?”

The second byte replies, “No, just feeling a bit off.”

Kevin Vandecar

Principal Developer Consulting Engineer – M&E Sparks Autodesk Developer Network


Bio kevin vandecar
bio: Kevin Vandecar

  • @ Autodesk for over 18 years

    • all customization related

      • Experience with AutoCAD, AutoCAD Architecture, 3d Studio (DOS), Autodesk Revit

      • Last five years as Software Engineer on AutoCAD Architecture API and Revit API

      • now focusing on 3ds Max customization in ADN Sparks team

    • Based in Manchester, New Hampshire, US

    • email: kevin.vandecar@autodesk.com


Autodesk developer network
Autodesk Developer Network

  • Access to almost all Autodesk software and SDK’s

    • Includes early access to beta software

  • Members-only website with thousands of technical articles

  • Unlimited technical support

  • Product direction through conferences

  • Marketing benefits

    • Exposure on autodesk.com

    • Promotional opportunities

  • One to three free API training classes

    • Based on user level

      www.autodesk.com/joinadn


What are we covering
What are we covering…

  • Most “plug-ins”, “add-ins”, “apps”, etc. for Autodesk applications are DLLs

    • Use mainly the C++ language to demonstrate debugging techniques in AutoCAD and 3ds Max

    • Touch on managed debugging, using Revit as an example.

    • Take a look at how CER mini-dump may be helpful for you

  • Look at the Visual Studio debugging tools

    • Nearly all of the techniques are the same between native (C++) and managed (C#, VB.NET, etc.)


Debugging
Debugging…

  • …is fundamentally problem solving

"Intellectuals solve problems, geniuses prevent them." - Albert Einstein


What is debugging
What is Debugging?

aka: Autodesk plug-in developers! 

Autodesk Application

plug-in 2

plug-in 1

plug-in 3

Wikipedia:

Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected. Debugging tends to be harderwhen various subsystems are tightly coupled, as changes in one may cause bugs to emerge in another.


What is debugging1
What is Debugging?

  • For the “coder” much easier to understand at the implementation time

    • Code-time testing is important! aka Unit Testing

    • document your code!

  • For the “inspector/debugger” much harder

    • You may be debugging other people’s code

    • Or it may be code from your distant past

    • This makes it much more difficult


How to debug
How to debug?

Swigert: 'Okay, Houston, we've had a problem here.'

Houston: 'This is Houston. Say again please.'

Lovell: 'Houston, we've had a problem. We've had a main B bus under-volt.'

  • First verify problem and reproduce it…

    • No use setting break points, stepping through code, etc. without knowing how to repro it.

      • helps to document steps

      • smallest repro steps/sample is ideal

    • When communicating API problems beyond your code to Autodesk, it is ideal to have the smallest repro sample code possible.


How to debug1
How to debug?

  • Start Debugging!

    • Use the tools you have

    • The debugger itself is not the only tool!

  • Then once you found the problem…

    • Find the entry point into necessary code branch

      • If you have a complex plug-in, sometimes UI resource strings can help to find how to enter the code branch


How to debug autodesk plug ins different techniques
How to Debug Autodesk Plug-ins? – different techniques

  • Coding Techniques

  • Additional Application specific options

  • Visually Inspect the Code

  • Use VS debugging tools

    • Reminder, VS2010 C++ Project Format used for 3ds Max and AutoCAD 2012 SDKs, but targeting VS2008 SP1 for binary compatibility (V90 toolset).

    • Revit is also using the VS 2010 managed compiler directly.

  • CER mini dump files


Coding techniques
Coding techniques

  • Simplest form: Use Output statements

    • Debugger output(OutputDebugString)

    • Application output (“printf”, “cout”, and other routines)

    • Sometimes apps have their own output means

      • 3ds Max: MaxMsgBox, MAXScriptmprintf

      • AutoCAD: acutPrintf, acedAlert

      • Revit: TaskDialogs

  • Other Debug code statements

    • http://msdn.microsoft.com/en-us/library/ms679303(v=VS.85).aspx


Coding techniques1
Coding Techniques

demo (acad)

  • Assert

    • code safety to ensure conditions are always met

    • Useful during dev cycle and all testing

  • #if <NAME> Pre-Processor statements

    • Technique can be used for “asserting” or other debug output in production code

    • Use project “variable” to set/unset, then very easy to enable/disable during build process


Additional application specific options
Additional Application specific options

  • Exploit application specific tools

  • For example:

    • Revit has RevitLookup API sample and debugging tool

    • AutoCAD

      • has ArxDbg and ArxDbgMgd (also vertical versions for ACA and AME)

      • Public symbol server (pdbs)

    • 3ds Max

      • Create routines that work in MAXScript context

      • has a full debug build with symbols and with some base source code

      • Public symbol server (pdbs)


Visually inspect the code
Visually Inspect the Code

  • If you have a large team of developers, source control can help

    • Source Control differences between old and new versions of source code

    • Look at file history to find out who made changes


Use debugging tools visual studio
Use Debugging Tools – Visual Studio

demo

  • Visual Studio IDE

    • VS 2010 and VS2008 IDEs are very similar for debugging

  • VS “global” Debugger Settings

    • Tools, Options, Debugging

    • Debug, Options and Settings

  • Consider Turning on Exception settings


Vs debug project settings
VS Debug Project settings

demo

  • Debugger “type”

    • Auto

    • Managed

    • Native Only

    • Mixed-mode (very useful with C++/CLI together with C++)

  • Edit and Continue (useful especially when learning)


Vs debug project settings1
VS Debug Project settings

  • Caveat for x64 vs. win32 (x86) projects

    • Edit and Continue STILL not supported in VS2010 for x64 targets

    • x64 Mixed-mode debugging also not available for .NET Framework 3.5 and prior. Only works in .NET Framework 4. The good news is that .NET Framework 4 is now supported by many Autodesk apps, but a C++ project has to be modified manually.

      • See: http://adn.autodesk.com/adn/servlet/devnote?siteID=4814862&id=16002138&linkID=4900509

    • Can build x86 targets and run under WOW, but some Autodesk apps are not supported as x86 on x64 Operating Systems (NOTE: 3ds Max is!)


Using the visual studio debugger
Using the Visual Studio debugger

Demo

(revit and acad)

  • Watch window

    • Variables

      • Autos

      • Locals

      • Watch

    • Can change variable data at runtime

    • Can use format specifiers to change the display of data

  • Step commands


Using the visual studio debugger1
Using the Visual Studio debugger

  • Breakpoint

    • To set one:

      • Press F9

      • Right Click->Set Breakpoint

      • Click in the margin

    • Halts execution at a specific line

    • Allows visualization of memory state at a given execution state

  • Step into, step over, step out, run, run to cursor

  • Right click -> Step into specific


Using the visual studio debugger2
Using the Visual Studio debugger

Demo (revit)

  • Breakpoint “types”

    • Default == break every time

    • Location

    • Condition

    • Hit Count

    • Filter (Processes and Threads)

      • For example, break in process 1, but not in 2

    • When Hit (Uses trace points)

      • Print Message: myPtr Val: $(myPtr)

      • Run macro

    • Edit Labels


Using the visual studio debugger3
Using the Visual Studio debugger

Demo (acad)

  • Other useful windows

    • Call Stack

    • Output

      • Remember to turn off output you do not want to see.

      • Can redirectto Immediate window.

    • Modules

    • Registers

    • Processes (useful in multi process apps/COM/etc.)

    • Threads

    • Memory


Using the visual studio debugger tips tricks demo
Using the Visual Studio debugger – tips/tricks/demo

demo

  • Use the breakpoint window

    • Helps you to see what break points and where

    • You can also directly set breakpoints there

    • Use labels with your break points

  • Disable, rather than delete breakpoints

  • Call Stack break point

  • Use Step into specific

  • Run to Cursor (temp break point)

  • Drag the execution pointer to another line

  • Change values in the watch window

  • Use the find tool in other windows (ie. it can help in output)

  • Turn on/off output that may or may not be interesting for you debugging session.


Symbols
Symbols

  • PDB files are the key

  • Contains the debugging information

  • Symbols also generated in “release” mode.

    • Optimization can cause “tricky” debugging

    • This is how it is possible to debug production software, using pdbs.

    • AutoCAD and 3ds Max now have public symbol servers!

      • http://symbols.autodesk.com/symbols


Symbols1
Symbols

  • When using symbols, versions MUST MATCH

    • internally a GUID is present and must match

    • Symbol servers simplify this task, but there are more “unknowns” when it doesn’t work

      • Likely we have not uploaded proper symbols, so let us know

    • Consider setting up a Symbol server internally for your own public builds

  • Great Blog article here about symbols:

    • http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx


Managed debugging
Managed debugging

demo

  • Managed APIs are often wrappers around native C++ APIs

    • This can sometimes cause strange debugging results

  • Managed debugger shares many of the same features

    • Revit

  • Mixed-Mode debugging can be very useful

    • AutoCAD

    • 3ds Max


Customer error report cer
Customer Error Report (CER)

  • CER = Customer Error Report.

  • Key Information Collected by CER

    • Mini-dump files

    • Snapshot of the memory

    • Applications Counters


Key information collected by cer
Key Information Collected by CER

  • System Information

    • Hardware information

      • Computer manufacturer

      • Amount of RAM installed

      • Number of processors

    • Video card model

      • Video card driver version

      • Configured video resolution

      • Amount of video ram

    • Operating System

    • Computer Name


Cer debugging how to debug the minidump
CER debugging – How to debug the minidump

Make sure to have the EXACT production install indicated in the CER data

Use the EXACT matching debug symbols if you have them

devenv <minidump>.dmp


Code structure tools
Code Structure tools

  • Intellisense

    • Code Model

    • Dynamic help when coding and debugging

    • Rewritten completely for VS2010 using an actual database (instead of NCB file)

  • VS2010 Ultimate has an Architecture feature

    • UML diagrams built in

    • Dependency graph

  • Visual Assist

    • Spell checker!

    • Plus many other useful helpers


Other useful tools
Other useful tools

  • Dependency Walker (depends)

    • http://dependencywalker.com/

  • SysInternals stuff

    • http://technet.microsoft.com/en-us/sysinternals/default.aspx

  • Reflector (for .NET Assemblies)

    • http://reflector.red-gate.com/download.aspx

    • (no longer free )

  • WinDbg

    • http://msdn.microsoft.com/en-us/windows/hardware/gg463009.aspx


How to debug autodesk plug ins summary
How to Debug Autodesk Plug-ins? – Summary

  • Coding Techniques

  • Additional Application specific options

  • Visually Inspect the Code

  • Use VS debugging tools

  • CER mini dump files


Developing autodesk plug ins
Developing Autodesk plug-ins

  • Autodesk has pages for most of the products that have APIs

  • The website entry for developing on a specific product is typically:

    • http://www.autodesk.com/develop<product name>

    • http://www.autodesk.com/develop3dsmax

    • http://www.autodesk.com/developmaya

    • http://www.autodesk.com/developmotionbuilder

    • http://www.autodesk.com/developfbx

    • http://www.autodesk.com/developautocad

    • http://www.autodesk.com/developrevit

    • http://www.autodesk.com/developinventor


Autodesk university session feedback
Autodesk University Session Feedback

Complete the AU Conference Survey at a survey station and receive an AU 2011 T-Shirt.

  • Your feedback is very important to Autodesk!

  • You can complete the session survey on your mobile device, PC, or at a survey station.

  • Each completed session survey enters you in that day’s drawing for a free AU 2012 pass.

  • You can help make AU 2012 better!


Questions
Questions?

Why do programmers always mix up Halloween and Christmas?

Because Oct 31 equals Dec 25!

Feel free to contact me later