CN103425565B - The method and system of acquisition program operation information - Google Patents

The method and system of acquisition program operation information Download PDF

Info

Publication number
CN103425565B
CN103425565B CN201210151244.0A CN201210151244A CN103425565B CN 103425565 B CN103425565 B CN 103425565B CN 201210151244 A CN201210151244 A CN 201210151244A CN 103425565 B CN103425565 B CN 103425565B
Authority
CN
China
Prior art keywords
function
address
file
program
entrance
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
CN201210151244.0A
Other languages
Chinese (zh)
Other versions
CN103425565A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201210151244.0A priority Critical patent/CN103425565B/en
Publication of CN103425565A publication Critical patent/CN103425565A/en
Application granted granted Critical
Publication of CN103425565B publication Critical patent/CN103425565B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention provides the method and system of acquisition program operation information, wherein, the method comprises: the address file obtaining Program Generating, and described address file comprises during program is run the function address of each function called, and obtains the MAP file of program; By the function address comprised in address file, from MAP file, inquire about corresponding function name; By the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generate the operational flow diagram of call function.The present invention program can obtain program operation information to graphically intuitively.

Description

The method and system of acquisition program operation information
Technical field
The program that the present invention relates to runs field, particularly relates to the method and system of acquisition program operation information.
Background technology
Multiple function can be called when program is run.In practice, often need to know which function of routine call, and the operational scheme of call function.
At present, only have partial higher platform can get program operation information based on Addr2line instrument, and final what obtain is the function name of the function called in program operation process.Addr2line instrument is an instrument in GNUBinutils, and GNUBinutils is a whole set of programming language tools formula, is one group of binary tools collection.On other occasions, Addr2line instrument can convert the address of instruction and executable image to filename sum functions name.The installation of Addr2line instrument is complicated, and environment for use compares limitation, can not be used for general situation.
As seen from the above, the Measures compare limitation of existing acquisition program operation information, and the function name that the program that can only obtain is called in running; If the graphic process situation of function call in program operation process can be obtained, will be more directly perceived, but also there is no the technology of this respect at present.
Summary of the invention
The invention provides a kind of method obtaining program operation information, the method can obtain program operation information to graphically intuitively.
The invention provides a kind of system obtaining program operation information, this system can obtain program operation information to graphically intuitively.
Obtain a method for program operation information, the method comprises:
Obtain the address file of Program Generating, described address file comprises during program is run the function address of each function called, and obtains the MAP file of program;
By the function address comprised in address file, from MAP file, inquire about corresponding function name;
By the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generate the operational flow diagram of call function.
Obtain a system for program operation information, this system comprises acquiring unit, query unit and process flow diagram generation unit;
Described acquiring unit, for obtaining the address file of Program Generating, described address file comprises during program is run the function address of each function called, and sends described query unit and described process flow diagram generation unit to; And obtain the MAP file of program, send described query unit to;
Described query unit, for by the function address comprised in address file, inquires about corresponding function name, sends described process flow diagram generation unit to from MAP file;
Described process flow diagram generation unit, for by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generates the operational flow diagram of call function.
As can be seen from such scheme, after the present invention obtains the address file of Program Generating, MAP file polling in conjunction with program goes out function name, then, by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generate the operational flow diagram of call function.Like this, achieve and obtain program operation information intuitively to graphically; Further, the present invention is based on the function name that MAP file obtains in program operation process the function called, and compiler corresponding to nearly all system platform can the MAP file of generator program, thus, make the range of application of the present invention program more extensive.
Accompanying drawing explanation
Fig. 1 is the method indicative flowchart that the present invention obtains program operation information;
Fig. 2 is the method flow diagram example that the present invention obtains program operation information;
Fig. 3 is the address file example that the present invention generates;
Fig. 4 is the operational flow diagram generated according to the address file of Fig. 3;
Fig. 5 is the system architecture schematic diagram that the present invention obtains program operation information.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly understand, below in conjunction with embodiment and accompanying drawing, the present invention is described in more detail.
The present invention first obtains the function name of the function called in program operation process based on MAP file, then inputs DOT file, generates the operational flow diagram of call function.See Fig. 1, for the present invention obtains the method indicative flowchart of program operation information, it comprises the following steps:
Step 101, obtains the address file of Program Generating, and described address file comprises during program is run the function address of each function called, and obtains the MAP file of program.
Program need obtain the installation kit of program, install installation kit before running; Particularly, bag can be downloaded and installed from network side server, also can receive the installation kit of other network node transmissions.Installation kit is generated by compiler, and compiler is program higher level lanquage being compiled into machine language.For different system platforms, need to adopt different compilers to compile program, to generate the installation kit that can perform at corresponding system platform; Such as, for Android system platform, server needs to adopt compiler corresponding to Android system platform to compile program, to generate the installation kit that can perform at Android system platform.And compiler corresponding to nearly all system platform all generates MAP file after support program compiling, MAP file in order to information such as save routine globak symbol, source file and code line numbers, comprising the mapping relations between function address function name.
After installation kit is installed, working procedure, the function address writing address file of each function that program will be called in operational process.Particularly, the present invention is by configuring entrance function and export function in a program, and realize function address writing address file, entrance function and being configured in the generative process of installation kit of export function complete.The generation of installation kit comprises:
Judge whether compiler supports that GUN compiler is set with (GCC, GNUCompilerCollection) compiling, if so, then adds entrance and exit configuration function in a program, is configured all entrance functions in program and export function; Otherwise, detect all functions in program, added before the entrance of each function and configure entrance function, add after the outlet of each function and configure export function;
Compiler compiles program, generates installation kit and MAP file.
GCC is a set of programming language compiler developed by GNU, and GNU is the operating system of a class UNIX, and target is to set up the free software environment that is compatible to UNIX completely.
The content of entrance function and export function can be arranged as required, in order to complete different functions, in the present invention, in order to the output of measure for fulfill address in follow-up program operation process.
If the type of compiler is GCC compiling, shows that compiler can add entrance function automatically before the entrance of each function, after the outlet of each function, add export function; The present invention is configured all entrance functions in program and export function, to realize function address writing address file in follow-up program operation process; If the type of compiler is not GCC compiling, show that compiler can not, automatically for each function in program adds entrance function and export function, need to add separately; In the present invention, detect all functions in program, added before the entrance of each function and configure entrance function, add after the outlet of each function and configure export function, add and the entrance function configured and export function in order to realize function address writing address file in follow-up program operation process.
Then, when program is run, first call corresponding entrance function before call function, entrance function is by the entry address writing address file of function; When exiting function, call corresponding export function, export function is by the exit address writing address file of function.
Entrance function and export function are except except the output of measure for fulfill address, also can realizing the output of allocating time and post-set time.Correspondingly, during the entry address writing address file of entrance function by function, also corresponding entry address writes allocating time in address file; During the exit address writing address file of export function by function, also corresponding exit address writes post-set time in address file.
Step 102, by the function address comprised in address file, inquires about corresponding function name from MAP file.
Step 103, by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generates the operational flow diagram of call function.
DOT language is a kind of text pattern descriptive language, it provides a kind of method of simple description figure.According to the feature of DOT file, by function name according to function call order input DOT file, then, specifically can adopt this DOT file of Graphviz tool to open, just can generate the operational flow diagram of call function.Graphviz is an Open-Source Tools bag, for drawing the figure that DOT language scripts describes.
If entrance function and export function not only can output function addresses, also exportable allocating time and post-set time, so, when function name being inputted DOT file according to function calling relationship described in this step, also comprise: the exit address time corresponding with function address deducts the entry address time, obtain the working time of function, corresponding each function name will input DOT file working time, comprise the working time of corresponding each function name in the operational flow diagram of generation.
Check the operational scheme of program to graphically, can learn better to understand program structure, and whether the operation of energy trace routine is normal; Further, also according to the function operation time of display, can analyze and optimizer.
Be illustrated the method that the present invention obtains program operation information below by Fig. 2, it comprises the following steps:
Step 201, judges whether compiler supports that GCC compiles, and if so, then performs step 202, otherwise performs step 203.
Step 202, adds entrance and exit configuration function in a program, is configured all entrance functions in program and export function, performs step 204.
If compiler supports GCC, then can add the entrance and exit configuration function of GCC.Entrance configuration function is such as:
void_cyg_profile_func_enter(void*func_address,void*call_site)
_attribute_((no_instrument_function));
Outlet configuration function is such as:
Void_cyg_profile_func_exit(void*func_address,void*call_site)
_attribute_((no_instrument_function));
Choose-the finstrument-functions in compiler and-g option during compiling, carry out the compiling of entrance and exit configuration function.
Step 203, detects all functions in program, adds and configured entrance function before the entrance of each function, add and configure export function after the outlet of each function, performs step 204.
Entrance function is expressed as: _ cyg_profile_func_enter function, and export function is expressed as:
_ cyg_profile_func_exit function.
Step 204, compiler compiles program, and generate installation kit and MAP file, described MAP file comprises the mapping relations between function address function name.
MAP file is carried in installation kit, also can leave assigned address in separately.
Step 205, obtains the installation kit of program, installs, working procedure, calculated address file to installation kit, and described address file comprises during program is run function address and the time of each function called, and obtains the MAP file of program.
When program is run, before call function, first call corresponding entrance function, when exiting function, call corresponding export function.The entry address writing address file of the function that will call in _ cyg_profile_func_enter function, and before address, add letter " E " (also can substitute with other letter), represent that this address is entry address, and export allocating time.The exit address writing address file of the function called in _ cyg_profile_func_exit function, and before address, add letter " O " (also can substitute with other letter), represent that this address is exit address, and export post-set time.After program is run, calculated address file, as shown in Figure 3, wherein only shown out the function address of each function successively called, temporal information is not shown in figure address file.
Entrance, the exit address of each function that in store program is operationally called in address.txt, if having an entry address (being set to A) in address.txt immediately following another entry address (being set to B), then show that A have invoked B.With the allocating time deducting identical entry address, address post-set time of address.txt middle outlet address, obtain the T.T. that respective function is run.
Step 206, by the function address comprised in address file, inquires about corresponding function name from MAP file.
Particularly, grep order can be adopted, go out function name corresponding to function address according to address file at MAP ff.Grep order is conventional detection look-up command.
Step 207, by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, simultaneously, the exit address time corresponding with function address deducts the entry address time, obtain the working time of function, corresponding each function name will input DOT file working time.
When writing function name in DOT file, the mode of storehouse can be adopted to write, particularly, read the address information in address.txt file one by one, when often encountering an entry address, just by corresponding function name press-in storehouse, the function name of stack top represents last invoked function; If be and then another entry address, this function corresponding to entry address just read from address.txt file of the function call that stack top function name is corresponding is described below.
Step 208, with Graphviz tool to open DOT file, generates the operational flow diagram of call function.
Fig. 4 is the operational flow diagram generated according to the address file of Fig. 3, the example of Fig. 3 have invoked 5 functions, here suppose that the function name corresponding to function address of sequence number 1-5 instruction is respectively A, B, C, D and E, call relation is that A calls B, B calls C, C calls D, and D calls E, and the working time of A, B, C, D and E is respectively 20 seconds, 5 seconds, 45 seconds, 20 seconds and 80 seconds.
After the present invention obtains the address file of Program Generating, MAP file polling in conjunction with program goes out function name, then, by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generate the operational flow diagram of call function.Thus, achieve and obtain program operation information intuitively to graphically; Further, the present invention is based on the function name that MAP file obtains in program operation process the function called, and compiler corresponding to nearly all system platform can the MAP file of generator program, like this, makes the range of application of the present invention program more extensive.
See Fig. 5, for the present invention obtains the system architecture schematic diagram of program operation information, this system comprises acquiring unit, query unit and process flow diagram generation unit;
Described acquiring unit, for obtaining the address file of Program Generating, described address file comprises during program is run the function address of each function called, and sends described query unit and described process flow diagram generation unit to; And obtain the MAP file of program, send described query unit to;
Described query unit, for by the function address comprised in address file, inquires about corresponding function name, sends described process flow diagram generation unit to from MAP file;
Described process flow diagram generation unit, for by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generates the operational flow diagram of call function.
Acquiring unit, query unit and process flow diagram generation unit are placed in the current device of working procedure.
Alternatively, this system also comprises installation kit acquiring unit, for obtaining the installation kit of program, installs installation kit;
This system also comprises installation kit generation unit, for judging whether compiler supports that GCC compiles, if so, then adds entrance and exit configuration function in a program, is configured all entrance functions in program and export function; Otherwise, detect all functions in program, added before the entrance of each function and configure entrance function, add after the outlet of each function and configure export function; Compiler compiles program, and generate installation kit and MAP file, described MAP file comprises the mapping relations between function address function name.
Installation kit generation unit can be placed on network side server, also can be placed in other network nodes.When needed, the installation kit acquiring unit of current device obtains installation kit from installation kit generation unit.
Alternatively, current device also comprises program running unit, and for when working procedure, first call corresponding entrance function before call function, entrance function is by the entry address writing address file of function; When exiting function, call corresponding export function, export function is by the exit address writing address file of function; And according to the request of described acquiring unit, address file is sent to described acquiring unit.
Alternatively, during the entry address writing address file of entrance function by function, also corresponding entry address writes allocating time in address file; During the exit address writing address file of export function by function, also corresponding exit address writes post-set time in address file.
Alternatively, described process flow diagram generation unit, also for when function name is inputted DOT file according to function calling relationship, the exit address time corresponding with function address deducts the entry address time, obtain the working time of function, corresponding each function name will input DOT file working time, comprise the working time of corresponding each function name in the operational flow diagram of generation.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within the scope of protection of the invention.

Claims (10)

1. obtain a method for program operation information, it is characterized in that, the method comprises:
The address file that acquisition program generates in operational process, described address file comprises during program is run the function address of each function called, and obtains the MAP file of program;
By the function address comprised in address file, from MAP file, inquire about corresponding function name;
By the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generate the operational flow diagram of call function.
2. the method for claim 1, is characterized in that, before the address file of described acquisition Program Generating, the method also comprises: the installation kit obtaining program, installs installation kit; The generation of installation kit comprises:
Judge whether compiler supports that GUN compiler is set with compiling, if so, then add entrance and exit configuration function in a program, all entrance functions in program and export function are configured; Otherwise, detect all functions in program, added before the entrance of each function and configure entrance function, add after the outlet of each function and configure export function;
Compiler compiles program, and generate installation kit and MAP file, described MAP file comprises the mapping relations between function address function name.
3. method as claimed in claim 2, is characterized in that, when program is run, first call corresponding entrance function before call function, entrance function is by the entry address writing address file of function; When exiting function, call corresponding export function, export function is by the exit address writing address file of function.
4. method as claimed in claim 3, is characterized in that, during the entry address writing address file of entrance function by function, also corresponding entry address writes allocating time in address file; During the exit address writing address file of export function by function, also corresponding exit address writes post-set time in address file.
5. method as claimed in claim 4, it is characterized in that, during by function name according to function calling relationship input DOT file, the method also comprises: the exit address time corresponding with function address deducts the entry address time, obtain the working time of function, corresponding each function name will input DOT file working time, comprise the working time of corresponding each function name in the operational flow diagram of generation.
6. obtain a system for program operation information, it is characterized in that, this system comprises acquiring unit, query unit and process flow diagram generation unit;
Described acquiring unit, for obtaining the address file that program generates in operational process, described address file comprises during program is run the function address of each function called, and sends described query unit and described process flow diagram generation unit to; And obtain the MAP file of program, send described query unit to;
Described query unit, for by the function address comprised in address file, inquires about corresponding function name, sends described process flow diagram generation unit to from MAP file;
Described process flow diagram generation unit, for by the function address write sequence determination function call order in address file, by function name according to function call order input DOT file, generates the operational flow diagram of call function.
7. system as claimed in claim 6, it is characterized in that, this system also comprises installation kit acquiring unit, for obtaining the installation kit of program, installs installation kit;
This system also comprises installation kit generation unit, for judging whether compiler supports that GUN compiler is set with compiling, if so, then adding entrance and exit configuration function in a program, being configured all entrance functions in program and export function; Otherwise, detect all functions in program, added before the entrance of each function and configure entrance function, add after the outlet of each function and configure export function; Compiler compiles program, and generate installation kit and MAP file, described MAP file comprises the mapping relations between function address function name.
8. system as claimed in claim 7, is characterized in that, this system program running unit, and for when working procedure, first call corresponding entrance function before call function, entrance function is by the entry address writing address file of function; When exiting function, call corresponding export function, export function is by the exit address writing address file of function; And according to the request of described acquiring unit, address file is sent to described acquiring unit.
9. system as claimed in claim 8, is characterized in that, during the entry address writing address file of entrance function by function, also corresponding entry address writes allocating time in address file; During the exit address writing address file of export function by function, also corresponding exit address writes post-set time in address file.
10. system as claimed in claim 9, it is characterized in that, described process flow diagram generation unit, also for when function name is inputted DOT file according to function calling relationship, the exit address time corresponding with function address deducts the entry address time, obtain the working time of function, corresponding each function name will input DOT file working time, comprise the working time of corresponding each function name in the operational flow diagram of generation.
CN201210151244.0A 2012-05-16 2012-05-16 The method and system of acquisition program operation information Active CN103425565B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210151244.0A CN103425565B (en) 2012-05-16 2012-05-16 The method and system of acquisition program operation information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210151244.0A CN103425565B (en) 2012-05-16 2012-05-16 The method and system of acquisition program operation information

Publications (2)

Publication Number Publication Date
CN103425565A CN103425565A (en) 2013-12-04
CN103425565B true CN103425565B (en) 2016-01-06

Family

ID=49650351

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210151244.0A Active CN103425565B (en) 2012-05-16 2012-05-16 The method and system of acquisition program operation information

Country Status (1)

Country Link
CN (1) CN103425565B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104899016B (en) * 2014-03-07 2018-10-09 腾讯科技(深圳)有限公司 Allocating stack Relation acquisition method and device
CN105354498A (en) * 2015-10-30 2016-02-24 珠海市君天电子科技有限公司 Operation method of registry, related device and equipment
US11636122B2 (en) * 2015-12-30 2023-04-25 Futurewei Technologies, Inc. Method and apparatus for data mining from core traces
CN105786512A (en) * 2016-02-29 2016-07-20 浪潮(苏州)金融技术服务有限公司 Program generation method and dimension manager
CN107168857B (en) * 2017-03-31 2021-01-01 武汉斗鱼网络科技有限公司 Method and assembly for counting function calls in application program
CN107480029B (en) * 2017-08-02 2019-02-15 北京深思数盾科技股份有限公司 A kind of monitoring method and device of function call time
CN107977236B (en) * 2017-12-21 2020-11-13 上海智臻智能网络科技股份有限公司 Question-answering system generation method, terminal device, storage medium and question-answering system
CN108304303A (en) * 2018-01-03 2018-07-20 珠海金山网络游戏科技有限公司 A kind of method and system of the script runnability of statistics frame sync server
CN109656805B (en) * 2018-09-28 2022-01-25 创新先进技术有限公司 Method and device for generating code link for business analysis and business server
CN112148392A (en) * 2019-06-27 2020-12-29 腾讯科技(深圳)有限公司 Function call chain acquisition method and device and storage medium
CN111104104A (en) * 2019-11-04 2020-05-05 珠海亿智电子科技有限公司 Method and device for visualizing function call time and statistical result and readable medium
CN112882912B (en) * 2021-02-01 2022-10-25 华东师范大学 Function runtime measurement method applied to parallel scientific computation program

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101178684A (en) * 2006-11-06 2008-05-14 中兴通讯股份有限公司 Symbol locating method of embedded system
CN102147743A (en) * 2011-03-28 2011-08-10 博视联(苏州)信息科技有限公司 Method for accelerating startup of embedded system application program

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120084758A1 (en) * 2010-10-05 2012-04-05 International Business Machines Corporation Collaborative Software Debugging In A Distributed System With Client-Specific Variable Evaluation

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101178684A (en) * 2006-11-06 2008-05-14 中兴通讯股份有限公司 Symbol locating method of embedded system
CN102147743A (en) * 2011-03-28 2011-08-10 博视联(苏州)信息科技有限公司 Method for accelerating startup of embedded system application program

Also Published As

Publication number Publication date
CN103425565A (en) 2013-12-04

Similar Documents

Publication Publication Date Title
CN103425565B (en) The method and system of acquisition program operation information
US11868231B2 (en) System and method for evaluating code by a hybrid of local and cloud-based computers
US9298427B2 (en) Creating inferred symbols from code usage
CN102880546B (en) Software integration testing method and system based on extensible markup language (XML) database
Paige et al. The design of a conceptual framework and technical infrastructure for model management language engineering
US8490050B2 (en) Automatic generation of user interfaces
EP1089172A2 (en) Compiler and method for compiling specification language into implementation language
US20080276221A1 (en) Method and apparatus for relations planning and validation
CN111736954B (en) Multi-intelligent contract virtual machine implementation method, multi-intelligent contract virtual machine and system
US20110283253A1 (en) Enforcement of architectural design during software development
CN104932905A (en) Automatic code generation method from AADL to C language
CN101980546B (en) Intelligent network platform, service execution method and method for analyzing service abnormality
US10303468B2 (en) Real-time quality of service monitoring apparatus and method
CN114153463B (en) Management system service function creating method and system based on script compiler
CN110209565B (en) Metadata model debugging method and device
CN104375932A (en) Method and device for analyzing code coverage rate of Java card
CN116069334B (en) Cloud-protogenesis-based online development and code hosting method and system
CN105893104A (en) Code compiling method and device
KR20180099044A (en) Supervisory control and data acquisition system and script language compile method
CN103677907A (en) Installation method and installation device for environmental forecast type application components
Zeiss et al. Refactoring and metrics for TTCN-3 test suites
CN115809076A (en) ECU software automation integration method and system
Bandur et al. Code-generating VDM for embedded devices
Barve et al. Upsara: A model-driven approach for performance analysis of cloud-hosted applications
Silva et al. Model driven engineering for performance testing in mobile applications

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant