c/c++ tools & methodology demonstration he zongjian [email protected] school of software...
TRANSCRIPT
C/C++ Tools & Methodology C/C++ Tools & Methodology demonstrationdemonstration
He ZongjianHe Zongjian
[email protected]@yahoo.com
School of Software EngineeringSchool of Software Engineering
Tongji UniversityTongji University
AgendaAgenda
Project management in Visual StudioProject management in Visual Studio Develop Resource lookupDevelop Resource lookup Debugging with Visual StudioDebugging with Visual Studio Introduction to Windows GUI AppsIntroduction to Windows GUI Apps Sample application of C++ projectSample application of C++ project ReferencesReferences DiscussionDiscussion
Project management in Project management in Visual StudioVisual Studio
Common Bad HabitCommon Bad Habit
Create a *.c / *.cpp fileCreate a *.c / *.cpp file Open it with Visual StudioOpen it with Visual Studio CompileCompile
Bad EffectBad Effect
NO Intelligent SenseNO Intelligent Sense Class View / File View disabledClass View / File View disabled Can NOT debuggingCan NOT debugging Can NOT locate definitionsCan NOT locate definitions
An Expensive NotepadAn Expensive Notepad
What is Workspace & ProjectWhat is Workspace & Project
Configuration files that help us managing thConfiguration files that help us managing the projecte project
A workspace can have multiple projectA workspace can have multiple project Workspaces have the .dsw extensionWorkspaces have the .dsw extension Projects have the .dsp extensionProjects have the .dsp extension Double click the workspace can auto launch Double click the workspace can auto launch
the Developer studiothe Developer studio
Other files used by devenvOther files used by devenv
.ncb : Visual C++ IntelliSense Database.ncb : Visual C++ IntelliSense Database .rc : Resource template.rc : Resource template .pch : Precompiled header.pch : Precompiled header .obj : Intermediate file.obj : Intermediate file .pdb : Program debugging database.pdb : Program debugging database .bsc : Browse information.bsc : Browse information .clw : Class wizard file (MFC only).clw : Class wizard file (MFC only)
Using File View & Class ViewUsing File View & Class View
File View :File View :– Add new fileAdd new file– Delete fileDelete file
Class View :Class View :– Locate functions & variablesLocate functions & variables– Add new classAdd new class– Add member functions and member variablesAdd member functions and member variables
Project configurationProject configuration
Debug version VS Release VersionDebug version VS Release Version Enable RTTIEnable RTTI Command line argumentsCommand line arguments
Useful TipsUseful Tips
Code auto formatting (Alt + F8)Code auto formatting (Alt + F8) Go to definitionGo to definition Go to referenceGo to reference Find in filesFind in files Open documentOpen document
New features in VS.NETNew features in VS.NET
.dsw -> .sln.dsw -> .sln Integrated IDEIntegrated IDE Measure up to C++ standardMeasure up to C++ standard …………
Develop Resource lookupDevelop Resource lookup
Microsoft Developer NetworkMicrosoft Developer Network(MSDN)(MSDN)
All develop related resourcesAll develop related resources Online Version:Online Version:
– http://http://msdnmsdn..microsoftmicrosoft.com.com– Released every 4 monthsReleased every 4 months
Visual Studio 6.0 Version (.chm)Visual Studio 6.0 Version (.chm)– VB 6, VC 6, VFP 6, VJ 6, VID 6, Platform SDKVB 6, VC 6, VFP 6, VJ 6, VID 6, Platform SDK
After Jan 2002, Visual Studio.NET VersionAfter Jan 2002, Visual Studio.NET Version– .NET framework.NET framework
Demo : Demo : How to use MSDNHow to use MSDN
Other ResourcesOther Resources
Knowledge BaseKnowledge Base– http://support.http://support.microsoftmicrosoft.com.com
TechNetTechNet– http://http://technettechnet..microsoftmicrosoft.com.com
Developer Works (IBM)Developer Works (IBM)– http://www.ibm.com/developerworks/http://www.ibm.com/developerworks/
Debugging with Visual StudioDebugging with Visual Studio
What is debugging?What is debugging?
A process for identifying the root cause of a A process for identifying the root cause of a problem by tracing program execution flow problem by tracing program execution flow and underneath memory status.and underneath memory status.
Beneficial after performing general Beneficial after performing general troubleshooting steps.troubleshooting steps.
Basic debugging knowledgeBasic debugging knowledge
Symbols : The PDB files generated with youSymbols : The PDB files generated with your binaries by VSr binaries by VS
Debugging toolsDebugging tools– Visual StudioVisual Studio– Windbg / CDB ( For Windows )Windbg / CDB ( For Windows )– Debug ( For MS-DOS )Debug ( For MS-DOS )– Gdb ( For Linux / Unix / AIX )Gdb ( For Linux / Unix / AIX )
Common Debug ScenarioCommon Debug Scenario
Logic ErrorLogic Error Memory LeakMemory Leak Access Violation (AV)Access Violation (AV)
Basic MethodologyBasic Methodology
Set break pointSet break point Step into / Step over / Step outStep into / Step over / Step out Variables monitor (Local / Watch / Auto)Variables monitor (Local / Watch / Auto) Call stackCall stack MemoryMemory RegisterRegister DisassemblyDisassembly
Demo :Demo :How to use Visual Studio.NET How to use Visual Studio.NET
to debuggingto debugging
Advanced MethodologyAdvanced Methodology
Conditional BreakpointConditional Breakpoint Remote debugging (GDI / Kernel)Remote debugging (GDI / Kernel) JIT debuggingJIT debugging Debugging running processDebugging running process Debugging crash dumpDebugging crash dump Multithread debuggingMultithread debugging
Demo :Demo :Conditional BreakpointConditional Breakpoint
Attach to a processAttach to a process
Solving Access ViolationSolving Access Violation
Buffer Overflow / UnderflowBuffer Overflow / Underflow– Heap CorruptionHeap Corruption– Stack CorruptionStack Corruption
Memory Access DeniedMemory Access Denied– Raw PointerRaw Pointer– Double FreeDouble Free
The HintThe Hint
Debuggers are just toolsDebuggers are just tools We must also :We must also :
– Know the productKnow the product– Know the languages and their implications Know the languages and their implications
(compiler implementation)(compiler implementation)– Know the operating systemKnow the operating system– Know the CPUKnow the CPU– Know the toolsKnow the tools
Introduction to Windows GUI Introduction to Windows GUI ApplicationsApplications
What does GUI App ContainsWhat does GUI App Contains
Entry Point : WinMainEntry Point : WinMain Register a window classRegister a window class Create and Show a WindowCreate and Show a Window Message LoopsMessage Loops Windows Procedure (WinProc)Windows Procedure (WinProc) Resource TemplateResource Template
Demo : Demo : Create and analyze a GUI Create and analyze a GUI
applicationapplication
Sample application Sample application of C++ projectof C++ project
Demo :Demo :Text Miner 1.0Text Miner 1.0
Cheat Killer 0.02 Cheat Killer 0.02
ReferencesReferences
C / C++ referencesC / C++ references
Thinking in C++ 2nd Edition Thinking in C++ 2nd Edition Bruce EckelBruce Eckel
C++ Primer C++ Primer Stanley B.LippmanStanley B.Lippman
The C++ Programming Language 3rd EditionThe C++ Programming Language 3rd Edition
Bjarne StroustrupBjarne Stroustrup
C / C++ references (Cont’d)C / C++ references (Cont’d)
The C++ Standard Library The C++ Standard Library 侯捷 译侯捷 译
STLSTL 源代码剖析 源代码剖析 侯捷 著侯捷 著
The C++ template The C++ template David VandevoordeDavid Vandevoorde
Inside C++ Object Model Inside C++ Object Model Stanley B.LippmanStanley B.Lippman
GUI ProgrammingGUI Programming
Programming Windows 4Programming Windows 4thth Edition Edition
Charles PetzoldCharles Petzold MFC Windows MFC Windows 程序设计 程序设计 22ndnd Edition Edition
Jeff ProsiseJeff Prosise Programming Microsoft Visual C++Programming Microsoft Visual C++
David J. KruglinskiDavid J. Kruglinski
Debugging ReferencesDebugging References
Debugging Application Debugging Application John RobbinsJohn Robbins
Debugging Applications for Microsoft .NET aDebugging Applications for Microsoft .NET and Microsoft Windows nd Microsoft Windows John RobbinsJohn Robbins
Debugging Windows ProgramsDebugging Windows Programs
Everett N. McKayEverett N. McKay
DiscussionDiscussion
© 2003 Tongji University. All rights reserved.© 2003 Tongji University. All rights reserved.This presentation is for informational purposes only. TJSSE MAKES NO WARRANTIEThis presentation is for informational purposes only. TJSSE MAKES NO WARRANTIE
S, EXPRESS OR IMPLIED, IN THIS SUMMARY.S, EXPRESS OR IMPLIED, IN THIS SUMMARY.
Thanks!
Question?