Browse Prior Art Database

Method for formatting C++ objects in a storage dump

IP.com Disclosure Number: IPCOM000015466D
Original Publication Date: 2002-May-21
Included in the Prior Art Database: 2003-Jun-20
Document File: 2 page(s) / 40K

Publishing Venue

IBM

Abstract

In reading a storage dump from a C++ application, it is helpful in the debug process to be able to view the attributes of objects, given a pointer to the object. However, for object oriented languages like C++ the attributes of an object are placed in storage in a manner not known to the application or the debugger. Being able to find and format the attributes of a C++ object in a storage dump without requiring internal knowledge of the compiler processing or making extensive manual updates to the application code would solve this problem. Assume the existence of a dump of storage in some sort of file and some application which allows access to it and the ability to run 'formatter' code that process it. Assume that the application whose data is contained within the dump consists of C++ code including a set of headers defining the various application classes (including attributes and methods).

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 52% of the total text.

Page 1 of 2

Method for formatting C++ objects in a storage dump

In reading a storage dump from a C++ application, it is helpful in the debug

process to be able to view the attributes of objects, given a pointer to the object. However, for object oriented languages like C++ the attributes of an object are placed in storage in a manner not known to the application or the debugger. Being able to find and format the attributes of a C++ object in a storage dump without requiring internal knowledge of the compiler processing or making extensive manual updates to the application code would solve this problem.

Assume the existence of a dump of storage in some sort of file and some application which allows access to it and the ability to run 'formatter' code that process it.

Assume that the application whose data is contained within the dump consists of C++ code including a set of headers defining the various application classes (including attributes and methods).

A pre-compiler could be written that would scan the headers, finding each class definition and implementing, in the headers, for each class a static method which would take as input a pointer to an object of the given class. The pointer need not actually point to an object of the type at runtime. The method implemented by the pre-compiler would examine the address of each attribute of the class relative to the address of the object. This can be done without actually examining the object itself (the compiler knows where it put the attributes, so it can return an address of an object attribute given the object pointer without actually looking at the object). The generated code maintains max values for attribute locations plus and minus (ahead/behind) the object pointer. The pre-compiler would also generate a call to the same method implemented on any parent class. Results from calls to parent classes will be compared to results for this class to generate a final result. The result of this method is the storage range (plus and minus) relative to the pointer within which the objects attributes lie.

The pre-compiler would also implement a second static method for each class which would take as input a pointer to an object of a given class. This pointer actually points to an object of the given class at runtime, however any pointers contained as attributes will contain invalid values for reasons to be seen. This second method returns an array of structures, each structure containing information about formatting a particular attribute of the object (e.g. attribute name, offset relative to the object pointer, attribute type (e.g. pointer to another object type, long, cha...