CN114116509A - Program analysis method, program analysis device, electronic device, and storage medium - Google Patents

Program analysis method, program analysis device, electronic device, and storage medium Download PDF

Info

Publication number
CN114116509A
CN114116509A CN202111460963.6A CN202111460963A CN114116509A CN 114116509 A CN114116509 A CN 114116509A CN 202111460963 A CN202111460963 A CN 202111460963A CN 114116509 A CN114116509 A CN 114116509A
Authority
CN
China
Prior art keywords
program
class
target
byte code
information
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.)
Pending
Application number
CN202111460963.6A
Other languages
Chinese (zh)
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.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech 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 CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202111460963.6A priority Critical patent/CN114116509A/en
Publication of CN114116509A publication Critical patent/CN114116509A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis

Abstract

The present disclosure provides a program analysis method, including: responding to a program analysis instruction, and acquiring a first byte code file to be analyzed, wherein the first byte code file is obtained by compiling a target program; performing enhancement processing on the first byte code file to obtain a second byte code file; loading the second bytecode file into the virtual machine by using the class loader so as to enable the virtual machine to run the target program; calling a monitor to asynchronously collect the running information of the target program; and generating call chain information based on the collected running information under the condition that the running of the target program is completed. In addition, the present disclosure also provides a program analysis apparatus, an electronic device, a readable storage medium, and a computer program product.

Description

Program analysis method, program analysis device, electronic device, and storage medium
Technical Field
The present disclosure relates to the field of program analysis technology and the field of finance, and more particularly, to a program analysis method, a program analysis apparatus, an electronic device, a readable storage medium, and a computer program product.
Background
At present, part of commercial program products such as databases, middleware and the like in enterprise-level application have great influence on production and operation activities of enterprises, and deep understanding of the operation principle of the program products has great significance on operation and maintenance, application architecture and application optimization.
In implementing the disclosed concept, the inventors found that there are at least the following problems in the related art: when some application programs report errors, operation and maintenance personnel of an enterprise are difficult to effectively process the problems, and the timeliness for solving the problems is poor.
Disclosure of Invention
In view of the above, the present disclosure provides a program analysis method, a program analysis apparatus, an electronic device, a readable storage medium, and a computer program product.
One aspect of the present disclosure provides a program analysis method including: responding to a program analysis instruction, and acquiring a first byte code file to be analyzed, wherein the first byte code file is obtained by compiling a target program; performing enhancement processing on the first byte code file to obtain a second byte code file; loading the second bytecode file into a virtual machine by using a class loader so that the virtual machine runs the target program; calling a monitor to asynchronously collect the running information of the target program; and generating calling chain information based on the collected running information under the condition that the target program is completely run.
According to an embodiment of the present disclosure, the first bytecode file includes a plurality of first class packages; wherein, the enhancing the first bytecode file includes: screening at least one target class package from a plurality of first class packages of the first byte code file based on preset configuration information; for each of the target class packages, determining at least one enhancement point of the target class package; and adding an enhancement tangent plane code corresponding to the enhancement point at the enhancement point for each enhancement point.
According to an embodiment of the present disclosure, the preset configuration information is configured with a target identifier of a class packet that needs to be enhanced; wherein, the obtaining of at least one target package from the plurality of first packages of the first bytecode file based on the preset configuration information includes: and selecting at least one first class packet with the target identification from a plurality of first class packets of the first byte code file as the target class packet.
According to an embodiment of the present disclosure, the enhancement point at least includes a constructor, a static function, an initialization block, and a preset method.
According to an embodiment of the present disclosure, the second bytecode file includes at least one second class package; wherein the loading the second bytecode file into the virtual machine using the class loader includes: for each second class package, in a case that the second class package has a corresponding preset class loader, calling the preset class loader by using the class loader, so that the preset class loader loads the second class package into the virtual machine.
According to an embodiment of the present disclosure, the asynchronously collecting, by the call listener, the running information of the target program includes: calling the listener to asynchronously collect the running information of each second type packet of the target program, wherein the running information at least comprises the starting running time, the ending running time and the thread information for running the second type packets; and storing the operation information of the second type of packet into a memory database.
According to an embodiment of the present disclosure, in the case that the running of the target program is completed, generating call chain information based on the collected running information includes: and generating the call chain information based on the running information of at least one second-class packet stored in the memory database when the target program is completely run.
According to an embodiment of the present disclosure, the method further includes:
and responding to preset operation of a user, and adding preset parameters into a starting command of the target program to initiate the program analysis instruction.
Another aspect of the present disclosure provides a program analysis apparatus including: the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for responding to a program analysis instruction and acquiring a first byte code file to be analyzed, and the first byte code file is obtained by compiling a target program; the first processing module is used for performing enhancement processing on the first byte code file to obtain a second byte code file; a loading module, configured to load the second bytecode file into a virtual machine using a class loader, so that the virtual machine runs the target program; the collecting module is used for calling a monitor to asynchronously collect the running information of the target program; and the generation module is used for generating calling chain information based on the collected running information under the condition that the running of the target program is finished.
Another aspect of the present disclosure provides an electronic device including: one or more processors; memory to store one or more instructions, wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement a method as described above.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions for implementing the method as described above when executed.
Another aspect of the disclosure provides a computer program product comprising computer executable instructions for implementing the method as described above when executed.
According to the embodiment of the disclosure, for a first byte code file obtained by compiling an object program, before the first byte code file is operated, enhancement processing can be performed on the first byte code file to obtain an enhanced second byte code file; the second byte code file can be loaded into the virtual machine through the class loader to run; during the running process, the running information of the target program can be collected to generate the calling chain information. By the technical means, the call chain information of each class of the program can be acquired on the basis of not carrying out invasive processing on the source code of the program, so that the technical problem of poor timeliness of solving the problem caused by the fact that operation and maintenance personnel are difficult to effectively process the problem of part of the application program in the related technology is at least partially solved, and the efficiency and the comprehensiveness of program debugging can be effectively improved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure with reference to the accompanying drawings, in which:
fig. 1 schematically illustrates an exemplary system architecture to which a program analysis method may be applied, according to an embodiment of the present disclosure.
Fig. 2 schematically shows a flow chart of a program analysis method according to an embodiment of the present disclosure.
Figure 3 schematically illustrates a flow chart of a program analysis method implemented using a CallTree in accordance with an embodiment of the present disclosure.
Fig. 4 schematically shows a block diagram of a program analysis apparatus according to an embodiment of the present disclosure.
Fig. 5 schematically shows a block diagram of an electronic device adapted to implement a program analysis method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
In the related art, for a program, since a large number of complicated configurations of black boxes are often performed, it is difficult to create a configuration in conformity with a production environment in a debugging environment; in addition, the popularization and use of technologies such as dynamic proxy and asynchronous technology further increases the difficulty of program debugging and tracing. All of these make the program be a black box to the user, the user can't look over or modify the source code of the program, therefore, once the program reports an error or lacks the function, only can wait for the creator of the program to solve the problem, make the timeliness of solving the problem poor.
In view of this, the embodiments of the present disclosure are based on the bytecode technology, and may non-invasively enhance some codes of the program, collect call data on the fly, and then calculate a complete code running link through background analysis. Through the code running link, the operation and maintenance personnel can deeply understand the running process of the program, and the problem of the program running is solved.
Specifically, embodiments of the present disclosure provide a program analysis method, a program analysis apparatus, an electronic device, a readable storage medium, and a computer program product. The method comprises the steps of responding to a program analysis instruction, and obtaining a first byte code file to be analyzed, wherein the first byte code file is obtained by compiling a target program; performing enhancement processing on the first byte code file to obtain a second byte code file; loading the second bytecode file into a virtual machine using a class loader so that the virtual machine runs the target program; calling a monitor to asynchronously collect the running information of the target program; and generating calling chain information based on the collected running information under the condition that the running of the target program is finished.
It should be noted that the program analysis method and apparatus determined by the embodiments of the present disclosure can be used in the technical field of program analysis or the financial field; but also in any fields other than the program analysis technical field and the financial field. The application fields of the program analysis method and the program analysis device determined by the embodiment of the disclosure are not limited.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, necessary security measures are taken, and the customs of the public order is not violated.
Fig. 1 schematically illustrates an exemplary system architecture to which a program analysis method may be applied, according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired and/or wireless communication links, and so forth.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various application program products may be installed on the terminal devices 101, 102, 103, including but not limited to shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, and/or social platform software, among others.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen including, but not limited to, smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a backend server that provides analysis services for programs running in the terminal devices 101, 102, 103. The background server can collect, analyze and process the running information of the program and feed back the analysis result to the terminal equipment.
It should be noted that the program analysis method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the program analysis device provided by the embodiment of the present disclosure may be generally disposed in the server 105. The program analysis method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the program analysis apparatus provided in the embodiments of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Alternatively, the program analysis method provided by the embodiment of the present disclosure may also be executed by the terminal device 101, 102, or 103, or may also be executed by another terminal device different from the terminal device 101, 102, or 103. Accordingly, the program analysis apparatus provided in the embodiments of the present disclosure may also be disposed in the terminal device 101, 102, or 103, or in another terminal device different from the terminal device 101, 102, or 103.
For example, the program may be originally installed on any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101 is not limited thereto), and the terminal device 101 may locally perform the program analysis method provided by the embodiments of the present disclosure; alternatively, the terminal device 101 may send a program analysis instruction to another terminal device, a server, or a server cluster, and the other terminal device, the server, or the server cluster that receives the instruction executes the program analysis method provided in the embodiment of the present disclosure, so as to analyze the program on the terminal device 101.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 schematically shows a flow chart of a program analysis method according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S201 to S205.
In operation S201, in response to a program analysis instruction, a first bytecode file to be analyzed is acquired, where the first bytecode file is obtained by compiling an object program.
In operation S202, the first bytecode file is enhanced to obtain a second bytecode file.
In operation S203, the second bytecode file is loaded into the virtual machine using the class loader so that the virtual machine runs the target program.
In operation S204, the call listener asynchronously collects the execution information of the target program.
In operation S205, in the case where the target program execution is completed, call chain information is generated based on the collected execution information.
According to embodiments of the present disclosure, the target program may be a program that does not use any open source protocol. After the target program is released, the user can only obtain the binary version of the computer program, i.e., the first bytecode file, permitted by the program distributor.
According to an embodiment of the present disclosure, the enhanced processing of the first bytecode file may be implemented based on a bytecode technology, or may be implemented using a source code analysis tool such as CallTree, which is not limited herein.
According to an embodiment of the present disclosure, enhancing the first bytecode file may include adding a collection function to each class of the first bytecode file.
According to an embodiment of the present disclosure, specific content of the running information may be set according to a specific application scenario, and may include, for example, basic information of a task, time when the task starts to be executed and finishes to be executed, thread information for executing the task, and the like, which are not limited herein.
According to the embodiment of the disclosure, after the call chain information is generated, the user can acquire the link information of the specified time period from the front-end page by means of query by thread or query by class method name.
According to the embodiment of the disclosure, for a first byte code file obtained by compiling an object program, before the first byte code file is operated, enhancement processing can be performed on the first byte code file to obtain an enhanced second byte code file; the second byte code file can be loaded into the virtual machine through the class loader to run; during the running process, the running information of the target program can be collected to generate the calling chain information. By the technical means, the call chain information of each class of the program can be acquired on the basis of not carrying out invasive processing on the source code of the program, so that the technical problem of poor timeliness of solving the problem caused by the fact that operation and maintenance personnel are difficult to effectively process the problem of part of the application program in the related technology is at least partially solved, and the efficiency and the comprehensiveness of program debugging can be effectively improved.
The method of fig. 2 is further described with reference to fig. 3 in conjunction with specific embodiments.
Figure 3 schematically illustrates a flow chart of a program analysis method implemented using a CallTree in accordance with an embodiment of the present disclosure.
As shown in fig. 3, the method includes operations S301 to S307.
It should be noted that, unless explicitly stated that there is an execution sequence between different operations or there is an execution sequence between different operations in technical implementation, the execution sequence between multiple operations may not be sequential, or multiple operations may be executed simultaneously in the flowchart in this disclosure.
In operation S301, in response to a preset operation by a user, a preset parameter is added to a start command of a target program.
In operation S302, a first bytecode file obtained by compiling the target program is obtained.
In operation S303, the first bytecode file is enhanced to obtain a second bytecode file.
In operation S304, the respective class packages of the second bytecode file are loaded into the virtual machine using the class loader.
In operation S305, a listener is called to asynchronously collect the run information of the class packet.
In operation S306, it is determined whether the execution of the target program is completed, and in case it is determined that the execution of the target program is not completed, operation S305 is returned to; in a case where it is determined that the target program execution is completed, operation S307 is performed.
In operation S307, call chain information is generated based on the collected run information.
According to an embodiment of the present disclosure, the preset operation may include, for example, a click operation for initiating a program analysis instruction for the target program.
According to an embodiment of the present disclosure, the preset parameters may include a parameter that specifies loading of a CallTree program, such as a "-javaagent" parameter.
According to the embodiment of the disclosure, after the preset parameter is added to the start command of the target program, the JVM may execute the CallTree program to perform enhancement processing on the first bytecode file before loading the first bytecode file of the target program.
According to the embodiment of the disclosure, when the CallTree program is not needed, only the starting command of the target program needs to be modified, and the function of the CallTree program can be completely removed by deleting the preset parameters in the starting command, so that the influence on the normal operation of the target program is effectively avoided.
According to an embodiment of the present disclosure, a plurality of first class packs may be included in the first bytecode file.
According to an embodiment of the present disclosure, the enhancing the first bytecode file may specifically include: screening at least one target class package from a plurality of first class packages of the first byte code file based on preset configuration information; for each target class package, determining at least one enhancement point of the target class package; and for each enhancement point, adding an enhancement tangent plane code corresponding to the enhancement point at the enhancement point.
According to the embodiment of the disclosure, the preset configuration information may include configuration information of a user on the CallTree, and the user may specify a packet name prefix of a bundle in the CallTree to implement definition of the bundle which needs to be enhanced and the bundle which omits enhancement in a plurality of first bundles, for example, the basic bundle or framework such as JDK, Spring framework may be used as the bundle which ignores enhancement. After configuration, the CallTree can perform enhancement processing only on the first type of packet needing enhancement.
According to the embodiment of the disclosure, the preset configuration information may be configured with a target identifier of a class packet that needs to be enhanced. When the plurality of first class packets of the first bytecode file are screened, at least one first class packet with a target identifier may be selected from the plurality of first class packets as a target class packet.
According to the embodiment of the disclosure, the positions and the number of the enhancement points in the target class package may be set according to a specific application scenario, and may include, for example, a constructor, a static function, an initialization block, a normal function, and a preset method.
According to an embodiment of the present disclosure, the preset method may include a method set by a user, such as getter, setter, and the like.
According to the embodiment of the disclosure, different enhancement points can be configured to use different enhancement tangent plane codes to collect information of different dimensions.
According to an embodiment of the present disclosure, the custom class loader in the CallTree may be used to load the respective class packages of the second bytecode file. Before loading, the class loader can be used for inquiring whether the class package has a corresponding preset class loader, and under the condition that the class package has the corresponding preset class loader, the class loader can be used for calling the corresponding preset class loader so as to load the class package by using the preset class loader, so that the path of the class package processed by the CallTree is consistent with the original path, and the problem that the JVM gives error reporting information of ClassNotFoundError due to inconsistent paths in the process that the JVM runs the target program is effectively solved.
According to the embodiment of the disclosure, after the class package is loaded, the CallTree can start the back-end service, including registering a listener to asynchronously collect the running information of the target program, initializing a memory database to store the collected running information, and providing a page to query and display the call chain information.
According to the embodiment of the disclosure, in the running process of the target program, the listener can be called to asynchronously collect the running information of each class packet of the target program, and the running information of the class packet is stored in the memory database.
According to the embodiment of the disclosure, when the class package starts to run, a CallItem structure may be generated, and the CallItem structure may include information such as start time, end time, thread ID, parent thread ID, sequence number, method name, class name, and thread name, as shown in table 1; after a CallItem structure is generated, the starting time can be recorded, and the CallItem structure is added into the context of the current thread through the stack-entering operation to collect other running information; after the class execution is completed, the CallItem can record the end time and pop the CallItem from the context of the current thread; the CallItem pop can trigger a CallItem completion event, which can be handled by listener snooping.
TABLE 1
Figure BDA0003388747110000111
According to an embodiment of the present disclosure, the listener may serialize the collected CallItem information into an in-memory database.
According to the embodiment of the disclosure, in the case that the target program is completely executed, the call chain information may be generated based on the execution information of the at least one class package stored in the in-memory database.
According to the embodiment of the disclosure, after the call chain information is obtained, the link information of the specified time period can be displayed through the front-end page, and the running information of the thread or the call information of the package can be obtained through a mode of querying according to the thread or the package name.
Fig. 4 schematically shows a block diagram of a program analysis apparatus according to an embodiment of the present disclosure.
As shown in fig. 4, the program analysis apparatus 400 includes an acquisition module 410, a first processing module 420, a loading module 430, a collection module 440, and a generation module 450.
The obtaining module 410 is configured to, in response to a program analysis instruction, obtain a first bytecode file to be analyzed, where the first bytecode file is obtained by compiling an object program.
The first processing module 420 is configured to perform enhancement processing on the first bytecode file to obtain a second bytecode file.
And a loading module 430, configured to load the second bytecode file into the virtual machine using the class loader, so that the virtual machine runs the target program.
And the collection module 440 is used for calling the listener to asynchronously collect the running information of the target program.
And a generating module 450, configured to generate the call chain information based on the collected running information when the running of the target program is completed.
According to the embodiment of the disclosure, for a first byte code file obtained by compiling an object program, before the first byte code file is operated, enhancement processing can be performed on the first byte code file to obtain an enhanced second byte code file; the second byte code file can be loaded into the virtual machine through the class loader to run; during the running process, the running information of the target program can be collected to generate the calling chain information. By the technical means, the call chain information of each class of the program can be acquired on the basis of not carrying out invasive processing on the source code of the program, so that the technical problem of poor timeliness of solving the problem caused by the fact that operation and maintenance personnel are difficult to effectively process the problem of part of the application program in the related technology is at least partially solved, and the efficiency and the comprehensiveness of program debugging can be effectively improved.
According to an embodiment of the present disclosure, the first bytecode file includes a plurality of first class packages.
According to an embodiment of the present disclosure, the first processing module 420 includes a first processing unit, a second processing unit, and a third processing unit.
The first processing unit is used for screening at least one target class packet from a plurality of first class packets of the first byte code file based on preset configuration information.
And the second processing unit is used for determining at least one enhancement point of the target class package for each target class package.
And the third processing unit is used for adding an enhancement tangent plane code corresponding to the enhancement point at the enhancement point for each enhancement point.
According to the embodiment of the disclosure, the preset configuration information is configured with the target identifier of the class packet that needs to be enhanced.
According to an embodiment of the present disclosure, the first processing unit is further configured to select at least one first class packet having a target identifier from a plurality of first class packets of the first bytecode file as a target class packet.
According to an embodiment of the present disclosure, an enhancement point includes at least a constructor, a static function, an initialization block, and a preset method.
According to an embodiment of the present disclosure, the second bytecode file includes at least one second class package.
According to an embodiment of the present disclosure, the loading module 430 is further configured to, for each second class package, use the class loader to call the preset class loader in a case that the second class package has a corresponding preset class loader, so that the preset class loader loads the second class package into the virtual machine.
According to an embodiment of the present disclosure, the collection module 440 includes a first collection unit and a second collection unit.
And the first collection unit is used for calling the listener to asynchronously collect the running information of each second type packet of the target program, wherein the running information at least comprises the starting running time, the ending running time and the thread information for running the second type packets.
And the second collection unit is used for storing the operation information of the second type of packets into the memory database.
According to an embodiment of the present disclosure, the generating module 450 is further configured to generate the call chain information based on the running information of the at least one second class packet stored in the in-memory database when the target program is completely run.
According to an embodiment of the present disclosure, the apparatus 400 further comprises a second processing module.
And the second processing module is used for responding to the preset operation of the user and adding the preset parameters into the starting command of the target program so as to initiate a program analysis instruction.
Any of the modules, units, or at least part of the functionality of any of them according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules and units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, units according to the embodiments of the present disclosure may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by any other reasonable means of hardware or firmware by integrating or packaging the circuits, or in any one of three implementations of software, hardware and firmware, or in any suitable combination of any of them. Alternatively, one or more of the modules, units according to embodiments of the present disclosure may be implemented at least partly as computer program modules, which, when executed, may perform the respective functions.
For example, any number of the obtaining module 410, the first processing module 420, the loading module 430, the collecting module 440, and the generating module 450 may be combined in one module/unit/sub-unit to be implemented, or any one of the modules/units/sub-units may be split into a plurality of modules/units/sub-units. Alternatively, at least part of the functionality of one or more of these modules/units/sub-units may be combined with at least part of the functionality of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to an embodiment of the present disclosure, at least one of the obtaining module 410, the first processing module 420, the loading module 430, the collecting module 440, and the generating module 450 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or in any one of three implementations of software, hardware, and firmware, or in a suitable combination of any of them. Alternatively, at least one of the obtaining module 410, the first processing module 420, the loading module 430, the collecting module 440 and the generating module 450 may be at least partially implemented as a computer program module, which when executed may perform a corresponding function.
It should be noted that the program analysis device portion in the embodiment of the present disclosure corresponds to the program analysis method portion in the embodiment of the present disclosure, and the description of the program analysis device portion specifically refers to the program analysis method portion, which is not described herein again.
Fig. 5 schematically shows a block diagram of an electronic device adapted to implement a program analysis method according to an embodiment of the present disclosure. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 5, a computer electronic device 500 according to an embodiment of the present disclosure includes a processor 501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. The processor 501 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 501 may also include onboard memory for caching purposes. Processor 501 may include a single processing unit or multiple processing units for performing different actions of a method flow according to embodiments of the disclosure.
In the RAM 503, various programs and data necessary for the operation of the electronic apparatus 500 are stored. The processor 501, the ROM 502, and the RAM 503 are connected to each other by a bus 504. The processor 501 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 502 and/or the RAM 503. Note that the programs may also be stored in one or more memories other than the ROM 502 and the RAM 503. The processor 501 may also perform various operations of method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, electronic device 500 may also include an input/output (I/O) interface 505, input/output (I/O) interface 505 also being connected to bus 504. The electronic device 500 may also include one or more of the following components connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program, when executed by the processor 501, performs the above-described functions defined in the system of the embodiments of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, a computer-readable storage medium may include ROM 502 and/or RAM 503 and/or one or more memories other than ROM 502 and RAM 503 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method provided by the embodiments of the present disclosure, when the computer program product is run on an electronic device, the program code being adapted to cause the electronic device to carry out the method of program analysis provided by the embodiments of the present disclosure.
The computer program, when executed by the processor 501, performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, downloaded and installed through the communication section 509, and/or installed from the removable medium 511. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
According to an embodiment of the present disclosure, program codes for executing a computer program provided by an embodiment of the present disclosure may be written using JAVA. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (12)

1. A program analysis method, comprising:
responding to a program analysis instruction, and acquiring a first byte code file to be analyzed, wherein the first byte code file is obtained by compiling a target program;
performing enhancement processing on the first byte code file to obtain a second byte code file;
loading the second bytecode file into a virtual machine using a class loader so that the virtual machine runs the target program;
calling a monitor to asynchronously collect the running information of the target program; and
and generating calling chain information based on the collected running information under the condition that the running of the target program is finished.
2. The method of claim 1, wherein the first bytecode file includes a plurality of first class packages;
wherein the enhancing the first bytecode file includes:
screening at least one target class package from a plurality of first class packages of the first byte code file based on preset configuration information;
for each target class package, determining at least one enhancement point of the target class package; and
for each enhancement point, adding an enhancement tangent plane code corresponding to the enhancement point at the enhancement point.
3. The method according to claim 2, wherein the preset configuration information is configured with a target identifier of a class packet that needs to be enhanced;
wherein the obtaining of at least one target package from the plurality of first packages of the first bytecode file by screening based on preset configuration information includes:
selecting at least one first class packet with the target identification from a plurality of first class packets of the first byte code file as the target class packet.
4. The method of claim 2, wherein the enhancement points comprise at least a constructor, a static function, an initialization block, and a preset method.
5. The method of claim 1, wherein the second bytecode file includes at least one second package;
wherein the loading the second bytecode file into the virtual machine using the class loader comprises:
for each second class package, calling the preset class loader by using the class loader under the condition that the second class package has a corresponding preset class loader, so that the preset class loader loads the second class package into the virtual machine.
6. The method of claim 5, wherein the call listener asynchronously collecting the running information of the target program comprises:
calling the listener to asynchronously collect the running information of each second type packet of the target program, wherein the running information at least comprises the starting running time, the ending running time and the thread information for running the second type packet; and
and storing the operation information of the second type of packet into an in-memory database.
7. The method of claim 6, wherein the generating call chain information based on the collected run information in the case that the target program run is completed comprises:
and generating the call chain information based on the running information of at least one second class packet stored in the memory database under the condition that the target program is completely run.
8. The method of claim 1, further comprising:
and responding to preset operation of a user, and adding preset parameters into a starting command of the target program to initiate the program analysis instruction.
9. A program analysis device comprising:
the device comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for responding to a program analysis instruction and acquiring a first byte code file to be analyzed, and the first byte code file is obtained by compiling a target program;
the first processing module is used for performing enhancement processing on the first byte code file to obtain a second byte code file;
a loading module, configured to load the second bytecode file into a virtual machine using a class loader, so that the virtual machine runs the target program;
the collecting module is used for calling a monitor to asynchronously collect the running information of the target program; and
and the generation module is used for generating calling chain information based on the collected operation information under the condition that the operation of the target program is finished.
10. An electronic device, comprising:
one or more processors;
a memory to store one or more instructions that,
wherein the one or more instructions, when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-8.
11. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 8.
12. A computer program product comprising computer executable instructions for implementing the method of any one of claims 1 to 8 when executed.
CN202111460963.6A 2021-12-02 2021-12-02 Program analysis method, program analysis device, electronic device, and storage medium Pending CN114116509A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111460963.6A CN114116509A (en) 2021-12-02 2021-12-02 Program analysis method, program analysis device, electronic device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111460963.6A CN114116509A (en) 2021-12-02 2021-12-02 Program analysis method, program analysis device, electronic device, and storage medium

Publications (1)

Publication Number Publication Date
CN114116509A true CN114116509A (en) 2022-03-01

Family

ID=80365694

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111460963.6A Pending CN114116509A (en) 2021-12-02 2021-12-02 Program analysis method, program analysis device, electronic device, and storage medium

Country Status (1)

Country Link
CN (1) CN114116509A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114610516A (en) * 2022-03-10 2022-06-10 北京字节跳动网络技术有限公司 Application program repairing method and device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114610516A (en) * 2022-03-10 2022-06-10 北京字节跳动网络技术有限公司 Application program repairing method and device, computer equipment and storage medium
CN114610516B (en) * 2022-03-10 2023-07-04 抖音视界有限公司 Application program repairing method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
US9122804B2 (en) Logic validation and deployment
US8806437B2 (en) Automated testing process
US20110258609A1 (en) Method and system for software defect reporting
US11561889B2 (en) Orchestration for automated performance testing
EP3362900B1 (en) Telemetry system extension
US11816479B2 (en) System and method for implementing a code audit tool
CN110865889A (en) Method and apparatus for transferring events between components
CN115357761A (en) Link tracking method and device, electronic equipment and storage medium
US11716354B2 (en) Determination of compliance with security technical implementation guide standards
Tang et al. Xdebloat: Towards automated feature-oriented app debloating
CN114116509A (en) Program analysis method, program analysis device, electronic device, and storage medium
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN115982491A (en) Page updating method and device, electronic equipment and computer readable storage medium
CN112506781B (en) Test monitoring method, device, electronic equipment, storage medium and program product
CN113535565B (en) Interface use case generation method, device, equipment and medium
CN114579405A (en) Data processing method, data processing apparatus, electronic device, and storage medium
CN113495498A (en) Simulation method, simulator, device, and medium for hardware device
CN113360825A (en) WebUI automatic test method and device, electronic equipment and storage medium
CN113176907A (en) Interface data calling method and device, computer system and readable storage medium
CN113032256A (en) Automatic test method, device, computer system and readable storage medium
CN111881025A (en) Automatic test task scheduling method, device and system
CN112817573B (en) Method, apparatus, computer system, and medium for building a streaming computing application
CN115934537A (en) Interface test tool generation method, device, equipment, medium and product
CN114266547A (en) Method, device, equipment, medium and program product for identifying business processing strategy
CN117472716A (en) Non-invasive application log acquisition method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination