搜索
您的当前位置:首页ABSTRACT Higher Abstractions for Dynamic Analysis

ABSTRACT Higher Abstractions for Dynamic Analysis

来源:乌哈旅游
HigherAbstractionsforDynamicAnalysis

SoftwareMarcusDenker,UniversityCompositionOrlaGreevySwitzerland

ofBerne

Group

ABSTRACT

Thedevelopersoftoolsfordynamicanalysisarefacedwithchoosingfromthemanyapproachestogatheringruntimedata.Typically,dynamicanalysisinvolvesinstrumentingtheprogramunderinvestigationtorecorditsruntimebe-havior.Currentapproachesforbyte-codebasedsystemslikeJavaandSmalltalkrelyoftenoninsertingbyte-codeintotheprogramunderanalysis.However,detailedknowl-edgeofthetargetprogramminglanguageorvirtualmachineisrequiredtoimplementdynamicanalysistools.Obtainingandexploitingthisknowledgetobuildbetteranalysistoolsiscumbersomeandoftendistractsthetoolbuilderfromtheactualgoal,whichistheanalysisoftheruntimebehaviorofasystem.

Inthispaper,wearguethatweneedtoadoptahigherlevelviewofasoftwaresystemwhenconsideringthetaskofabstractingruntimeinformation.Wefocusonobject-orientedvirtualmachinebasedlanguages.Wewanttobeabletodealwiththeruntimesystemasacollectionofreifiedfirst-classentities.Weproposetoachievethisbyintroduc-ingalayerofabstraction,i.e.,abehavioralmiddlelayer.Thishastheadvantagethatthetaskofcollectingdynamicinformationisnotconcernedwithlowleveldetailsofaspe-cificlanguageorvirtualmachine.Thepositiveeffectofsuchabehavioralmiddlelayeristwofold:ontheonehanditpro-videsuswithastandardAPIforalldynamicanalysisbasedtoolstouse,ontheotherhanditallowsthetooldevelopertoabstractfromtheactualimplementationtechnique.

Keywords

DynamicAnalysis,BehavioralReflection,MetaProgram-ming,Tracing

1.INTRODUCTION

Inrecentyearstherehasbeenarevivalofinterestindy-namicanalysis[16].Systemanalysisofruntimebehaviorisvitalforperformanceanalysistodetecthotspotsofactivityandbottlenecksofexecutionormemoryallocationproblemssuchasunnecessaryobjectretention.Inareverseengineer-ingcontext,dynamicanalysisisusedistoextracthigh-levelviewsaboutthebehavioroflow-levelcomponentstofacili-tatethecomprehensionofthesystem[15,17,31].Thefocusofanalysisdeterminestherelevanceandlevelofdetailoftheinformationcapturedduringdynamicanalysis.Inthefieldofreverseengineering,thereisnoconsensusonthetypeorlevelofgranularityofruntimeinformationthatisnecessaryforaparticularanalysis.Aninherentrequirementofsuch

FacultyMicheleLanzaUniversityofInformaticsSwitzerland

ofLugano

toolsisthattheybeeasilyextensibleastherequirementsandtheresearchfocusevolves.

Dynamicanalysisyieldspreciseinformationabouttheruntimebehaviorofsystems[2].However,thetaskofwrit-ingtoolstoabstractruntimedataisnottrivial.Developersoftoolsarefacedwithmanyoptionsastherearenumeroustechniquesthataddressthetaskofcollectingruntimedata.Theapproachtotooldevelopmentandtheabstractionofdynamicdataisthereforenotstandardized.Eachindivid-ualtooladoptsaspecifictechniqueandfocusesonlow-leveldetailsofthechosentechniquetoachieveitsgoals.

Thisleadstorecurrentproblemsofallapproachesandtechniques:

•allclientsneedtore-implementlargepartsofthecoderesponsibleforgatheringtheruntimedata,and•theabstractionlevelistoolowinthesensethatclientsneedtoknowtoomuchabouttheimplementationside.Inthispaperweproposetheintroductionofanabstrac-tionlayerbasedonbehavioralreflectiontofacilitatethede-signanddevelopmentoftoolsfordynamicanalysis.Wein-troduceourreflectionframeworkandidentifyitsstrengthsandshortcomings.

Structureofthepaper.Inthenextsectionweidentifysometypicalapplicationsofdynamicanalysis.Inthiscon-textweoutlinethestateoftheartingatheringdynamicdataatruntime.Section3thenshowsproblemsandshortcom-ingsassociatedwiththecurrentapproaches.InSection4wegiveanoverviewofreflectionframeworks.InSection5weintroduceourreflectionframeworkandidentifyhowitcanbeusedtosolvetheproblemsshown,andweidentifywhatismissingfromourimplementationwiththeintentionofinitiatingadiscussionandobtainingfeedback.Section7outlinesourconclusionsandfuturework.

2.DYNAMICANALYSISTECHNIQUES

Dynamicanalysistypicallyinvolvesinstrumentingthepro-gramunderinvestigationtoexamineorrecordcertainas-pectsofitsruntimebehavior.Codeinstrumentationisamechanismthatallowsinsertionofcodeatruntimetomon-itorandtracktheruntimebehaviorofasystem.Inthissectionwereviewthetechniquescurrentlyavailableforab-stractingtheruntimebehaviorofasystem.Theunderlyingconceptsbehinddynamicanalysistoolsarecurrentlylimitedtousingthesetechniquesforextractingdynamicinformation[17].

Thegranularityandamountofbehavioraldataextractedduringtheexecutionofasystemvariesdependingonthespecificfocusofaparticularanalysistool.Dynamicanaly-sisimpliesvastamountsofdata.Asimpleexecutionofasystem’sfunctionalitycanresultinalargenumberofevents[10].Typically,dynamicanalysistoolsemployfilteringandcompressiontechniquestolimittheamountofdynamicdatacollecteddependingonaspecificfocusoftheanalysis.Forexample,ifthegoaloftheanalysisisfeaturelocation[11],thisrequiresthatarelationshipbetweentheexternalfunc-tionalitiesofasystemandthepartsofthecodethatim-plementthisfunctionalityisestablished.Therefore,itisusuallysufficienttoextracttraceeventsrepresentingthemethodcallsperformedduringtheexecutionofaspecificfunctionality[1,15].AnexampleoftracerepresentationisgivenbyRichnerandDucasse[27].Eachlinerecordstheclassofthesender,theidentityofthesender,theclassofthereceiver,theidentityofthereceiverandthemethodinvoked.Theorderofthecallsismaintained.

Analysistechniquesthatfocusonmonitoringthestateofobjectsatruntimerequireamoredetailedanalysistoex-tractinformationaboutvariableaccess.Thislevelofgran-ularityisrequiredifthefocusoftheanalysisistoinferpro-graminvariants[12].Performanceanalysistoolsgenerallyfocusonobjectcreationanddeletionandthecorrectmem-oryallocationdetails.Thustherequirementsofdynamicanalysistoolsvarydependingontheirspecificfocus.Thisisadrawback,becausetheanalysisgoalsshouldnotrestrictthetypeofinformationtobecollected.Wewanttoextractasmuchdynamicdataaspossibleandthendependingontherequirementsofaparticularanalysis,extractanduseaappropriatesubsetofthedynamicdata.

Therearevariousapproachesandlanguage-specificframe-worksthatsupporttheextractionofdynamicinformation.Wedescribethedetailsoftheunderlyingmechanismsusedbydynamicanalysistoolsinthefollowingparagraphs.Sourcecodemodification.Onewaytocontrolmes-sagepassingistoinstrumentthecodeviasourcecodemodificationandrecompilation.Themaindrawbackofthistechniqueisthatallcontrolledmethodshavetobereparsedandrecompiled.Furthermore,anotherrecompilationisneededtoreinstalltheoriginalmeth-ods.Bytecodemodification.Anotherwaytocontrolmes-sagepassingistodirectlyinsertbyte-codeintothebyte-codeofthecompiledmethods.Theintroducedbyte-codecontrolsthemessagepassing.However,thistechniquereliesheavilyonprofoundknowledgeofthebytecodeinstructionsusedbythevirtualmachines.Anotherpotentialdangerofthistechniqueisthatthesecodesarenotstandardizedandcanchange.InstrumentingtheVirtualMachine.Atechnique

forcollectingruntimeinformationisinstrumentingtheruntimeenvironmentinwhichthesystemruns.Forex-ample,theJavaVirtualMachinecanbeinstrumentedtogenerateeventsofinterest.Theadvantageofthistechniqueisthatitdoesnotrequiremodificationofthesourcecode.

TheJavaVirtualMachineProfilinginterface(JVMPI)[20]providesasetofhookstotheJVMtosignalin-terestingevents,suchasthreadstartsorobjectal-

locations.JVMTI[21]isthesucessortoJVMPIandprovidesbothawaytoinspectthestateandtocontroltheexecutionofapplicationsrunningintheJavavir-tualmachine.Itprovidesadditionalfacilitiesforbyte-codeinstrumentation.ProfilersbasedonJVMPIorJVMTIinterfacesimplementprofilingagentstointer-ceptvariousevents,suchasmethodinvocations.Un-fortunatelytheseprofilingagentshavetobewritteninplatformnativecode,contradictingtheJavamottoof“writeoncerunanywhere”.BinderdevelopedKo-morium,anovelsamplingprofilerwrittenpurelyinJavathatdirectlyinstrumentsthebytecodeofJavaprograms[4].AnotherpureJavasolutionistheJavaInteractiveProfiler(JIP)isbasedonJVMTIandpro-videscontroltoturnonandoffprofilingatruntime(seehttp://jiprof.sourceforge.net/).

MethodWrappers.Brantetal,describeacodein-strumentingtechniqueforSmalltalkbasedonmethodwrappers[5].Wrappersaremechanismsforintroduc-ingnewbehaviorthatisexecutedbeforeand/orafter,andperhapsinsteadof,anexistingmethod.Ratherthanchangingmethodlookup,theymodifythemethodobjectsthattheprocessesreturn.WrappersareeasytobuildforSmalltalkasitwasdesignedwithreflec-tivefacilitiesthatallowprogrammerstointerveneinthelookupprocess,whilethesameisnottrueforJavawhichonlysupportsintrospection.Debuggers.Itispossibletorunasystemunderthecon-trolofthedebugger.Inthiscase,breakpointsaresetatlocationsofinterest(e.g.,entryandexitofamethod).Thistechniquehastheadvantageofnotmodifiyingthesourcecodeandtheenvironment.How-everitslowsdowntheexecutionofasystemconsid-erably,andtheinstrumentationitselfcanbecumber-some.Thiscanbedoneonthesourcelevelbeforecompilations,oronbytecodeatloadtime(Java)orruntime(Smalltalk).Theabstractionlayerswedealwithareeitherthoseoftheprogramtextorthoseofbytecode.LoggingServices.Loggingcanbeusedtotrackthestate

ofarunningsystematvariouspointsintime.AgoodframeworkfordoingthiswithJavaisprovidedbylog4j(seehttp://logging.apache.org/).Thedrawbackisagainthatthisimpliesmodifyingthesourcecode.

3.CHALLENGES

Aswehaveseen,therearemultipleimplementationtech-niquesforgatheringruntimedata.Thekeyproblemisthateverynewclientapplicationhastore-implementlargepartsoftheruntimedatagatheringcodedependingonthelan-guageandruntimeenvironment.Furthermore,theabstrac-tionistoolowlevel,resultinginclientsthatareconcernedwithmanipulatingtoomanyimplementationdetails.

Inthefollowingsectionsweelaborateonthemainprob-lemsofthecurrentapproaches.

3.1Instrumentationre-implemented

Mostprojectsthatrequiretoaccessruntimedatatypicallyre-implementthedatagatheringmechanism.Instrumenta-tioncodeisinsertedatallplacesofinterestinthecode

(e.g.,atmessagesends).Inthecaseofbytecodemanipu-lationtechniques,theactualmodificationofthebytecodeisachievedusinglibraries(e.g.,Javassist[8,7]orBytesur-geon[9]).Bytecodemanipulationprovidesaverylowlevelofabstractionandrequiresdetailedknowledgeofthebyte-codeoftheprogramminglanguage.Moreover,itispronetolanguageevolution,i.e.,thespecificationoftheVMmaychange.

Thepositiveeffectofthelowlevelapproachisofcoursethatwebuildaveryspecificimplementation,tailoredex-actlytowardstheinformationneededforaspecifictask.Thedrawbackisthattheinstrumentationlogicistightlycoupledwiththeapplicationthatrequiresthedynamicdata,thusinmostcaseswewillhavetore-implementtheinstrumen-tationlogicforeachnewtask.Figure1showsanexample:Wehavetwoprojectsthatareinterestedingatheringrun-timedata(Tracer1andTracer2).Althoughbothrunonastandardvirtualmachine,bothindependentlyimplementthecodeforbytecodeinstrumentation.Wehaveseenthishappenofteninourresearch,forexampleboththetracede-buggerUnstuck[19]andatestcoveragetoolbothutilizedthesamebyte-codemanipulationlibrary(ByteSurgeon),buttheydidnotshareanyinstrumentationcode.

Tracer1Tracer2Tracer2, for specialized Virtual MachinebytecodebytecodemodificationmodificationVirtualspecialized MachineVirtual Machine Figure1:Tracetooltoday

3.2ImplementationSpecificDesigns

Implementorsoftoolsthatgatherruntimedataarefacedwiththedecisiononwhichimplementationtechniquetoadopt.Subsequently,theydesignatoolbasedonspecificknowledgeofthetargetlanguageandruntimeenvironment.Theresultingtoolinevitablyisforcedtoencodeimplemen-tationissuesintothedesignofthetool.Thus,theresultisatoolthatistightlycoupledwithaparticularruntimeenvironment.

Thisapproachhasobviousdrawbacks.Itisverydiffi-culttochangetheadoptedimplementationtechnique:e.g.,bytecodemanipulationisportable,butaspecializedvir-tualmachinemightbefaster.Whentheimplementationtechniqueiscloselytiedtoaparticularvirtualmachine,weareboundtothisoneimplementation,wecannotswitchtoabyte-codebasedimplementationonacase-to-casebasis.Figure1showsthatforaspecialvirtualmachine,weneedtore-implementoursystem.

4.BEHAVIORALREFLECTION

SystemslikeSmalltalkandCLOSmodeltheirownstruc-tures(classes,methods)asfirstclassobjects.

Thetermintrospectiondefinestheabilitytoquerythesystemaboutthisinformation,whereaswetalkaboutin-tercessionwhenchangestothesestructuresdirectlychangethestructureofthesystemitself.Systemsthatprovidebotharecalledreflective.

Structuralreflectionisconcernedwithreificationoftheprogramanditsabstracttypes.Behavioralreflection,ontheotherhand,isconcernedwiththeabilityofthelan-guagetoprovidecompletereificationofitsownsemanticsandimplementationaswellascompletereificationofthedataandimplementationoftheruntimesystem.

Popularobjectorientedlanguagesprovidedifferentde-greesofintrospectionorreflectivecapabilities.Smalltalkis,tosomeextent,areflectivesystem[13,3]:Classesandmeth-odsareobjects,wecanchangethoseobjectstochangethestructureofthesystem.Javaand.NETontheotherhand,haveonlyintrospectivefeatures(i.e.,allowsforqueryinganobjectforitsclass,aclassforitsmethodsandconstruc-tors,querythedetailsofthosemethodsandconstructors,andtellthosemethodstoexecute),andpartialintercession(intercessionislimitedtomethodinvocationandattributemanipulation)[6].

Languagesthatfacilitatethedescriptionofmethodsasfirstclassobjectsinherentlysupportdynamicanalysis.ThemethodwrapperstechniqueexploitsthefirstclassnatureofmethodsinSmalltalkforprovidingawaytointerceptmethodexecution[5].ExamplesofdynamicanalysistoolsbuiltonthemethodwrappertechniqueareGreevyandDucasse’sTraceScrapertoolforfeatureanalysis[15]andJohnBrant’sInteractionDiagramandCoverageTools[5].Howevermethodexecutionisjustanaspectofruntimeinfor-mation.Foracompletedynamicanalysisweneedtofocusonotherruntimeeventssuchase.g.,messagesendsbetweenobjectinstancesorinstancevariableaccess.Thus,werec-ognizetheneedtodefineareflectivemetarepresentationthatdescribesallbehavioralaspectsofsystems.Wewantasystemthatcanreifythoseeventsondemand,providingasystemwithfullbehavioralreflection.

InbothJavaandSmalltalk,thereflectionmechanismsprovidedareconcernedmostlywithstructure.Theydonotprovideaneasywaytochangethesemanticsoftherun-timemodel:Messagesends,instancevariableaccessarenotmodeledwithobjects.Atruebehavioralreflectivesystemmodelsbehaviorinawaythatitisfirstclassandchangesarepossible:e.g.,weareabletodefineourownversionofwhatamessagesendis.

Lookingbackintothehistoryofobjectorientedsystems,wecanfindthattherehasbeenextensiveresearchonbe-havioralreflectivesystems,e.g.,theworkdonearoundMetaObjectProtocols[22]forCLOS.Themetaobjectprotocolprovidesalloperations(e.g.,methodactivationorvariableaccess)tobereifiedandre-defined.

InsystemslikeJavaandSmalltalk,behavioralreflectioncanberealisedviaspecialvirtualmachinesorbytecodema-nipulation,withthelatterbeingportable.ExamplesforthevirtualmachineapproachareIguana/J[26],Metaxa[14],orGuarana[25].Theprimeexampleforabytecodemodifica-tionbasedmetaobjectprotocolisReflex[30].Reflexpro-videsamodelforbehavioralreflectionthatallowsforaveryfinegrainedselectionofwhenandwhattoreify.

5.THEBEHAVIORALFRAMEWORK

Thedrawbackswehaveidentifiedwithcurrentapproaches

leadustosuggestthatthesolutionwouldbetointroduceanadditionallayerofabstractiontooursystem,whichwerefertoasabehavioralframework.

Wenowanalyzehowabehavioralreflectionframeworkcouldbeusedtotackleandsolvetheproblemsofpreviousapproachestogatheringruntimeinformation.

Tracer1Tracer2Behavioral Reflection FrameworkBytecode modificationspecialized Virtual Machine Virtual MachineFigure2:Acommonabstractionlayer

5.1ASharedAPI

Withtheexistenceofabehaviorallayer,alltoolscoulduseittohookintoruntimeevents.Theindividualtoolsarenolongerconcernedwithaspecificcodeinsertionimplemen-tation.Instead,theyjustleveragetheabstractionsprovidedbythebehaviorallayerframework.

InFigure2weseeagainourtwotoolsthatareinter-estedindynamicinformation.Nowbothtoolsjustusethebehaviorallayer,thustheydonotneedtoimplementthebyte-codemodificationcodethemselves,butshareit.

5.2APluggableImplementation

Anotherimportantrequirementofanabstractionlayeristoprovideahighdegreeofflexibility,butatthesametimeretainthesameinterfaceforclients.Theproposedbehav-ioralframeworkshouldmakeitpossibletohaveapluggableimplementation(thebackend):itcanberealizedviaeditingbyte-code,achangedvirtualmachineorothermeans.

Figure2showshowwenowcanusebothprogramsonthemodifiedvirtualmachine,withouthavingtoimplementthelogicourselves:Alltoolsusingtheabstractionlayerwillworkonboththestandardvirtualmachineandanyspecial-izedvirtualmachinethattheabstractionlayersupports.

5.3Requirements

Inthefollowingweidentifyalistofrequirementsforabehavioralframeworktotacklethechallengesweidentifiedpreviously.

Runtimeinstallation:Weneedtointroducebehaviordy-namicallyatruntime.Whenwearedonewiththeanalysis,itshouldbepossibletoreverttotheoriginalstateofthesystem.Unanticipateduse:Thebehavioralchangeshouldbepos-sibleatanytimeinthedeployedsystem,withouttheneedtopreparethesysteminanywayatstartup.

Fine-GrainedSelection:Theoperationoccurrenceswe

areinterestedinaredifferentdependingonwhatweanalyze.Wewanttobeabletoselecttheentitiesuptothelevelofthesingleoccurrenceinthecode.ImplementationHiding:Fromadynamicanalysisper-spective,wearenotinterestedintheunderlyingmech-anismsofobtainingruntimeinformation.Thefun-damentalgoalofabehaviorallayeristoallowustoabstractfromthedetailsofaspecificimplementationtechnique(e.g.,VMchange,byte-codeextension,byte-codemodification)usedtoextractbehavioralinforma-tionfromanapplicationatruntime.Performance:Tomaketheframeworkusableforanalyz-ingrealworkapplications,weneedaframeworkwithlowoverhead.Thebestcasewouldbeasystemwherewepayexactlythesameoverheadasifweweretoannotatethecodewithprofilingcallsbyhand.

5.4Implementation

Wehaverealizedaframeworkforpartialbehavioralreflec-tionforSqueak(adialectofSmalltalk)calledGeppetto[28].Geppettousestheruntimebyte-codetransformationframe-workByteSurgeon[9]andfollowsthemodelofpartialbehav-ioralreflectionaspioneeredbyReflex[30].UnlikeReflex,whichisconstrainedbytheunderlyingmodeloftheJavalanguage,ourGeppettoimplementationcanbeusedcom-pletelyunanticipated:codedoesnotneedtobepreparedatloadorcompiletime,reflectioncanbeenabledatruntimeandcompletelyretractedwhennotneeded.

Geppettoallowsforreifyingmessagesending,methodexe-cutionandvariableaccess(readandwrite)forbothinstancevariablesandtemporaryvariables.Selectionisveryfine-grained:perpackage,class,object,method,operationandoperationoccurrence.GeppettocanbeusedinanySqueakprogram,withouttheneedtoadaptitatloadorstarttime.Installationhappenstransparentlyatruntime.

GeppettousesByteSurgeontoinsertsmallpeacesofcode,socalledhooksintothebytecodewhereaselectedoperation(e.g.messagesend)occurs.Figure3showsthemodelindetail.Hooksaregroupedtohooksets,whichareboundtoametaobjectbyalink.Thelinkdefinestheprotocolbetweenthebaseandthemetalayer.Linkscanbeenabledordisabledbasedonanactivationcondition.

metaobjectlinksactivationconditionhookset

Figure3:Hooksets,LinksandMetaobjectsinGep-petto

ForacompletedescriptionoftheGepettobehavioralre-flectionframework,see[28].

5.5Usage

ThebehavioralreflectionframeworkprovidesageneralAPI:thereificationofruntimeeventstriggerscallstometaobjects,whichareinstancesofnormalclasses.Thetooldeveloperthusisfreetousetheframeworkasneededbyspecifyingwhichconceptstoreifyandwhichinformationtopassontothemetaobject.Theframeworkdoesnotprovideamodelofthedataobtained(e.g.,atrace),insteaditprovidesamodelforobtainingdata.Itcanbeeitherstoredforlateruseasatraceorprocessedandreactedonatruntime.ThelatterhaslatelybecomeanactivetopicofresearchwithsystemslikePQL[24].

6.DISCUSSION

Wenowanalyzeourbehavioralframeworkwithrespecttotherequirementsdefinedintheprecedingsectionanddefinefuturework.Thenwebrieflydiscusstherelationshiptoaspectorientedprogrammingandtheusefulnessofprovidingscopingabstractionsaspartoftheframework.

6.1NextSteps

Theimplementationasdescribedinsection5.4,alreadyfulfillssomeoftherequirementsstated:Itcaninstall(andretract)behavioralchangesatruntime,providesfine-grainedspatialandtemporalselectionbyimplementingtheReflexmodel[30]andsupportsunanticipateduse.Tworequirementsarenotyetfulfilled:1.Geppettoneedstobeextendedtosupportpluggablebackends.Weareworkingonprovidingabackendbasedonannotatedabstractsyntaxtrees.2.Weneedtoverifytherealworldusability:firstbench-marksshowgoodperformancecharacteristics,butGep-pettoneedstobevalidatedwithrealworldusage.Weplantomovethetoolsandexperimentsdonethatcur-rentlyuseByteSurgeontouseGeppettoinstead.

6.2Aspects

Thispaperpresentsthesolutionfromtheperspectiveofbehavioralreflection.AnotherpointofviewcanbethatofAspectOrientedProgramming.Theproposedabstractionlayercoulduse,asabackend,anexistingdynamicaspectsimplementation.Inthiscase,theaspectframeworkwouldbeusedasahigh-levelreplacementforbyte-codemanipula-tion.

Anotherpossibilitywouldbetoformulatethemiddlelayerintermsofadynamicaspectframeworkinsteadofmetaob-jects.Theproblemhereisthatmostaspectsystems(e.g.,AspectJ[23])arestatic:weavinghappensatcompileorloadtime.PureruntimeAspectsarenotyetverycommonandthosethatexistarebasedthemselvesinsomecasesonbe-havioralreflectionfacilities,forexampleAspectS[18]andas-pectsystemsbasedonReflex[29].

6.3ScopeAbstractions

ModernimplementationslikeReflexprovideveryfine-grainedspatialandtemporalselectionofreification.Herewecanselectwhatandwhere,inatemporalandspacialway.

Thismeanswecanscopethereificationtowardscollec-tionsofclasses(likemodulesandpackages)orsinglein-stances,asinglemethodsofaclass,oreventoonecertain

occurrenceofabehavioralevent.Temporalselectionmeansthatwecanswitchreificationsonandoffatwill,thuswecanmakethegatheringofruntimedatabecontrolledbyruntimeevents.

Anotherideaofscopingisthatofscoping-towards-the-client:Wemightbeinterestedineventsgeneratedonlyifourpackageundertestiscalledfromacertainotherpack-age.Thiscanbeusefultolimittheamountofunnecessarydatawhene.g.,analysingsystemclasseslikeSmalltalkscol-lections.

7.CONCLUSION

Inthispaperweaddressedafundamentalproblemthatfacesthedevelopersoftoolsthatexploitruntimeinforma-tionofanapplication.Weproposeannewapproachtodesigningdynamicanalysistoolsforvirtualmachinebasedlanguagesthatinteractwithalayerofabstraction,namelyabehaviorallayer.Thebehaviorallayershouldprovideaframeworkfortooldevelopersthatencapsulatetypicalob-jectorientedlanguageconstructsatruntimesuchasobjectinstantiation,messagesendsandinstancevariableaccess.Thusthedeveloperhasaccesstoreifiedfirstclassentitiesofruntimebehaviorandfocusesonthesehighlevelabstrac-tionswhendesigningaspecifictool.Themainadvantageofthislayerofabstractionisthattheresultingtoolshouldeas-ilyportabletousewithothervirtualmachinesasthereifiedentitiesareindependentoftheunderlyingimplementationdetailsandbyte-codes.Moreoverthedeveloperisnotcon-cernedwithlowleveldetailsthatarespecifictoaparticularvirtualmachine.

Inthispaperweprovidedashortoverviewoftheavail-abletechnologiesandapproachestoextractruntimedata.Weidentifiedproblemsinherenttotheseapproaches.Thismotivatesourargumentthatthereisaneedtointroducealayerofabstractionbetweenlowlevelimplementationde-tailsandthetoolsanalysingthedata.

Tobetterunderstandtheunderlyingmotivationofabe-haviorallayerweprovidedashortoverviewofsomeoftheapplicationsofdynamicanalysis.Inthefieldofprogramcomprehensionandreverseengineeringdynamicanalysisap-proachesarebecomingmoreprevalent.Howeverthereisnostandardapproachtoextractingruntimedatanorisitclearwhichtypeofruntimeinformationtoextract.Thereforesuchtoolsneedtobeextensible,asrequirementschange.Weidentifiedalistofrequirementsforabehaviorallayer.Wedescribeourcurrentimplementationofabehaviorallayerandillustratehowitcanbeusedtoaddresstheprob-lems.Weshowhowwesimplifythetaskofimplementingdynamicanalysistools.

Acknowledgments.Wegratefullyacknowledgethefi-nancialsupportoftheSwissNationalScienceFoundationfortheprojects“Analyzing,capturingandtamingsoftwarechange”(SNFProjectNo.200020-113342,Oct.2006-Sept.2008))and“NOREX-NetworkofReengineeringExpertise”(SNFSCOPESProjectNo.IB7320-110997).

8.REFERENCES

[1]GiulianoAntoniolandYann-Ga¨elGu´eh´eneuc.Feature

identification:anovelapproachandacasestudy.InProceedingsIEEEInternationalConferenceon

SoftwareMaintenance(ICSM2005),pages357–366,

LosAlamitosCA,September2005.IEEEComputerSocietyPress.

[2]

ThomasBall.Theconceptofdynamicanalysis.InProceedingsEuropeanSoftwareEngineeringConferenceandACMSIGSOFTInternationalSymposiumontheFoundationsofSoftware

Engineering(ESEC/FSC1999),number1687in

LNCS,pages216–234,Heidelberg,sep1999.SpringerVerlag.

[3]

AlexandreBergelandMarcusDenker.Prototypinglanguages,relatedconstructsandtoolswithSqueak.InInProceedingsoftheWorkshoponRevivalofDynamicLanguages(co-locatedwithECOOP’06),July2006.

[4]

WalterBinder.AportableandcustomizableprofilingframeworkforJavabasedonbytecodeinstructioncounting.InProceedingsofTheThirdAsian

SymposiumonProgrammingLanguagesandSystems(APLAS-2005),volume3780ofLNCS,pages178–194,Tsukuba,Japan,nov2005.

[5]

JohnBrant,BrianFoote,RalphJohnson,andDonRoberts.Wrapperstotherescue.InProceedings

EuropeanConferenceonObjectOrientedProgramming(ECOOP1998),volume1445ofLNCS,pages

396–417.Springer-Verlag,1998.methodwrappers.[6]

WalterCazzola.Smartreflection:Efficient

introspectioninjava.JournalofObjectTechnology,3(11),August2004.

[7]

S.ChibaandM.Nishizawa.Aneasy-to-usetoolkitforefficientJavabytecodetranslators.InProceedingsofGPCE’03,volume2830ofLNCS,pages364–376,2003.[8]

ShigeruChiba.Load-timestructuralreflectioninJava.InProceedingsofECOOP2000,volume1850ofLNCS,pages313–336,2000.

[9]

MarcusDenker,St´ephaneDucasse,andEric´Tanter.

RuntimebytecodetransformationforSmalltalk.JournalofComputerLanguages,SystemsandStructures,32(2-3):125–139,July2006.St´ephaneDucasse,MicheleLanza,andRolandBertuli.High-levelpolymetricviewsofcondensed

run-timeinformation.InProceedingsofConferenceonSoftwareMaintenanceandReengineering(CSMR2004),pages309–318,LosAlamitosCA,2004.IEEEComputerSocietyPress.

ThomasEisenbarth,RainerKoschke,andDanielSimon.Locatingfeaturesinsourcecode.IEEEComputer,29(3):210–224,March2003.

MichaelD.Ernst,JakeCockrell,WilliamG.Griswold,andDavidNotkin.Dynamicallydiscoveringlikelyprograminvariantstosupportprogramevolution.InProceedingsofICSE’99,May1999.

BrianFooteandRalphE.Johnson.Reflective

facilitiesinSmalltalk-80.InProceedingsOOPSLA’89,ACMSIGPLANNotices,volume24,pages327–336,October1989.

MichaelGolmandJ¨urgenKlein¨oder.Jumpingtothemetalevel:Behavioralreflectioncanbefastandflexible.InReflection,pages22–39,1999.OrlaGreevyandSt´ephaneDucasse.Correlatingfeaturesandcodeusingacompacttwo-sidedtraceanalysisapproach.InProceedingsIEEEEuropeanConferenceonSoftwareMaintenanceand

Reengineering(CSMR2005),pages314–323,LosAlamitosCA,2005.IEEEComputerSocietyPress.[16]

A.Hamou-Lhadj.Theconceptoftrace

summarization.InProceedingsofPCODA2005(1stInternationalWorkshoponProgramComprehensionthroughDynamicAnalysis).IEEEComputerSocietyPress,2005.

[17]

A.Hamou-LhadjandT.Lethbridge.Asurveyoftraceexplorationtoolsandtechniques.InProceedingsIBMCentersforAdvancedStudiesConferences(CASON2004),pages42–55,IndianapolisIN,2004.IBMPress.[18]

RobertHirschfeld.AspectS–aspect-oriented

programmingwithSqueak.InM.Aksit,M.Mezini,andR.Unland,editors,Objects,Components,Architectures,Services,andApplicationsforaNetworkedWorld,number2591inLNCS,pages216–232.Springer,2003.

[19]

ChristophHofer,MarcusDenker,andSt´ephaneDucasse.Designandimplementationofabackward-in-timedebugger.InProceedingsofNODE’06,2006.

[20]Sunmicrosystems,inc.jvmprofilerinterface(jvmpi).[21]Sunmicrosystems,inc.jvmtoolinterface(jvmti).[22]

GregorKiczales,JimdesRivi`eres,andDanielG.Bobrow.TheArtoftheMetaobjectProtocol.MITPress,1991.

[23]

GregorKiczales,ErikHilsdale,JimHugunin,MikKersten,JeffreyPalm,andWilliamG.Griswold.AnoverviewofAspectJ.InProceedingECOOP2001,number2072inLNCS,pages327–353.SpringerVerlag,2001.

[24]

MickaelMartin,BenjaminLivshits,andMonicaS.Lam.Findingapplicationerrorsandsecurityflawsusingpql:aprogramquerylanguage.InProceedingsofObject-OrientedProgramming,Systems,Languages,andApplications(OOPSLA’05),pages363–385,NewYork,NY,USA,2005.ACMPress.

[25]

A.OliviaandL.E.Buzato.ThedesignandimplementationofGuaran´a.InProceedingsofthe5thUSENIXConferenceonObject-OrientedTechnologiesandSystems(COOTS’99),pages203–216,SanDiego,California,USA,May1999.

[26]

BarryRedmondandVinnyCahill.Supportingunanticipateddynamicadaptationofapplication

behaviour.InProceedingsofEuropeanConferenceonObject-OrientedProgramming,volume2374,pages205–230.Springer-Verlag,2002.[27]

TamarRichnerandSt´ephaneDucasse.Usingdynamicinformationfortheiterativerecoveryofcollaborationsandroles.InProceedingsIEEEInternational

ConferenceonSoftwareMaintenance(ICSM2002),page34,LosAlamitosCA,October2002.IEEEComputerSocietyPress.

[28]

DavidR¨othlisberger,MarcusDenker,andEric´Tanter.

Unanticipatedpartialbehavioralreflection.InProceedingsofISC2006(InternationalSmalltalkConference),LNCS,toappear,2006.[29]

Eric´TanterandJacquesNoy´e.Aversatilekernelformulti-languageAOP.InProceedingsofthe4thACMSIGPLAN/SIGSOFTConferenceonGenerativeProgrammingandComponentEngineering(GPCE2005),volume3676ofLNCS,Tallin,Estonia,sep

[10]

[11]

[12]

[13]

[14]

[15]

2005.´[30]EricTanter,JacquesNoy´e,DenisCaromel,andPierreCointe.Partialbehavioralreflection:Spatialandtemporalselectionofreification.InProceedingsofOOPSLA’03,ACMSIGPLANNotices,pages27–46,nov2003.

[31]A.ZaidmanandS.Demeyer.Managingtracedata

volumethroughaheuristicalclusteringprocessbasedoneventexecutionfrequency.InProceedingsIEEEEuropeanConferenceonSoftwareMaintenanceandReengineering(CSMR2004),pages329–338,LosAlamitosCA,March2004.IEEEComputerSocietyPress.

因篇幅问题不能全部显示,请点此查看更多更全内容

Top