CN103577304B - A kind of method and device of code dynamic analysis - Google Patents

A kind of method and device of code dynamic analysis Download PDF

Info

Publication number
CN103577304B
CN103577304B CN201210285223.8A CN201210285223A CN103577304B CN 103577304 B CN103577304 B CN 103577304B CN 201210285223 A CN201210285223 A CN 201210285223A CN 103577304 B CN103577304 B CN 103577304B
Authority
CN
China
Prior art keywords
calling
code
progress
crucial moment
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201210285223.8A
Other languages
Chinese (zh)
Other versions
CN103577304A (en
Inventor
栾涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201210285223.8A priority Critical patent/CN103577304B/en
Publication of CN103577304A publication Critical patent/CN103577304A/en
Application granted granted Critical
Publication of CN103577304B publication Critical patent/CN103577304B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The present invention provides a kind of method and device of code dynamic analysis, the method for wherein code dynamic analysis includes:A. monitor is inserted at the module calling of code, wherein output calls relevant log information with this time when the monitor occurs for the calling at this;B. the code after monitor is inserted into operation, to export the journal file being made of the log information of one or more;C. the analysis result of the code is determined according to the journal file, wherein the analysis result of the code is used to indicate the module call relation when code is run.By the above-mentioned means, the module when present invention can effectively run code calls situation to be monitored, to improve code quality, the difficulty of code maintenance is reduced.

Description

A kind of method and device of code dynamic analysis
【Technical field】
The present invention relates to the technology of code analysis, more particularly to a kind of method and device of code dynamic analysis.
【Background technology】
With the development of software technology, software product also becomes to become increasingly complex, especially while offering convenience for people It is the various softwares of enterprise-level, and size of code is huge, and which increase developers to grasp the integrally-built difficulty of software, is also made It obtains the defects of software Producing reason to be not easy to be found, so as to cause the difficulty in software maintenance.In order to preferably right Software is monitored and safeguards that the prior art proposes the method for carrying out static analysis to software code.By to software code Carry out static analysis, although it will be seen that relation of interdependence between the module of code, however, this Static Analysis Method without Situation when method is to code dynamic operation is monitored.It is appreciated that in the initial input difference of software systems, software systems Be likely to run different branches, and run different branches can cause it is different as a result, under the program branch having code Operation be perhaps normal, under the program branch having the operation of code be possible to just will appear exception.It is this since code is dynamic State is caused wrong it is not possible that be found by code static analysis when running, that is to say, that existing code static analysis skill Art can not effectively grasp the mistake occurred when code dynamic operation, increase the difficulty of software supervision and maintenance.
【Invention content】
It is existing to solve technical problem to be solved by the invention is to provide a kind of method and device of code dynamic analysis Software supervision present in technology and problem difficult in maintenance.
The present invention is to solve technical problem the technical solution adopted is that provide a kind of method of code dynamic analysis, is wrapped It includes:A. at the module calling of code be inserted into monitor, wherein the monitor at this calling occur when output with Relevant log information is called in this time;B. the code after monitor is inserted into operation, to export by the log information structure of one or more At journal file;C. the analysis result of the code is determined according to the journal file, wherein the analysis result of the code For indicating the module call relation when code operation.
According to one of present invention preferred embodiment, the step C includes:According to each log information in the journal file The homophony module of record with by mode transfer block, draw from homophony module to by the line of mode transfer block, to obtain the code entire Module call graph during operation, and using the module call graph as the analysis result of the code.
According to one of present invention preferred embodiment, the step C includes:C1. according to each item day in the journal file Will information draws the calling progress picture frame at each crucial moment of the code during operation;When C2. utilizing each crucial The calling progress picture frame at quarter generates dynamic image document, and using the dynamic image document as the analysis knot of the code Fruit, wherein the dynamic image document, which describes module of the code in multiple times of running, calls progress.
According to one of present invention preferred embodiment, the step C1 includes:C11. it extracts and records in each log information It is carved at the beginning of calling and at least one of finish time crucial moment of the moment as the code during operation;C12. For each crucial moment, determines the calling that the crucial moment is carried out at the same time, calculate each calling in the calling being carried out at the same time In the progress at the crucial moment, and draw according to the progress each called the calling progress picture frame at the crucial moment.
According to one of present invention preferred embodiment, in the step C12, the calling that crucial moment T is carried out at the same time is determined Step includes:Judge whether the closed interval carved at the beginning of the calling recorded in each log information and finish time is constituted is covered T is covered, if it is, extracting the corresponding calling in the closed interval for covering T as the calling being carried out at the same time in crucial moment T In one.
According to one of present invention preferred embodiment, in the step C12, each calling in the calling being carried out at the same time is calculated Include in the step of progress of crucial moment T:According to the thread identification recorded in each log information, the tune being carried out at the same time is determined Any one in calls all sub- calling of the X in the same thread, and all sub- calling of the X in the same thread are pressed According to the time sequencing arrangement of calling, the sub- calling sequence of X is obtained;Using X sub- calling sequence calculate X crucial moment T into Degree, wherein:When being carved more than crucial moment T at the beginning of first son of X calls, determine that X belongs to backhaul calling, and backhaul tune Progress is calculated using following equation:The progress of wherein go expression backhaul calling, Key_time indicates quarter, call at the beginning of crucial moment T, x_stime expression X1_ stime indicates what first son of X called Start time;When the finish time that last height of crucial moment T more than X calls, determine that X belongs to return calling, and return The progress that journey is called is calculated using following equation:Wherein back indicates that return is called Progress, x_etime indicate finish time of X, calln_ etime indicates the finish time that last height of X calls.
According to one of present invention preferred embodiment, the dynamic image document includes:Lantern slide document, animation document regard Frequency document.
According to one of present invention preferred embodiment, in the step A, inserted at least at the module calling with one of Types Below Enter monitor:Service access type calls or event notice type calls.
The present invention also provides a kind of devices of code dynamic analysis, including:It is inserted into unit, for the module tune in code Use is inserted into monitor, wherein output calls relevant daily record to believe with this time when the monitor occurs for the calling at this Breath;Output unit, for running the code after being inserted into monitor, to export the daily record text being made of the log information of one or more Part;Determination unit, the analysis result for determining the code according to the journal file, wherein the analysis result of the code For indicating the module call relation when code operation.
According to one of present invention preferred embodiment, the determination unit includes:Figure generation unit, for according to the daily record In file the homophony module of each log information recording with by mode transfer block, draw from homophony module to by the line of mode transfer block, with Module call graph of the code during whole service is obtained, and using the module call graph as the code Analysis result.
According to one of present invention preferred embodiment, the determination unit includes:Picture frame generation unit, for according to Each log information in journal file draws the calling progress image at each crucial moment of the code during operation Frame;Document structure tree unit generates dynamic image document, and by institute for the calling progress picture frame using each crucial moment Analysis result of the dynamic image document as the code is stated, wherein the dynamic image document describes the code multiple The module of the time of running calls progress.
According to one of present invention preferred embodiment, described image frame generation unit includes:Crucial moment determination unit, is used for It is carved at the beginning of extracting the calling recorded in each log information and at least one of the finish time moment is as the code Crucial moment during operation;Progress drawing unit determines that the crucial moment is carried out at the same time for being directed to each crucial moment Calling, calculate the progress that the crucial moment is each invoked in the calling being carried out at the same time, and paint according to the progress each called Make the calling progress picture frame at the crucial moment.
According to one of present invention preferred embodiment, the progress drawing unit determines the calling that crucial moment T is carried out at the same time Mode include:Judge to carve at the beginning of the calling recorded in each log information and whether the closed interval of finish time composition T is covered, if it is, extracting the corresponding calling in the closed interval for covering T as the tune being carried out at the same time in crucial moment T One in.
According to one of present invention preferred embodiment, the progress drawing unit calculates each tune in the calling being carried out at the same time Mode used in the progress of crucial moment T includes:According to the thread identification recorded in each log information, determines and to be carried out at the same time Any one in calling calls all sub- calling of the X in the same thread, by all sub- calling of the X in the same thread It is arranged according to the time sequencing of calling, obtains the sub- calling sequence of X;X is calculated crucial moment T's using the sub- calling sequence of X Progress, wherein:When being carved more than crucial moment T at the beginning of first son of X calls, determine that X belongs to backhaul calling, and backhaul The progress of calling is calculated using following equation:The progress of wherein go expression backhaul calling, Key_time indicates quarter, call at the beginning of crucial moment T, x_stime expression X1_ stime indicates what first son of X called Start time;When the finish time that last height of crucial moment T more than X calls, determine that X belongs to return calling, and return The progress that journey is called is calculated using following equation:Wherein back indicates that return is called Progress, x_etime indicate finish time of X, calln_ etime indicates the finish time that last height of X calls.
According to one of present invention preferred embodiment, the dynamic image document includes:Lantern slide document, animation document regard Frequency document.
According to one of present invention preferred embodiment, the insertion unit is inserted at least at the module calling with one of Types Below Enter monitor:Service access type calls or event notice type calls.
It as can be seen from the above technical solutions, can be with by being inserted into monitor at the module calling of code in the present invention Obtained after code entire run and code operation in the module that occurs call relevant journal file, by the journal file, The code analysis of reflection code runtime module call relation can be obtained as a result, the code analysis knot obtained through the invention Fruit, module when can effectively be run to code call situation to be monitored, related technical personnel are contributed to find generation in time The mass defect of code reduces the difficulty of code maintenance to improve code quality.
【Description of the drawings】
Fig. 1 is the flow diagram of the method for code dynamic analysis in the present invention;
Fig. 2 is a schematic diagram of the module call graph in the present invention;
Fig. 3 is the schematic diagram of one embodiment of the calling progress picture frame in the present invention;
Fig. 4 is the schematic diagram of another embodiment of the calling progress picture frame in the present invention;
Fig. 5 is the structural schematic block diagram of the device of code dynamic analysis in the present invention;
Fig. 6 is the structural schematic block diagram of one embodiment of determination unit in the present invention;
Fig. 7 is the structural schematic block diagram of another embodiment of determination unit in the present invention;
Fig. 8 is the structural schematic block diagram of the embodiment of picture frame generation unit in the present invention.
【Specific implementation mode】
To make the objectives, technical solutions, and advantages of the present invention clearer, right in the following with reference to the drawings and specific embodiments The present invention is described in detail.
Referring to FIG. 1, Fig. 1 is the flow diagram of the method for code dynamic analysis in the present invention.As shown in Figure 1, the party Method includes:
Step S101:Monitor is inserted at the module calling of code, when which occurs for the calling at this Output calls relevant log information with this time.
Step S102:The code after monitor is inserted into operation, to export the daily record being made of the log information of one or more File.
Step S103:The analysis result of code is determined according to journal file, wherein the analysis result of code is for indicating generation Module call relation when code operation.
Above-mentioned steps are illustrated below by specific embodiment.
Embodiment one:
As it should be appreciated by those skilled in the art that module is abstracted to function, a module can be understood as centainly The encapsulation of function, module can be with different granularity divisions, such as understand from smaller granularity, realize certain function Function is exactly a module.The function of one program is realized by mutual call of modules in code.In the present invention In, in order to get the module recalls information that code occurs in dynamic operation, the module tune in code is needed in step S101 Use is inserted into monitor, it should be appreciated by those skilled in the art that so-called monitor is exactly the code for realizing snoop logic, this hair In bright, it is that module is called to need the event monitored, and when this occurs, monitor can export and specifically call relevant daily record Information.It is inserted into monitor in code, can be realized by the various prior arts, such as by the detours technologies of Microsoft, so that it may To be easily inserted into monitor in code, it can also realize to be inserted into code by other technological means certainly and monitor Device, details are not described herein for this specification.
In step s 102, the code after monitor is inserted into operation, and in the process, module calling occurs every time will be defeated Go out one calls relevant log information therefore after code end of run, can obtain one and be made of log information with this time Journal file.
In step S103, by handling journal file, it will be able to determine the analysis result of code.In the present embodiment In, the analysis result of code is module call graph.In order to facilitate understanding, with reference to a kind of schematic construction of log information Step S103 is illustrated, it should be appreciated that this does not constitute the limitation for the journal entry covered to log information in the present invention.
In the present embodiment, a log information is expressed as(Call mark, homophony module, by mode transfer block), wherein calling mark The call relation that knowledge is indicated for indicating this log information, and homophony module and the hair for being indicated the secondary calling respectively by mode transfer block Play person and recipient.Such as a log information is expressed as(5,count,rank), be meant that the calling marked as 5, be by The calling to rank modules that count modules are initiated.
According to above-mentioned log information, in the present embodiment, step S103 includes specifically:According to each item in journal file The homophony module of log information recording draws from homophony module to by the line of mode transfer block with by mode transfer block, obtains code whole Module call graph during a operation.Referring to FIG. 2, Fig. 2 is a signal of the module call graph in the present invention Figure.
From figure 2 it can be seen that current code operation in, have occurred modules A to module D, B, C calling, wherein The calling from module B to module E, F also has occurred in modules A to the calling of module B.Line arrow direction illustrates master in Fig. 2 It is transferred to the relationship adjusted, it should be appreciated that, this is a kind of signal, and actually homophony and the relationship adjusted can also use other Mode such as word, color etc. distinguishes, should not be using this as limitation of the present invention.
Static analysis is carried out to code, cannot reflect the module call relation that code actually occurs during operation, and The method that the present invention carries out dynamic analysis to code, can reflect the call relation that code occurs during operation well. As it should be appreciated by those skilled in the art that in the static code of program, it is understood that there may be multiple logic branches, in the reality of code In execution, according to different initial input values, the module calling of generation is likely to be different, such as chart shown in Fig. 2 In the program code shown, it is likely present calling logic of the modules A to module G, but in the secondary actual motion of code, but simultaneously Such calling does not occur, it is seen then that the method that dynamic analysis are carried out to code through the invention, it can be according to different initial defeated Enter value, obtains being possible to the different and secondary relevant module call relation of initial input value, this is more conducive to related personnel couple Code is monitored, and when code existing defects, related personnel is easier to find, therefore the method for the present invention helps to improve generation Code quality.
Embodiment two:
In the present embodiment, the embodiment and embodiment one of step S101 and step S102 are essentially identical, but in step The code analysis obtained in rapid S103 is as a result, be a dynamic image document, which describes code multiple The module of the time of running calls progress.
Specifically, step S103 includes:
Step S1031:According to each log information in journal file, draw code it is each of during operation crucial when The calling progress picture frame at quarter.
Step S1032:Using the calling progress picture frame at each crucial moment, dynamic image document is generated.
For the purposes of facilitate understand, with reference to another log information schematic construction to step S1031 and S1032 into Row explanation.Likewise, this limitation for illustrating not constituting the journal entry for covering log information in the present invention.
In the present embodiment, a log information is expressed as(It calls mark, call place thread identification, homophony module, quilt Mode transfer block calls start time, calls finish time), wherein thread identification where calling is used to indicate to execute the thread called Code name calls start time and finish time is called to indicate that the start/stop time occurred is called in this time respectively.A such as daily record letter Breath is expressed as(5,TRD3,count,rank,3:12:34,3:12:45), the calling marked as 5 is meant that, where when generation Thread number is TRD3, is initiated to the calling of rank modules by count modules, is carved with finish time at the beginning of calling and is respectively 3:12:34 and 3:12:45.
In conjunction with the schematic construction of above-mentioned log information, specifically, step S1031 includes:
Step S1031_1:Extract carve at the beginning of the calling recorded in each log information and in finish time at least Crucial moment of one moment as code during operation.
Step S1031_2:For each crucial moment, determine the calling that the crucial moment is carried out at the same time, calculate simultaneously into Each of capable calling is invoked at the progress at the crucial moment, and the tune at the crucial moment is drawn according to the progress each called With progress picture frame.
Every log information has recorded two moment, is carved and ties at the beginning of this log information corresponds to calling respectively The beam moment determines that the strategy at crucial moment is in the present embodiment:It will be carved at the beginning of every log information or in finish time At least one moment extract, these moment extracted can be used as the crucial moment in the present invention, by these Crucial moment can obtain the calling progress picture frame at each crucial moment in step S1031_2.It is appreciated that when crucial The determination strategy at quarter can also have other modes, such as that moment among start time and finish time is also extracted As crucial moment etc., this specification repeats no more.Preferably, will be recorded in each log information in the present embodiment It is carved at the beginning of calling and finish time extracts the crucial moment as code during operation.
In step S1031_2, the calling that a crucial moment is carried out at the same time passes through the beginning recorded in each log information Moment and finish time it may determine that.Specifically, it is determined that crucial moment T be carried out at the same time calling the step of include:
Judge whether the closed interval carved at the beginning of the calling recorded in each log information and finish time is constituted is covered T is covered, if it is, extracting the corresponding calling in the closed interval for covering T as the calling being carried out at the same time in crucial moment T In one.Such as to crucial moment 3:12:20, it is respectively 3 to carve at the beginning of a log information with finish time:12:10 With 3:12:50, due to [3:12:10,3:12:50] 3 are covered:12:20, so [3:12:10,3:12:50] tune corresponding to The calling being carried out at the same time with the calling exactly and corresponding to crucial moment(Because at the beginning of crucial moment T is exactly some calling Quarter or finish time).It is appreciated that since computer has the ability concurrently executed, multiple calling to may operate in difference Thread in, have the case where multiple calling being carried out at the same time so as to appear in synchronization.
In step S1031_2, after obtaining the calling that crucial moment T is carried out at the same time, it is also necessary to be carried out at the same time if calculating Each of dry calling is invoked at the progress of crucial moment T.Specifically, following manner realization may be used:
According to the thread identification recorded in each log information, any one calling X in the calling being carried out at the same time is determined All sub- calling in the same thread arrange all sub- calling of the X in the same thread according to the time sequencing of calling Row, obtain the sub- calling sequence of X;Using X sub- calling sequence calculate X crucial moment T progress, wherein:
When being carved more than crucial moment T at the beginning of first son of X calls, determine that X belongs to backhaul calling, and backhaul tune Progress is calculated using following equation:The progress of wherein go expression backhaul calling, Key_time indicates quarter, call at the beginning of crucial moment T, x_stime expression X1_ stime indicates what first son of X called Start time;When the finish time that last height of crucial moment T more than X calls, determine that X belongs to return calling, and return The progress that journey is called is calculated using following equation:Wherein back indicates that return is called Progress, x_etime indicate finish time of X, calln_ etime indicates the finish time that last height of X calls.
In conjunction with the schematic construction for the log information that front is lifted, it can be seen that the corresponding calling of every log information is remembered The mark for having recorded thread where one, traverses log information, it may be determined that with X(Appointing in the calling being carried out at the same time One calling of meaning)Belong to all calling of same thread, in these calling, it is that the sub of X calls to be called caused by X.Such as It is calling of the modules A to B to call X, is had occurred again by the calling of module B to C in the calling(The calling is Y), then it is assumed that Y is The son of X calls.If in the same thread, X is Y, Z, W according to the calling that time sequencing is initiated successively, then calls Y, Z, W with regard to structure At the sub- calling sequence of X.
It is appreciated that calling of the module to another module, it should since sending out call signal, be adjusted to receiving Terminated with return signal.Such as modules A since modules A sends out call signal to module B, arrives modules A to the calling of module B The calling return signal for receiving module B terminates.Wherein modules A sends out the backhaul that call signal belongs to calling, module to module B B returns to the return that call signal belongs to calling to modules A, and backhaul is called and return calling reflects the calling residing stage, specifically Ground can also be obtained using above-mentioned progress algorithm in crucial moment T, the progress that backhaul is called or return is called.
If in crucial moment T, the calling being carried out at the same time has X(Calling of the modules A to module B),Y(Module C to module D Calling),Z(Calling of the module E to module F), and it is 0 to call the backhaul of X to call progress(Indicate that the calling just starts), call It is 0.5 that the backhaul of Y, which calls progress, and it is 0.7 to call the backhaul of Z to call progress, then can draw the calling progress chart of crucial moment T As frame is as shown in Figure 3.In figure 3, arrow present position represents calling progress, and with the variation at crucial moment, what is obtained is every The position of arrow can also change in a relevant calling progress picture frame with crucial moment, it should be appreciated that this is a kind of signal Property explanation, it is practical in calling progress can also be identified using modes such as different colors, line weights.As Another embodiment, image shown in Fig. 3 can also combine with the module call graph in embodiment one as tune With progress picture frame, referring to FIG. 4, Fig. 4 is the schematic diagram of another embodiment of the calling progress picture frame in the present invention.? In this execution of code shown in Fig. 4, modules A has occurred altogether and is arrived to B, module C to D, module E to F, module F to G, module G The calling of H, but in crucial moment T, ongoing call only has modules A to the calling of B, the calling and mould of module C to D The calling of block E to F.
After obtaining the calling progress picture frame at each crucial moment, i.e. using each key in step S1032 The calling progress picture frame at moment generates dynamic image document.In the present embodiment, dynamic image document can be video documents, For example, by using video smoothing technology, transition frames are generated using the calling progress picture frame at adjacent crucial moment, it then will be crucial Calling progress picture frame and the transition frames at moment are connected in turn, so that it may to obtain dynamic video documents.In addition, this implementation Dynamic image document in example can also be lantern slide document or animation document, such as PPT documents or Flash documents, this mode It only needs down the calling progress picture frame that crucial moment obtains being connected in turn and can obtain dynamic image document.
By embodiment two, the analysis result that the present invention obtains not only reflects the module calling pass of code at runtime System, but also reflect module of the code in multiple times of running and call progress, it can preferably reflect the Dynamic Execution of code Situation, compared with static code analysis methods, the present invention has good code monitoring ability, can effectively help exploit person Member improves code quality, or code maintenance personnel is helped to safeguard code.
It is worth illustrating, either in embodiment one or embodiment two, can be being taken in step S101 It is inserted into monitor at least one of access type module of being engaged in is called or event notice pattern block calls type calling.Wherein service Access type module is called, and refers to that a module is to realize the function of another module, example to the calling of another module As, to the calling of function B, exactly in order to realize the function of function B, and event notice pattern block calls, and refers to one in function A A module sends out event notice, is concerned about that the module of the event carries out respective handling to trigger, is also achieved that notification module pair It is notified the calling of module.
Method using the present invention, one kind in can only being called to the module of above two type individually carry out analysis or Person is analyzed two kinds of module calling.It is called to service access pattern block calling and event notice pattern block In the case of being carried out at the same time analysis, it is only necessary to be added and the relevant journal entry of call type in log information, it will be able to most The module of both the above type calling is distinguished in the analysis result obtained eventually, preferably to reflect the running shape of code Condition.
Referring to FIG. 5, Fig. 5 is the structural schematic block diagram of the device of code dynamic analysis in the present invention.As shown in figure 5, generation Code dynamic analysis device 200 include:It is inserted into unit 201, output unit 202, determination unit 203.
It is wherein inserted into unit 201, for being inserted into monitor at the module calling of code, wherein monitor is used at this Calling output and this time calling relevant log information when occurring.In the present invention, unit 201 is inserted at least with Types Below One of module calling at be inserted into monitor:Service access type calls or event notice type calls.
Output unit 202 is made of with output the log information of one or more for running the code after being inserted into monitor Journal file.
The analysis result of determination unit 203, the analysis result for determining code according to journal file, wherein code is used for Indicate module call relation when code operation.
Referring to FIG. 6, Fig. 6 is the structural schematic block diagram of one embodiment of determination unit in the present invention.In the embodiment In, determination unit 203 includes figure generation unit 2031, and figure generation unit 2031 is used for according to each log information in journal file The homophony module of record with by mode transfer block, draw from homophony module to by the line of mode transfer block, to obtain code in whole service The module call graph of period, and using module call graph as the analysis result of code.
Referring to FIG. 7, Fig. 7 is the structural schematic block diagram of another embodiment of determination unit in the present invention.In the implementation In example, determination unit 203 includes picture frame generation unit 203a and document structure tree unit 203b.Wherein picture frame generation unit 203a be used to be drawn according to each log information in journal file the calling at each crucial moment of code during operation into Spend picture frame.Document structure tree unit 203b is used for the calling progress picture frame using each crucial moment, generates dynamic image text Shelves, and using dynamic image document as the analysis result of code, wherein dynamic image document describes code in multiple operations The module at quarter calls progress.In the present invention, dynamic image document includes:Lantern slide document, animation document or video documents.
Referring to FIG. 8, Fig. 8 is the structural schematic block diagram of the embodiment of picture frame generation unit in the present invention.Such as Fig. 8 institutes Show, picture frame generation unit 203a includes:Crucial moment determination unit 203a_1 and progress drawing unit 203a_2.It is wherein crucial Moment determination unit 203a_1 carved at the beginning of being used to extract the calling that is recorded in each log information and in finish time extremely Few crucial moment of the moment as code during operation.When progress drawing unit 203a_2 is used for for each key It carves, determines the calling that the crucial moment is carried out at the same time, calculate each of the calling being carried out at the same time and be invoked at the crucial moment Progress, and draw according to the progress each called the calling progress picture frame at the crucial moment.
In the present embodiment, progress drawing unit 203a_2 determines that the mode for the calling that crucial moment T is carried out at the same time includes:
Judge whether the closed interval carved at the beginning of the calling recorded in each log information and finish time is constituted is covered T is covered, if it is, extracting the corresponding calling in the closed interval for covering T as the calling being carried out at the same time in crucial moment T In one.
In the present embodiment, when each of the calling that progress drawing unit 203a_2 calculating is carried out at the same time is invoked at key The mode of progress for carving T includes:
According to the thread identification recorded in each log information, any one calling X in the calling being carried out at the same time is determined All sub- calling in the same thread arrange all sub- calling of the X in the same thread according to the time sequencing of calling Row, obtain the sub- calling sequence of X;
Using X sub- calling sequence calculate X crucial moment T progress, wherein:
When being carved more than crucial moment T at the beginning of first son of X calls, determine that X belongs to backhaul calling, and backhaul tune Progress is calculated using following equation:The progress of wherein go expression backhaul calling, Key_time indicates quarter, call at the beginning of crucial moment T, x_stime expression X1_ stime indicates what first son of X called Start time;When the finish time that last height of crucial moment T more than X calls, determine that X belongs to return calling, and return The progress that journey is called is calculated using following equation:Wherein back indicates that return is called Progress, x_etime indicate finish time of X, calln_ etime indicates the finish time that last height of X calls.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all essences in the present invention With within principle, any modification, equivalent substitution, improvement and etc. done should be included within the scope of protection of the invention god.

Claims (12)

1. a kind of method of code dynamic analysis, including:
A. at the module calling of code be inserted into monitor, wherein the monitor at this calling occur when output with Relevant log information is called in this time;
B. the code after monitor is inserted into operation, to export the journal file being made of the log information of one or more;
C1. according to each log information in the journal file, each crucial moment of the code during operation is drawn Calling progress picture frame;
C2. the calling progress picture frame for utilizing each crucial moment, generates dynamic image document, and by the dynamic image document As the analysis result of the code, wherein the dynamic image document describe the code multiple times of running module The module call relation each called in the multiple calling being carried out at the same time of synchronization when calling progress and the code are run.
2. according to the method described in claim 1, it is characterized in that, the step C1 includes:
C11. it is carved at the beginning of extracting the calling recorded in each log information and at least one of finish time moment conduct The crucial moment of the code during operation;
C12. it is directed to each crucial moment, the calling that the crucial moment is carried out at the same time is determined, calculates in the calling being carried out at the same time It is each invoked at the progress at the crucial moment, and draws the calling progress image at the crucial moment according to the progress each called Frame.
3. according to the method described in claim 2, it is characterized in that, in the step C12, determine that crucial moment T is carried out at the same time Calling the step of include:
Judge whether the closed interval carved at the beginning of the calling recorded in each log information and finish time is constituted covers T, If it is, extracting the corresponding calling in the closed interval for covering T as in the calling that crucial moment T is carried out at the same time One.
4. according to the method described in claim 2, it is characterized in that, in the step C12, calculate in the calling being carried out at the same time Each the step of being invoked at the progress of crucial moment T includes:
According to the thread identification recorded in each log information, determine any one calling X in the calling being carried out at the same time same All sub- calling of the X in the same thread are arranged according to the time sequencing of calling, are obtained by all sub- calling in one thread To the sub- calling sequence of X;
Using X sub- calling sequence calculate X crucial moment T progress, wherein:
When being carved more than crucial moment T at the beginning of first sub- calling of X, determine that X belongs to backhaul and calls, and backhaul calling Progress is calculated using following equation:Wherein go indicates the progress of backhaul calling, key_ Time indicates quarter, call at the beginning of crucial moment T, x_stime expression X1_ stime indicates the beginning that first son of X calls Moment;When the finish time that last height of crucial moment T more than X calls, determine that X belongs to return calling, and return tune Progress is calculated using following equation:Wherein back indicate return call into Degree, x_etime indicate the finish time of X, calln_ etime indicates the finish time that last height of X calls.
5. according to the method described in claim 1, it is characterized in that, the dynamic image document includes:Lantern slide document, animation Document or video documents.
6. according to the method described in claim 1, it is characterized in that, in the step A, at least with the module of one of Types Below Monitor is inserted at calling:Service access type calls or event notice type calls.
7. a kind of device of code dynamic analysis, including:
It is inserted into unit, for being inserted into monitor at the module calling of code, wherein the monitor is for the calling at this Output calls relevant log information with this time when generation;
Output unit, for running the code after being inserted into monitor, to export the daily record being made of the log information of one or more File;
Picture frame generation unit, for according to each log information in the journal file, drawing the code in the runtime Between each crucial moment calling progress picture frame;
Document structure tree unit generates dynamic image document, and by institute for the calling progress picture frame using each crucial moment Analysis result of the dynamic image document as the code is stated, wherein the dynamic image document describes the code multiple It is each called in the multiple calling being carried out at the same time of synchronization when the module of the time of running calls progress and the code to run Module call relation.
8. device according to claim 7, which is characterized in that described image frame generation unit includes:
Crucial moment determination unit, for extracting the calling recorded in each log information at the beginning of carve and finish time in Crucial moment of at least one moment as the code during operation;
Progress drawing unit determines the calling that the crucial moment is carried out at the same time for being directed to each crucial moment, calculate simultaneously into It is each invoked at the progress at the crucial moment in capable calling, and draws the calling at the crucial moment according to the progress each called Progress picture frame.
9. device according to claim 8, which is characterized in that the progress drawing unit determine crucial moment T simultaneously into The mode of capable calling includes:
Judge whether the closed interval carved at the beginning of the calling recorded in each log information and finish time is constituted covers T, If it is, extracting the corresponding calling in the closed interval for covering T as in the calling that crucial moment T is carried out at the same time One.
10. device according to claim 8, which is characterized in that the progress drawing unit calculates the calling being carried out at the same time Each of be invoked at crucial moment T the mode of progress include:
According to the thread identification recorded in each log information, determine any one calling X in the calling being carried out at the same time same All sub- calling of the X in the same thread are arranged according to the time sequencing of calling, are obtained by all sub- calling in one thread To the sub- calling sequence of X;
Using X sub- calling sequence calculate X crucial moment T progress, wherein:
When being carved more than crucial moment T at the beginning of first sub- calling of X, determine that X belongs to backhaul and calls, and backhaul calling Progress is calculated using following equation:Wherein go indicates the progress of backhaul calling, key_ Time indicates quarter, call at the beginning of crucial moment T, x_stime expression X1_ stime indicates the beginning that first son of X calls Moment;When the finish time that last height of crucial moment T more than X calls, determine that X belongs to return calling, and return tune Progress is calculated using following equation:Wherein back indicate return call into Degree, x_etime indicate the finish time of X, calln_ etime indicates the finish time that last height of X calls.
11. device according to claim 7, which is characterized in that the dynamic image document includes:Lantern slide document moves Draw document or video documents.
12. device according to claim 7, which is characterized in that the insertion unit is at least with the mould of one of Types Below Monitor is inserted at block calling:Service access type calls or event notice type calls.
CN201210285223.8A 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis Active CN103577304B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210285223.8A CN103577304B (en) 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210285223.8A CN103577304B (en) 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis

Publications (2)

Publication Number Publication Date
CN103577304A CN103577304A (en) 2014-02-12
CN103577304B true CN103577304B (en) 2018-11-09

Family

ID=50049132

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210285223.8A Active CN103577304B (en) 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis

Country Status (1)

Country Link
CN (1) CN103577304B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104615919B (en) * 2015-02-10 2017-09-29 北京润科通用技术有限公司 A kind of file source code License control method and device
CN107122426A (en) * 2017-04-11 2017-09-01 上海众开信息科技有限公司 The monitoring acquisition methods and device of Operation Log information based on database
CN107733710A (en) * 2017-10-17 2018-02-23 平安科技(深圳)有限公司 Construction method, device, computer equipment and the storage medium of link call relation
CN109359028B (en) * 2018-08-22 2024-05-03 平安科技(深圳)有限公司 Code quality monitoring method, device, computer equipment and storage medium
CN111954058B (en) * 2020-08-13 2023-11-21 北京达佳互联信息技术有限公司 Image processing method, device, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313616A (en) * 1990-09-18 1994-05-17 88Open Consortium, Ltd. Method for analyzing calls of application program by inserting monitoring routines into the executable version and redirecting calls to the monitoring routines
CN101320350A (en) * 2008-07-17 2008-12-10 金蝶软件(中国)有限公司 Performance monitoring method and device
CN101788949A (en) * 2010-03-10 2010-07-28 中兴通讯股份有限公司 Method and device for realizing embedded type system function monitoring
CN101876938A (en) * 2009-11-11 2010-11-03 北京神州泰岳软件股份有限公司 Message queue-based application software response time measuring method
CN102053906A (en) * 2009-10-30 2011-05-11 国际商业机器公司 System and method for collecting program runtime information
CN102360328A (en) * 2011-09-29 2012-02-22 用友软件股份有限公司 Programmed monitoring device and programmed monitoring method
CN102521543A (en) * 2011-12-23 2012-06-27 中国人民解放军国防科学技术大学 Method for information semantic analysis based on dynamic taint analysis

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313616A (en) * 1990-09-18 1994-05-17 88Open Consortium, Ltd. Method for analyzing calls of application program by inserting monitoring routines into the executable version and redirecting calls to the monitoring routines
CN101320350A (en) * 2008-07-17 2008-12-10 金蝶软件(中国)有限公司 Performance monitoring method and device
CN102053906A (en) * 2009-10-30 2011-05-11 国际商业机器公司 System and method for collecting program runtime information
CN101876938A (en) * 2009-11-11 2010-11-03 北京神州泰岳软件股份有限公司 Message queue-based application software response time measuring method
CN101788949A (en) * 2010-03-10 2010-07-28 中兴通讯股份有限公司 Method and device for realizing embedded type system function monitoring
CN102360328A (en) * 2011-09-29 2012-02-22 用友软件股份有限公司 Programmed monitoring device and programmed monitoring method
CN102521543A (en) * 2011-12-23 2012-06-27 中国人民解放军国防科学技术大学 Method for information semantic analysis based on dynamic taint analysis

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向嵌入式系统的测试工具研究;杜晓东;《中国优秀硕士学位论文全文数据库信息科技辑》;20031215(第4期);第25-38页 *

Also Published As

Publication number Publication date
CN103577304A (en) 2014-02-12

Similar Documents

Publication Publication Date Title
CN103577304B (en) A kind of method and device of code dynamic analysis
CN103279840B (en) Workflow engine implement method based on dynamic language and event processing mechanism
CN111339071B (en) Method and device for processing multi-source heterogeneous data
CN107689953A (en) A kind of vessel safety monitoring method and system towards multi-tenant cloud computing
CN110677402B (en) Data integration method and device based on intelligent network card
CN103684581B (en) A kind of automated testing method of optical network unit vlan function
CN104971499B (en) Game providing server
CN107018042A (en) Method for tracing and tracing system for online service system
CN106790694A (en) The dispatching method of destination object in distributed system and distributed system
CN101754046A (en) Measuring client interactive performance using a display channel
US20220245131A1 (en) Method and system for using stacktrace signatures for bug triaging in a microservice architecture
CN113468168B (en) Multi-source heterogeneous data high-speed acquisition and processing soft control method for hoisting machinery
CN109741134A (en) Information-pushing method, device, electronic equipment and computer readable storage medium
CN104331315B (en) A kind of parsing of arbitrary levels json objects and generation method and system
CN109903012A (en) A kind of equipment quality progress monitoring system and control method
CN109829537A (en) Style transfer method and equipment based on deep learning GAN network children's garment clothes
CN106383764A (en) Data acquisition method and device
CN109966742A (en) The method and device of rendering performance data is obtained in game running
CN107506194A (en) Application version, which retracts, determines method and device
CN109960647A (en) A kind of method for testing software and device calculate equipment and storage medium
CN109167979A (en) The processing method and system of multi-path monitoring video artefacts' intellectual analysis
US9626156B2 (en) Application architecture design method, application architecture design system, and recording medium
CN106997313A (en) A kind of signal processing method of application program, system and terminal device
CN109729130A (en) Information analysis method, service server, storage medium and device
CN107343221A (en) A kind of online multimedia interaction systems and method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant