Application Note C++ Debugging

Similar documents
Training Simulator and Demo Software


RTOS Debugger for ecos

Data Tool Platform SQL Development Tools

COLLABORATION NAVIGATING CMiC

10CS35: Data Structures Using C

Desktop, Web and Mobile Testing Tutorials

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7

Xcode Project Management Guide. (Legacy)

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Database Studio is the new tool to administrate SAP MaxDB database instances as of version 7.5.

Welcome to the topic on Master Data and Documents.

IQ MORE / IQ MORE Professional

Using the Query Analyzer

MEDIAplus administration interface

Create a New Database in Access 2010

C++ INTERVIEW QUESTIONS

Working with sections in Word

Assets, Groups & Networks

How to test and debug an ASP.NET application

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Stored Documents and the FileCabinet

Setting Up Database Security with Access 97

SAP Business Intelligence (BI) Reporting Training for MM. General Navigation. Rick Heckman PASSHE 1/31/2012

Internet Explorer 7. Getting Started The Internet Explorer Window. Tabs NEW! Working with the Tab Row. Microsoft QUICK Source

Microsoft Access 3: Understanding and Creating Queries

Generating lesson plans with. Adobe Acrobat

A Basic introduction to Microsoft Access

Code::Blocks Student Manual

The New ABAP Debugger - An Introduction. Boris Gebhardt Christoph Stoeck SAP AG

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

Chapter 15: Forms. User Guide. 1 P a g e

Developing SQL and PL/SQL with JDeveloper

Bitrix Site Manager 4.1. User Guide

Hypercosm. Studio.

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

Microsoft Access 2010 Part 1: Introduction to Access

PROJECT ON MICROSOFT ACCESS (HOME TAB AND EXTERNAL DATA TAB) SUBMITTED BY: SUBMITTED TO: NAME: ROLL NO: REGN NO: BATCH:

Microsoft Word Revising Word Documents Using Markup Tools

Infoview XIR3. User Guide. 1 of 20

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Liferay Portal User Guide. Joseph Shum Alexander Chow

Creating tables of contents and figures in Word 2013

Compute Cluster Server Lab 3: Debugging the parallel MPI programs in Microsoft Visual Studio 2005

Glossary of Object Oriented Terms

Ross Video Limited. DashBoard Server and User Rights Management User Manual

Tips and Tricks SAGE ACCPAC INTELLIGENCE

UOFL SHAREPOINT ADMINISTRATORS GUIDE

Manual English KOI Desktop App 2.0.x

UML Class Diagrams (1.8.7) 9/2/2009

EMC Smarts Network Configuration Manager

SES Project v 9.0 SES/CAESAR QUERY TOOL. Running and Editing Queries. PS Query

This section provides a 'Quickstart' guide to using TestDriven.NET any version of Microsoft Visual Studio.NET

Making Visio Diagrams Come Alive with Data

ECDL. European Computer Driving Licence. Spreadsheet Software BCS ITQ Level 2. Syllabus Version 5.0

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

SQL Server 2005: Report Builder

Previewing & Publishing

Colligo Manager 6.2. Offline Mode - User Guide

EXCEL Using Excel for Data Query & Management. Information Technology. MS Office Excel 2007 Users Guide. IT Training & Development

UML for C# Modeling Basics

SharePoint 2007 Get started User Guide. Team Sites

State of Illinois Web Content Management (WCM) Guide For SharePoint 2010 Content Editors. 11/6/2014 State of Illinois Bill Seagle

Microsoft Office. Mail Merge in Microsoft Word

Introduction to Simulink

BusinessObjects: General Report Writing for Version 5

TRACE32 Debugger Getting Started... ICD Tutorial About the Tutorial... 2

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Excel 2003 A Beginners Guide

Microsoft Word 2011: Create a Table of Contents

Project Management with Enterprise Architect

Styles, Tables of Contents, and Tables of Authorities in Microsoft Word 2010

IBM Information Server

Legal Notes. Regarding Trademarks KYOCERA Document Solutions Inc.

WINDOWS PROCESSES AND SERVICES

vrealize Business User Guide

Jet Data Manager 2012 User Guide

Prospect module. Quick reference guide. Opmetrix app version 4.10 onwards

How To Use Netsuite With Openair

SECURE MOBILE ACCESS MODULE USER GUIDE EFT 2013

Excel 2007 A Beginners Guide

Using the SAS Enterprise Guide (Version 4.2)

CooCox CoIDE UserGuide Version: page 1. Free ARM Cortex M3 and Cortex M0 IDE: CooCox CoIDE UserGuide

2010 Document Template Administration. User Guide. Document Template Administration

Shark Talent Management System Performance Reports

Rational DOORS Next Generation. Quick Start Tutorial

Colligo Manager 6.0. Offline Mode - User Guide

Creating and Viewing Task Dependencies between Multiple Projects using Microsoft Project

CATIA Tubing and Piping TABLE OF CONTENTS

BulkSMS Text Messenger Product Manual

SPSS: Getting Started. For Windows

NØGSG DMR Contact Manager

Table of Contents. Overview of Segments 2 Creating Segments 3 Managing Segments 17 Deleting Segments 23 Examples of Using Segments 24

3. Programming the STM32F4-Discovery

Working together with Word, Excel and PowerPoint

Excel 2007 Basic knowledge

Step One. Step Two. Step Three USING EXPORTED DATA IN MICROSOFT ACCESS (LAST REVISED: 12/10/2013)

Training Manual Version 1.0

Umbraco v4 Editors Manual

Transcription:

Application Note C++ Debugging TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents... High-Level Language Debugging... Application Note C++ Debugging... 1 Sample Code used by This Application Note... 2 Gathering Information of Objects... 3 Display Options Dedicated to Objects 3 Most Derived Class 5 Lifetime of the this Pointer 5 Class Conversions 6 Gathering Information of Classes... 7 C++ Overloading and Symbol Mangling... 8 Demangling 8 Ambiguous Symbols 8 Other Command Line Hints 9 ELF Loader Options... 10 Debugging in C++ Code... 11 Target Order / Source Order 11 Breakpoints 12 Application Note C++ Debugging 1

Application Note C++ Debugging Version 24-May-2016 This application note describes dedicated PowerView commands and approaches that can be helpful when C++ applications are analyzed. Sample Code used by This Application Note Further chapters will contain pictures, commands and source code that are based to a small sample. This sample code implements two classes A and B, where B is derived from A. Class A class A { public: int na1; int na2; A(){na1 = 1; na2 = 2;} A(int a1, int a2){na1 = a1; na2 = a2;} virtual int Sum() { return na1 + na2; } virtual ~A(){;} }; UML Class Diagram A na1 : int na1 : int A ( ) A (a 1 : in t, a 2 : in t) S u m () : in t ~ A ( ) B nb1 : int nb2 : int B ( ) S u m ( ) : in t ~ B ( ) Class B class B: public A { public: int nb1; int nb2; B(){nb1 = 3; nb2 = 4;} virtual int Sum() { return A::Sum()+nb1+nb2; } virtual ~B(){;} }; Application Note C++ Debugging 2 Sample Code used by This Application Note

Gathering Information of Objects Display Options Dedicated to Objects The Var.Watch or Var.View command can show the content of instances of structures or classes. The command SETUP.Var or the context menu entry Format will open a dialog with various display settings. The Inherited check box controls whether anything is displayed from the base classes. To show all known methods of the class, the Methods check box must be turned on. The integer number after a method indicates the index of that method within the Virtual Function Table. Application Note C++ Debugging 3 Gathering Information of Objects

The Hidden check box controls whether artificially created symbols are visible. V-Table By the context menu commands Indirect Dump and Indirect List it is possible to navigate to the virtual function in order to check if the values match the debug information. Application Note C++ Debugging 4 Gathering Information of Objects

Most Derived Class Generic algorithms use the polymorphic nature of classes they work with. These algorithms will handle pointers to objects that fulfill an interface or are derived from a certain parent class. The Most Derived Class is the class type that was used to create a particular instance. By default, the Var.Watch window will treat these pointers with the type that is used in the current context. The Derived option can be turned on for a certain entry of the Var.Watch window by double-clicking the tree node icon or using the context menu. void TestMostDerivedClass() { B* pb = new B(); A* pa = pb; //view content of pa here... pa = NULL; delete pb; }; or Double click here Context menu To automate the Most Derived Class feature, the [] operator can be used in Practice: ; set nb1 to 1 Var.Set (*[pa]).nb1 = 1 ; display most derived class of pa Var.View *[pa] Lifetime of the this Pointer When a none-static method of a class is called, the object instance is transferred by the call, too. Within the method a symbol named this will be valid once the stack frame start code has finished. When a method is implemented into a single line of source code, it is necessary to do assembler steps until this is alive before any other class member can be observed correctly. The this symbol can be used to show the members of the instance: Var.View this Application Note C++ Debugging 5 Gathering Information of Objects

Class Conversions The () operator can be used to cast an object to another class. ;cast this pointer to class B and display it Var.View (B*)this ;cast object at address 0x00114710 to class B and display it Var.View (B*)0x00114710 Application Note C++ Debugging 6 Gathering Information of Objects

Gathering Information of Classes There are two ways to gather information about classes: the class browser and the symbol browser. The class browser lists all known classes in the type column. Righ-clicking a class opens a context menu. The context menu, for example, provides access to the class hierarchy diagram (Select the View Class Hierarchy option). Parent Via the context menu, it is also possible to view the details of a class (Select the View Details option). Size Offset Mangled Name The symbol browser can show things that are dedicated to one class by using its capabilities to filter names. Application Note C++ Debugging 7 Gathering Information of Classes

C++ Overloading and Symbol Mangling Demangling In contrast to C, multiple functions can have the same name by using the overloading technique. The functions must then differ in their parameter signatures. In C++ object files, therefore an exported symbol is encoded using function name and parameter signature into one mangled name. The mangling can be different for different compilers. TRACE32 demangles the names controlled by symbol.demangle. The first parameter set whether the Demangler is turned on. The second parameter controls if the parameter signature is concatenated to the symbol name. Setting Behavior Symbol of A::A(int,int) symbol.demangle Off demangler switched off ct 1AFiT1 symbol.demangle On On demangler switched on A::A(int,int) symbol.demangle On Off demangler switched on, but does not concatenate parameters A::A Ambiguous Symbols Due to the overloading technique of C++, the debug information contains ambiguous short symbol names. Resolving these symbols will result in an error message: This behavior can be controlled by the symbol.match setting: Setting symbol.match Exact symbol.match Best symbol.match Choose Behavior release error message when ambiguous symbol is resolved take the first matching symbol open a symbol browser to select the right symbol Application Note C++ Debugging 8 C++ Overloading and Symbol Mangling

Other Command Line Hints C++ symbols are often very long. Therefore use the TAB key to select and automatically complete the input of a symbol. Symbols containing brackets must be enclosed in apostrophes to distinguish them from other parser functions that use brackets. The symbol browser opens and the symbol matching the passed pattern can be chosen when an input symbol contains an asterisk character. Application Note C++ Debugging 9 C++ Overloading and Symbol Mangling

ELF Loader Options The Data.LOAD.Elf command has additional parameters to tune the loader for formats or circumstances it cannot detect correctly. Option /CPP /CFRONT /NoInclude /SingleLine /SingleLineAdjacent Behavior Used for ELF/STABS format if symbols are loaded correctly. Load additional symbol information for CFront based compilers that translate C++ code to C code. Ignore debug information that is related to code in header files. One source line is assigned to multiple target code parts. Therefore the source lines are multiplied, too. In the Source Order view of the Data.List window, these lines are merged behind a + symbol. When this option is passed, the debugger doesn t multiply the source lines. The source line is assigned to the first code part. The option is similar to /SingleLine, but only takes effect, if the code parts are concatenated. Application Note C++ Debugging 10 ELF Loader Options

Debugging in C++ Code Target Order / Source Order Due to the usage of inline code, one source line can match multiple code sections. When a memory section is displayed, it can be source order or target order. Target Order Source order mixes the code sections to the order inside the source file: Target Order mode is active for HLL debugging by default. Both calls of the inline function malloc2 will create one code piece each. Due to source order these code pieces are displayed above the MultiLineTest2 function. When the function is executed by Step.Over commands, the windows selected source line will jump to the matching code lines. This can be confusing some times. Target Order Target Order displays the code in the order of ascending addresses of the code behind: In this case it is more obvious that the compile has inlined the code from the malloc2 template. The execution of the routine by Step.Over will work without any confusing jump to other source lines. Target Order display is the default in Mixed mode debugging. Application Note C++ Debugging 11 Debugging in C++ Code

Breakpoints Breakpoints to every function and symbol can be set using the For Each function. symbol.foreach "Break.Set *" A::* Sometimes it is necessary to break at a method for a certain object. This can be achieved by a breakpoint containing a condition that checks the passed this pointer of the instance. For example, the this pointer is passed by register R3 and the object has the address 0x0114710 the breakpoint for the function A::Sum would be set by: Break.Set A::Sum /CONDition Register(R3)==0114710 Application Note C++ Debugging 12 Debugging in C++ Code