CDT Source Code Framework Analysis Transformation of threading object (III.)

Source: Internet
Author: User

Requirements: When stop tracking is clicked on the debug system, if the number of cache frames is nonzero, the basic information of the first frame is displayed by default (ID of the trace point, thread ID. such as

Add a Stop trace event, which is said later in this mechanism. Icdistoptraceevent.

The Cthread object implements the Icdieventlistener interface, so it stops tracking events when it departs. The Handledebugevents method of the class intercepts this command.

In the CDT, each Debug object has an object with a presentation layer and a CDT layer

such as thread objects.

The Cthread object is located in Eclipse's core package. It uses the thread object of the CDT layer through the Getcdithread () method bar.

Thread implementation of the command and other operations.

The Icdithread excuse contains some of the user's operating instructions

For example Here we customize the information of the display frames.

cthread{ ... publicvoidhandledebugevents (icdievent[] events) {if(isdisposed ())return;  for(inti = 0; i < events.length; i++) {Icdievent event=Events[i]; Icdiobject Source=Event.getsource (); if(Eventinstanceoficdistoptraceevent) {                //Stop track Point eventshandlestoptraceevent ((icdistoptraceevent) event);
}
.....}


Private void handlestoptraceevent (Icdistoptraceevent event) { this. Getcdithread (). Showframe ( Event.getframenum ()); Firechangeevent (Debugevent.starttrace); }

Firechangeevent Refresh Interface

Modify the name of the thread

In Eclipse plug-in development, the content provider, the label provider MVC, is used to display it.

Cdebugmodelpresentation This class as the provider class for all tags.

The contents of the thread label display are divided into several parts. Object name, state, thread name, and status information.

This modifies the Getthreadtext method of the label class. Refactor to the GetFrameText method.

Re-add the frame Name field in the Cdebuguimessages. Here, all the thread is replaced with a frame. Add a change to a state at the same time. Thread.istraceing (). If the tracking status displays its status.

    protectedString GetFrameText (Ithread thread,BooleanQualified)throwsdebugexception {icdebugtarget target= (Icdebugtarget) thread.getdebugtarget (). Getadapter (Icdebugtarget.class ); if(Target.ispostmortem ()) {returnGetformattedstring (cdebuguimessages.getstring ("Cdtdebugmodelpresentation.f8"), Thread.getname ());//$NON-nls-1$        }        //here is the decision to add a boot trace, if the trace is started, the status is displayed        if( !thread.istraceing ()) {            returnGetformattedstring (cdebuguimessages.getstring ("Cdtdebugmodelpresentation.f28"), Thread.getname ());//$NON-nls-1$        }        if(Thread.istraceing ()) {returnGetformattedstring (cdebuguimessages.getstring ("cdtdebugmodelpresentation.f29"), Thread.getname ());//$NON-nls-1$}

All right. Make model judgments. If it is a KGTP model, it is modified to frame.

PrivateString Getbasetext (Object element) {Else if(elementinstanceofithread) {                intMode=(( Ikidelaunch) ((ithread) Element). Getlaunch ()). Getdebugmode (); //make a model judgment here. If it's KGTP , it shows the frame information.                if(Mode==iztelaunchconfigurationconstants.kide_debug_kgtp_mode) {label.append (GetFrameText (ithread) element, showqualified)); }ElseLabel.append (Getthreadtext ((ithread) element, showqualified)); }}

OK, now start doing, query frame content

Add a command to query frames

 PackageOrg.eclipse.cdt.debug.mi.core.command;Importorg.eclipse.cdt.debug.mi.core.MIException;ImportOrg.eclipse.cdt.debug.mi.core.output.MISelectFrameFomFrameIdInfo;ImportOrg.eclipse.cdt.debug.mi.core.output.MIInfo;ImportOrg.eclipse.cdt.debug.mi.core.output.MIOutput;ImportOrg.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo; Public classMiselectframefomframeidactionextendsMicommand { Publicmiselectframefomframeidaction (String miversion,string id) {Super(Miversion, "-trace-find frame-number" +ID); }     PublicMiselectframefomframeidinfo Getmiframeselectinfo ()throwsmiexception {return(Miselectframefomframeidinfo) getmiinfo (); }     PublicMiinfo Getmiinfo ()throwsmiexception {miinfo info=NULL; Mioutput out=Getmioutput (); if(Out! =NULL) {Info=NewMithreadselectinfo (out); if(Info.iserror ()) {throwmiexception (info, out); }        }        returninfo; }}

Miselectframeinfo the parse class for return. It is divided into several types, done,error. Do not explain the specific.

/*** * * Display the basic information of the frame. here because **/@Override Public voidShowframe (intframenum) {                if(framenum>0) {target target=(Target) gettarget (); Misession mi=target.getmisession (); Commandfactory Factory=mi.getcommandfactory (); //Miselectframefomframeidaction frames = Factory.selectframefromframeid ((0+ ""). Trim ()); Try{Mi.postcommand (frames); } Catch(miexception e) {//TODO Auto-generated catch blockE.printstacktrace (); }            Try{Name= "[Track point number:" +frames.getmiframeselectinfo (). Gettraceframe () + ", Method name:" +frames.getmiframeselectinfo (). Getframefunc ()+ ", Address is" +frames.getmiframeselectinfo (). GETFRAMEADDR () + "]"; } Catch(miexception e) {//TODO Auto-generated catch blockE.printstacktrace (); }                                        }        //TODO Auto-generated method stubs//}

CDT Source Code Framework Analysis Transformation of threading Objects (iii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.