Hi , I am new to the Dtrace and exited by reading the features of Dtrace. I am facing problem in printing local string variable. Consider the following example program written in C++. Here I want to print the value of variable "name" in "getName() defined inside base class. #include <iostream> #include <string.h> using namespace std; class base { private: string name; public: base(string str):name(str) { } string getName() { return name; } }; int main() { base B("XYZ"); while(true) { sleep(2); cout<<B.getName()<<endl; } } Could anybody help me in finding the answer. Thanks in advance. Regards, Siddu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20100308/4ac63d5a/attachment.html>
rick weisner
2010-Mar-08 16:35 UTC
[dtrace-discuss] To print local string value in C++ prog
see http://blogs.sun.com/rweisner/entry/dtrace_and_c_objects rick On Mon, Mar 08, 2010 at 06:29:53PM +0530, siddesh r wrote:> X-CAA-SPAM: F00000 > X-Authority-Analysis: v=1.1 cv=Ipw23gTRDFe/aqQd+eJw8AKmeEpQqlpTGi2dzkUqTfM> c=1 sm=1 a=o8gELQ5d3MoA:10 a=+m2fIHUStRf1/t0uzs6iiw==:17 > a=w0PEVsKNyt1Je2L31DcA:9 a=OSmVSa8ETVpJFLsl3OgSffRCX70A:4 > a=wPNLvfGTeEIA:10 a=y0lYlqDfCy3T7T5ERHAA:9 > a=NA5Dec-I8jcAyMemtPyx6na6FbMA:4 a=ep_KMAzDAAAA:8 > a=vej-Mc3cnFJ5S1Kj554A:9 a=79m8v0KFj_KPrU16VYQAFn5yzeUA:4 > a=CjuIK1q_8ugA:10 a=TC1Ce7_l9HwA:10 a=+m2fIHUStRf1/t0uzs6iiw==:117 > X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on > oss-mail1.opensolaris.org > X-Spam-Level: > X-Spam-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM, > HTML_MESSAGE,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.0 > X-Original-To: dtrace-discuss at opensolaris.org > Delivered-To: dtrace-discuss at opensolaris.org > DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; > h=domainkey-signature:mime-version:received:date:message-id:subject > :from:to:content-type; > bh=y5iHg5UVujob24jgCOLuzOl/CX48xra5a9HjgTFiNko=; > b=Kw+kdYIZcZpH2jY2TXG/6ntnbJZ5cxgl/fTtVsOODwO9dxiR7FX/91/b/vuYflM4dh > yJdalBLjZS/wMMRN1sO6Yt69D0jNVUAxzuAo3nzcGlYeW8Z8XmTKkyiL5I4NCykzLi+T > rKrbdsdnblAqO3iSQcGyF7jnjzUluqH8wQDmU> DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; > h=mime-version:date:message-id:subject:from:to:content-type; > b=ShJ7fY8lK6BkuGWy/HE3HW5Sr2Qxcn1WvFe5mTHOFO0JP7YPQhdHHycV2BkQw5kSDj > AyjjwUwUiZmvNrL1GhEfGwNqioULyuDQY+M8WIvyQlCyb7/3AIanMk9arqxQZstTZiyk > cu7izjI+pDTC1T6V0Tlp3eGUD3VRZRjAW/ncQ> Date: Mon, 8 Mar 2010 18:29:53 +0530 > From: siddesh r <siddu049 at gmail.com> > To: dtrace-discuss at opensolaris.org > Subject: [dtrace-discuss] To print local string value in C++ prog > X-BeenThere: dtrace-discuss at opensolaris.org > X-Mailman-Version: 2.1.13 > Precedence: list > List-Id: DTrace General Discussion <dtrace-discuss.opensolaris.org> > List-Unsubscribe: > <http://mail.opensolaris.org/mailman/options/dtrace-discuss>, > <mailto:dtrace-discuss-request at opensolaris.org?subject=unsubscribe> > List-Archive: <http://mail.opensolaris.org/pipermail/dtrace-discuss> > List-Post: <mailto:dtrace-discuss at opensolaris.org> > List-Help: <mailto:dtrace-discuss-request at opensolaris.org?subject=help> > List-Subscribe: > <http://mail.opensolaris.org/mailman/listinfo/dtrace-discuss>, > <mailto:dtrace-discuss-request at opensolaris.org?subject=subscribe> > Errors-To: dtrace-discuss-bounces at opensolaris.org > > > Hi , > I am new to the Dtrace and exited by reading the features of Dtrace. > I am facing problem in printing local string variable. > Consider the following example program written in C++. > Here I want to print the value of variable "name" in "getName() > defined inside base class. > #include <iostream> > #include <string.h> > using namespace std; > class base > { > private: > string name; > public: > base(string str):name(str) > { > } > string getName() > { > return name; > } > }; > int main() > { > base B("XYZ"); > while(true) > { > sleep(2); > cout<<B.getName()<<endl; > } > } > Could anybody help me in finding the answer. > Thanks in advance. > Regards, > Siddu> _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Rickey C. Weisner Software Development and Performance Specialist Principal Software Engineer Systems Quality Office Oracle Corporation cell phone: 615-308-1147 email: rick.weisner at oracle.com