CN115220725A - Application processing method and device and electronic equipment - Google Patents

Application processing method and device and electronic equipment Download PDF

Info

Publication number
CN115220725A
CN115220725A CN202110407836.3A CN202110407836A CN115220725A CN 115220725 A CN115220725 A CN 115220725A CN 202110407836 A CN202110407836 A CN 202110407836A CN 115220725 A CN115220725 A CN 115220725A
Authority
CN
China
Prior art keywords
code
function
target
file
target path
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
CN202110407836.3A
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.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202110407836.3A priority Critical patent/CN115220725A/en
Publication of CN115220725A publication Critical patent/CN115220725A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The disclosure relates to an application program processing method and device and electronic equipment. The method comprises the following steps: receiving an import code of an application program; determining whether code in the modified portion of the incorporated code relates to a target path of the application; determining whether time-consuming operations exist for modifying the code in the portion; and when the code in the modification part relates to the target path and time-consuming operation exists, outputting an analysis result, wherein the analysis result comprises the target code which relates to the target path and has the time-consuming operation and the position of the target code in the incorporated code. Therefore, whether the incorporated code can cause the application program to be degraded in the target path or not can be found earlier, so that sufficient time is provided for repairing the incorporated code, the degradation-prevention processing efficiency of the application program is improved, and the repair period of the application program is shortened.

Description

Application processing method and device and electronic equipment
Technical Field
The present disclosure relates to the field of internet technologies, and in particular, to a method and an apparatus for processing an application program, and an electronic device.
Background
In the process of software application development, operation and upgrading on the android system, with continuous expansion and updating of services, developers can write newly added codes corresponding to the services and optimize the newly added codes corresponding to the services.
However, with the incorporation of the newly added code corresponding to the service, a degradation phenomenon may occur on a target path (e.g., a start path) of the application program, and in a severe case, even a full optimization effort of a developer is wasted. Therefore, a processing method for preventing the application program from deteriorating is important.
Currently, the existing processing methods for preventing the application program from being degraded include the following two methods:
1. before publishing, the incorporated version and the unincorporated version of the application program are compared offline, and whether indexes in the two versions are degraded or not is tested. However, this method cannot intercept the incoming version in time before the release even if the incoming version is degraded, and only depends on the repair of the subsequent version.
2. After publishing, the in-line version of the program is observed on-line to determine if any of the indicators in the version have degraded. And after the incorporated version is degraded, locating the degradation position and analyzing the degradation reason. However, this method is inefficient in processing and the repair cycle after positioning is long.
Disclosure of Invention
In order to solve the technical problems or at least partially solve the technical problems, the disclosure provides an application program processing method, an application program processing device and an electronic device.
In a first aspect, the present disclosure provides a method for processing an application program, including:
receiving an import code of an application program;
determining whether code in the modified portion of the incorporated code relates to a target path of the application;
determining whether there is a time-consuming operation to modify the code in the portion;
and when the code in the modification part relates to the target path and time-consuming operation exists, outputting an analysis result, wherein the analysis result comprises a target code which relates to the target path and has the time-consuming operation and a target position of the corresponding code in the incorporated code.
By the method provided by the first aspect, after the import code of the application program is submitted, the changed part in the import code is detected and analyzed, and firstly, whether the code in the changed part relates to a target path is analyzed; secondly, whether time-consuming operation exists in the code in the changed part is analyzed. In the case that the code in the modified part relates to the target path and the time-consuming operation exists, the code reviewer can be informed of the analysis result, the analysis result comprises the target code which relates to the target path and has the time-consuming operation and the position of the target code, so that the code reviewer can conduct code review with the developer to conduct the check-in warehouse operation on the check-in code after the code review is successful, or the code reviewer can conduct blocking of the check-in warehouse operation on the check-in code. Therefore, whether the incorporated code can cause the application program to be degraded in the target path or not can be found earlier, so that sufficient time is provided for repairing the incorporated code, the degradation-prevention processing efficiency of the application program is improved, and the repair period of the application program is shortened. In one possible design, determining whether there are time consuming operations to modify code in a portion includes: and if the codes in the modified part relate to the target path, determining whether time-consuming operation exists in the codes relating to the target path in the modified part.
In one possible design, determining whether code in a modified portion of the incorporated code relates to a target path of the application includes: acquiring a target file, wherein all functions related to a target path in all codes of an application program are recorded in the target file; based on the target file, it is determined whether the code in the modified portion relates to the target path.
In one possible design, determining whether code in the modified portion relates to the target path based on the target file includes: determining that the code in the modified portion relates to the target path when the code in the modified portion is included in the function of the target file record; determining that the code in the modified portion does not relate to the target path when the code in the modified portion is not included in the function of the target file record.
In one possible design, obtaining a target file includes: acquiring a first file, and determining a first function set called in a target path in all codes of an application program based on the first file; acquiring a second file, and determining a second function set called in a root function of the target path in all codes of the application program based on the second file; and determining the union of the first function set and the second function set as a target file.
In one possible design, the method further includes: a first file is determined. Determining a first file comprising: configuring a start function and a stop function of a target path in a compiling stage of an application program; performing instrumentation on all codes of the application program; recording a called function between a start function and a stop function in a first file in the running stage of the application program based on instrumentation; the first file is saved.
In one possible design, the method further includes: a second file is determined. Determining a second file comprising: determining a root function of a target path; compiling all codes of an application program into first byte codes; performing static analysis on the first byte code to obtain sub-functions directly and indirectly called by the root function, and recording the root function and the sub-functions in a second file; and saving the second file.
In one possible design, determining whether there are time consuming operations to modify code in a portion includes: compiling the modified part into a second bytecode in a compiling stage of the application program; for each corresponding function in the second bytecode, determining whether the type of each function is within the type range of a preset list, wherein the type of the time-consuming function is recorded in the preset list; when the type of a corresponding function in the second bytecode is within the type range of the preset list, determining that time-consuming operation exists when the function corresponds to the code in the modification part; and when the corresponding function type in the second byte code is not in the type range of the preset list, determining that no time-consuming operation exists when the function corresponds to the code in the modified part.
In one possible design, when there is a called external function in a corresponding one of the second bytecodes and all corresponding functions in the second bytecodes do not include a function-called external function, the method further includes: determining whether the type of an external function called by a function is within the type range of a preset list; determining that time-consuming operation exists in a function when an external function called by the function is within the type range of a preset list; and when the external function called by the function is not in the type range of the preset list, determining that no time-consuming operation exists for the function.
In one possible design, when it is determined that a corresponding function in the second bytecode has a time-consuming operation and involves the target path, the function is determined as the target code, the position of the function is determined as the position of the target code, and the target code and the position of the target code are saved in the analysis result.
In one possible design, the types of time consuming functions in the preset list include: locking function, JSON analysis function, read-write I/O function and system time consumption function.
In one possible design, the target path is the main thread of the main process in the launch path of the application.
In a second aspect, the present disclosure provides an apparatus for processing an application, including:
the receiving module is used for receiving the import code of the application program;
a determination module for determining whether code in the modified portion of the incorporated code relates to a target path of the application;
the determining module is further used for determining whether time-consuming operation exists in the code in the modification part;
and the output module is used for outputting an analysis result when the code in the modification part relates to the target path and the time-consuming operation exists, wherein the analysis result comprises the position of the target code and the target code which relates to the target path and has the time-consuming operation in the incorporated code.
In one possible design, the determining module is specifically configured to determine whether there is a time-consuming operation on the code related to the target path in the modified portion after determining that the code related to the target path in the modified portion is related to the target path.
In one possible design, the determining module is specifically configured to obtain a target file, where all functions related to a target path in all codes of the application program are recorded in the target file; based on the target file, it is determined whether the code in the modified portion relates to a target path.
In one possible design, the determining module is configured to determine that the code in the modified portion relates to the target path when the code in the modified portion is included in the function of the target file record; determining that the code in the modified portion does not relate to the target path when the code in the modified portion is not included in the function of the target file record.
In one possible design, the determining module is configured to obtain a first file, and determine, based on the first file, a first function set called in the target path in all the codes of the application program; acquiring a second file, and determining a second function set called in a root function of the target path in all codes of the application program based on the second file; and determining the union of the first function set and the second function set as a target file.
In one possible design, the determining module is further configured to determine the first file. The determining module is specifically used for configuring a start function and a stop function of the target path in the compiling stage of the application program; performing instrumentation on all codes of the application program; recording a called function between a start function and a stop function in a first file in the running stage of the application program based on instrumentation; the first file is saved.
In one possible design, the determining module is further configured to determine the second file. The determining module is specifically used for determining a root function of the target path; compiling all codes of an application program into first byte codes; performing static analysis on the first byte code to obtain sub-functions directly and indirectly called by the root function, and recording the root function and the sub-functions in a second file; and saving the second file.
In one possible design, the determining module is further specifically configured to compile the modified portion into a second bytecode during a compilation phase of the application; for each corresponding function in the second bytecode, determining whether the type of each function is within the type range of a preset list, wherein the type of the time-consuming function is recorded in the preset list; when the type of a corresponding function in the second byte codes is within the type range of the preset list, determining that time-consuming operation exists when the function corresponds to the codes in the modification part; and when the corresponding function type in the second byte code is not in the type range of the preset list, determining that no time-consuming operation exists when the function corresponds to the code in the modified part.
In a possible design, the determining module is further configured to determine whether a type of the external function called by the function is within a type range of a preset list when the called external function exists in a corresponding function in the second bytecode and all corresponding functions in the second bytecode do not include the external function called by the function; when an external function called by a function is within the type range of a preset list, determining that time-consuming operation exists in the function; and when the external function called by the function is not in the type range of the preset list, determining that no time-consuming operation exists in the function.
In one possible design, when it is determined that a corresponding function in the second bytecode has a time-consuming operation and involves the target path, the function is determined as the target code, the position of the function is determined as the position of the target code, and the target code and the position of the target code are saved in the analysis result.
In one possible design, the types of time consuming functions in the preset list include: the method comprises a lock function, a JSON analysis function, a read-write I/O function and a system time consumption function.
In one possible design, the target path is the main thread of the main process in the launch path of the application.
The beneficial effects of the processing apparatus for the application program provided in the second aspect and in each possible design of the second aspect may refer to the beneficial effects brought by each possible implementation manner of the first aspect and the first aspect, and are not described again here.
In a third aspect, the present disclosure provides an electronic device, comprising: a memory and a processor; the memory is used for storing program instructions; the processor is configured to invoke the program instructions in the memory to cause the electronic device to perform the processing method of the application program in the first aspect and any one of the possible designs of the first aspect.
In a fourth aspect, the present disclosure provides a computer storage medium including computer instructions that, when run on an electronic device, cause the electronic device to perform the method for processing an application program in the first aspect and any one of the possible designs of the first aspect.
In a fifth aspect, the present disclosure provides a computer program product for causing a computer to perform the method of processing an application program in the first aspect and any one of the possible designs of the first aspect when the computer program product runs on the computer.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic flowchart of a processing method of an application program according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a processing method of an application program according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of a processing method of an application program according to an embodiment of the present disclosure;
fig. 4 is a flowchart of a processing method of an application program according to an embodiment of the present disclosure;
fig. 5 is a flowchart of the operation of a processing device of an application program according to an embodiment of the present disclosure;
fig. 6 is a flowchart illustrating a processing method of an application program according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a processing device of an application according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that the embodiments and features of the embodiments of the present disclosure may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced in other ways than those described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
The present disclosure provides a processing method, an apparatus, a device, a computer storage medium, and a computer program product for an application program, where after an import code of the application program is submitted, a modified part in the import code is detected and analyzed, and first, whether the code in the modified part relates to a target path is analyzed; secondly, whether time-consuming operation exists in the code in the changed part is analyzed. Thereby, a code review (code review) person is notified of the analysis result, so that the code review person determines to perform a subsequent operation on the access code based on the analysis result. In the case that the code in the modified part relates to the target path and the time-consuming operation exists, the code reviewer can be informed of the analysis result, the analysis result comprises the target code which relates to the target path and has the time-consuming operation and the position of the target code, so that the code reviewer can conduct code review with the developer to conduct the check-in warehouse operation on the check-in code after the code review is successful, or the code reviewer can conduct blocking of the check-in warehouse operation on the check-in code. Therefore, whether the incorporated code causes the application program to be degraded in the target path or not can be found earlier, so that sufficient time is provided for repairing the incorporated code, the processing efficiency of preventing the application program from being degraded is improved, and the repairing period of the application program is shortened.
The processing method of the application program is executed by the code management platform. The code management platform may be a server, a terminal device or an Application (APP) in the terminal device, a web page, a public number, and the like, and the present disclosure does not set any limit to a specific type of the code management platform.
Based on the foregoing description, the embodiment of the present disclosure will use a code management platform as an example, and details a processing method of an application program provided by the present disclosure with reference to the accompanying drawings and application scenarios.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a processing method of an application according to an embodiment of the disclosure. As shown in fig. 1, the processing method of the application program provided by the present disclosure may include:
s101, receiving an incorporated code of the application program.
The code management platform receives the incorporative code for the application from the developer. The incorporated code may include a code corresponding to the service. When the service is the service already possessed by the application program, the incorporated code may include a newly added code corresponding to the service; when the service is the newly added service of the application program, the incorporated code comprises a code corresponding to the newly added service.
In addition to the codes corresponding to the services, the incorporation code may further include: other code of the application. In addition, the present disclosure does not limit the type of the application program and the specific representation manner of the incorporated code.
In addition, besides the incorporated code, the code management platform may also receive an identifier for indicating that a developer wants to incorporate the incorporated code into the application program, so that the code management platform detects the incorporated code. In addition, the specific representation of the identifier is not limited in the present disclosure.
S102, determining whether the code in the modified part integrated into the code relates to a target path of the application program.
After submitting the import code, the code management platform can detect whether the modified part in the import code relates to the target path of the application program or not so as to avoid the target path of the application program from being degraded.
When the codes in the modified part do not relate to the target path, the code management platform can inform a code reviewer to carry out warehousing operation on the import codes.
The target path may implement a phase corresponding to one or more services, one or more scenes, one or more functions, and the like for the application program. The specific implementation of the target path is not limited in this disclosure.
In some embodiments, the target path is a main thread of a main process in the launch path of the application. The starting path is a time period from the start of the application program to the display of a preset initial page. Specifically, the starting path is set to be from the start of the application program to the display of the home page by the application program, and correspondingly, the main thread of the main process is used for realizing the start of the application program to the display of the home page by the application program. When the starting path is set to be from the start of the application program to the display of the first page (such as a drainage page), correspondingly, the main thread of the main process is used for realizing the start of the application program from the start to the display of the first page.
S103, determining whether time-consuming operation exists in the code in the modification part.
After the application program's incorporated code is submitted, the code management platform can detect whether there is a time-consuming operation on the code in the modified portion. The code management platform determines whether time-consuming operation exists in the code in the modified part or not.
When time-consuming operation does not exist in the code in the modification part, the code management platform can inform a code reviewer to carry out warehousing operation on the input code.
It should be noted that the execution sequence of step S102 and step S103 is not sequential.
Step S102 may be performed prior to step S103, namely, after the modified part relates to the target path, it is determined whether there is a time-consuming operation for the code relating to the target path in the modified part. Therefore, the code management platform only needs to analyze whether time-consuming operation exists in the codes related to the target path in the modification part or not, and does not need to analyze all the codes in the modification part, so that the workload is reduced, and the working efficiency is improved.
Step S103 may also be performed before step S102, that is, after the time-consuming operation exists in the code in the modification part, it is determined whether the code in the modification part, in which the time-consuming operation exists, relates to the target path. Therefore, the code management platform only needs to analyze whether the codes with time-consuming operation in the modification part relate to the target path or not, and does not need to analyze all the codes in the modification part, so that the workload is reduced, and the working efficiency is improved.
Step S102 may also be executed in synchronization with step S103, that is, the code 1 that consumes time in the modified part and the code 2 that relates to the target path in the modified part are determined in synchronization, and then it is determined whether there is an intersection between the code 1 and the code 2. Therefore, the determination time is saved, and the working efficiency is improved.
In addition, before the code management platform executes step S102 or step S103, it needs to determine that a modified portion exists in the incorporated code.
And S104, when the code in the modification part relates to the target path and time-consuming operation exists, outputting an analysis result, wherein the analysis result comprises the target code which relates to the target path and has the time-consuming operation and the position of the target code in the incorporated code.
Based on the descriptions of step S102 and step S103, the code management platform may determine whether the modified portion relates to the target path and whether there is a time-consuming operation on the code in the modified portion, so that the code management platform may notify the code reviewer whether the code in the modified portion relates to the target path and there is a time-consuming operation.
Thus, when the code in the modification part relates to the target path and has time-consuming operation, the code management platform can output the analysis result so as to inform the code reviewer of the position of the target code and the target code which relates to the target path and has time-consuming operation in the merged code based on the analysis result.
The present disclosure does not limit the specific representation manner of the analysis result. For example, the analysis result includes a presence identifier and a location identifier, the presence identifier is used for indicating that the incorporated code includes a code which relates to the target path and has a time-consuming operation, and the location identifier is used for identifying the location of the corresponding code. The aforementioned identifiers may be represented in the form of numbers, letters, characters, and the like.
According to the processing method of the application program, after the import code of the application program is submitted, the changed part in the import code is detected and analyzed, and whether the code in the changed part relates to a target path or not is analyzed; secondly, whether time-consuming operation exists in the code in the changed part is analyzed. In the case that the code in the modified part relates to the target path and the time-consuming operation exists, the code reviewer can be informed of the analysis result, the analysis result comprises the target code which relates to the target path and has the time-consuming operation and the position of the target code, so that the code reviewer can conduct code review with the developer to conduct the check-in warehouse operation on the check-in code after the code review is successful, or the code reviewer can conduct blocking of the check-in warehouse operation on the check-in code. Therefore, whether the incorporated code can cause the application program to be degraded in the target path or not can be found earlier, so that sufficient time is provided for repairing the incorporated code, the degradation-prevention processing efficiency of the application program is improved, and the repair period of the application program is shortened.
Based on the description of the embodiment of fig. 1, in step S102, the code management platform acquires a time-consuming function corresponding to a target path in all codes of the application program by combining dynamic analysis and static analysis.
In some embodiments, the code management platform may obtain the target file. Among all the codes of the application programs, all the functions related to the target path of the application program are recorded in the target file. The specific implementation of the object file is not limited in this disclosure. And references to functions in this disclosure are also to be understood as a method or method of function.
In addition, the object file may be stored in the code management platform, may also be stored in the server, and may also be stored in the code management platform and the server, so as to fully consider the storage space that the code management platform may have, which is not limited by the present disclosure. For convenience of explanation, the present disclosure is illustrated by taking a code management platform as an example to store the object file.
Since the code management platform can determine all functions related to the target path in all codes of the application program based on the target file, and the codes in the modification part can be instruction codes or calling codes in the functions. Thus, the code management platform may analyze whether the code in the modified portion is contained in a function of the target file record to determine whether the code in the modified portion relates to the target path.
The code management platform may determine that the code in the modified portion relates to a target path when the code in the modified portion is included in a function of the target file record.
The code management platform may determine that the code in the modified portion does not relate to the target path when the code in the modified portion is not included in the function of the target file record. At this time, the code management platform may notify the code reviewer to perform the warehousing operation on the import code.
In a specific embodiment, assuming that the target path is a start path, based on the description of fig. 1 and the above embodiment, with reference to fig. 2, a possible way for the code management platform to adopt the processing method of the application program in the embodiment of fig. 1 is introduced.
As shown in FIG. 2, the code management platform may perform the following steps:
in step 01, the developer submits Merge Request (MR) code to the code management platform, corresponding to step 101 in fig. 1. The MR code is the incorporated code of the application program.
Step 02, after the code management platform enters the detection process, the target file is obtained from the server, and whether the code in the modified part in the MR code relates to the start path is judged based on the target file, which corresponds to step 102 in fig. 1.
Step 03, when the code in the modified part in the MR code relates to a start path, the code management platform determines whether there is a time-consuming operation on the code in the modified part, which corresponds to step 103 in fig. 1.
Step 04, the code management platform outputs the analysis result when there is time-consuming operation to modify the code in the part, which corresponds to step 103 in fig. 1.
Thus, the code management platform can enter the review stage and notify the code reviewer of the analysis result, so that the code reviewer can judge whether the MR code can pass through based on the analysis result. After the MR codes pass, the code management platform can enter a warehousing procedure so as to store the MR codes into a warehouse.
In addition, the code in the modification part of the code management platform does not relate to a starting path, or the code in the modification part can enter a warehousing process when no time-consuming operation exists.
In the present disclosure, the code management platform may obtain the target file in various ways. The target file can be divided into a first file and a second file, all functions related to the target path in all codes of the application program are recorded in the first file and the second file, and all functions related to the target path in all the codes of the application program are determined from different angles in the first file and the second file.
Next, referring to fig. 3, a specific implementation manner of the code management platform obtaining the target file is described in a case that the target file is stored in the local storage module of the code management platform.
Referring to fig. 3, fig. 3 is a flowchart illustrating a processing method of an application according to an embodiment of the disclosure. As shown in fig. 3, the processing method of the application program provided by the present disclosure may include:
s201, acquiring a first file, and determining a first function set called in a target path in all codes of the application program based on the first file.
In the present disclosure, the first file records a function in the entire code of the application program from the viewpoint of whether or not it is called in the target path. Accordingly, the code management platform may retrieve a first file from a local storage module of the code management platform and determine, based on the first file, a first set of functions of the overall code of the application that are invoked in the target path.
The present disclosure does not limit the determination manner of the first file. In some embodiments, as shown in fig. 4, the step of determining the first file may include:
and 11, configuring a start function and a stop function of the target path in the compiling stage of the application program.
The starting function is used for starting the target path, and the terminating function is used for terminating the target path. The present disclosure does not limit the specific implementation methods of the target path, the start function, and the end function.
And step 12, performing instrumentation on all codes of the application program.
The present disclosure does not limit the specific implementation manner of the pile insertion process. In some embodiments, at the compile time of an application, "stub functions" are inserted into "exits" and "entries" of all functions in all code of the application.
And step 13, recording the called function between the starting function and the terminating function in a first file in the running stage of the application program based on the instrumentation processing.
The code management platform can automatically start the application program so as to collect called functions in all codes of the application program. For example, if the target path is the main thread of the main program of the application program, the called function in all the codes of the application program is the function started by the main thread of the main process.
In the running phase of the application, if a function is called in the target path, the "stub function" may record the function. After the target path is cut, the "stub function" stops recording. That is, after the termination function is executed for the first time, the collection of the called function incorporated in the code in the target path is stopped. Thus, the code management platform may save all the functions that have been recorded in the first file.
And step 14, saving the first file. Specifically, the first file may be saved locally and then sent to the server.
Therefore, the code management platform can realize dynamic collection of the first function set corresponding to the target path in all codes of the application program.
It should be noted that, in the embodiment of fig. 4, the determining step of the first file may be executed by other execution platforms besides the code management platform, and the disclosure is not limited thereto.
S202, acquiring a second file, and determining a second function set called in the root function of the target path in all codes of the application program based on the second file.
In the present disclosure, the second file records a function in the entire code of the application program from the viewpoint of whether or not it is called in the root function of the target path. Therefore, the code management platform may obtain the second file from the local storage module of the code management platform, and determine, based on the second file, a second set of functions in the code management platform that are invoked in the root function of the target path.
The present disclosure does not limit the determination manner of the second file. In some embodiments, as shown in fig. 5, the determining of the second file may include:
and step 21, determining a root function of the target path.
The present disclosure does not limit the specific implementation manner of the root function of the target path. For example, when the target path is the start path, the root function of the target path may be configured as an Android four-large component (activity, service, content provider, broadcast receiver) and application-started related declaration periodic function. In addition, the root function of the target path can be configured in the code management platform in advance, and repeated configuration is not needed.
Step 22, compile all code of the application into a first bytecode.
And step 23, performing static analysis on the first byte code, acquiring sub-functions directly and indirectly called by the root function, and recording the root function and the sub-functions in a second file.
The code management platform may determine all the link functions (i.e., root functions and subfunctions) by determining a path called by a corresponding function in the first bytecode using a bytecode static analysis method and analyzing directly-called and indirectly-called subfunctions of the root function using a reachability algorithm such as the optimized MainDexList. Thus, the code management platform may record all collected link functions into a second file.
And 24, saving the second file. Specifically, the second file may be saved locally and then sent to the server.
Thus, the code management platform can realize static collection of the second function set called in the root function of the target path in all codes of the application program.
It should be noted that, in the embodiment of fig. 5, the determining step of the second file may be executed by other execution platforms besides the code management platform, which is not limited in this disclosure.
S203, determining the union of the first function set and the second function set as a target file.
Since the first set of functions and the second set of functions may each miss some functions in the target path. For example, the first set of functions cannot cover all if-else code branches, and the second set of functions cannot cover the cases of indirect method calls (such as call modes of Action, event, and the like). Therefore, the code management platform can take the union of the first function set and the second function set as a target file and cover the target path as completely as possible.
In summary, the code management platform may obtain the target file from a local storage module of the code management platform.
It should be noted that, in addition to the above implementation, the code management platform may also obtain the target file from the server, or may also obtain the first file and the second file from the server, respectively.
Based on the above description of the embodiments in fig. 3 to fig. 5, the code management platform may collect the target file obtained based on the dynamic and static combination policy as completely as possible, so as to analyze the function related to the target path as completely as possible, thereby determining whether the modified part in the incorporated code relates to the target path to the greatest extent based on the target file.
In the present disclosure, the code management platform may adopt various implementations to determine whether there is a time-consuming operation in the code in the modification part in step S104.
One possible implementation of the code management platform determining whether there are time-consuming operations to modify the code in the section is described below in conjunction with FIG. 6.
Referring to fig. 6, fig. 6 is a flowchart illustrating a processing method of an application according to an embodiment of the disclosure. As shown in fig. 6, the processing method of the application program provided by the present disclosure may include:
s301, in the compiling stage of the application program, the modified part is compiled into a second byte code.
Since the code management platform is capable of executing bytecodes. Therefore, in the compiling stage of the application program, the code management platform can compile the modified part into the second bytecode, so that the code management platform can judge whether time-consuming operation exists in the code in the modified part corresponding to the function corresponding to the bytecode through static analysis of the bytecode.
For example, if the code in the modified part is Java source code, the code management platform may compile the Java source code into a second bytecode executable by the code management platform, so as to determine whether the corresponding function is time-consuming by statically analyzing the instruction corresponding to the bytecode.
S302, for each corresponding function in the second bytecode, determining whether the type of each function is within the type range of a preset list, wherein the type of the time-consuming function is recorded in the preset list.
Since the type of the time-consuming function is recorded in the preset list. Therefore, for a corresponding function in the second bytecode, in the running phase of the target path, the code management platform may determine whether a function type is within a type range of the preset list to determine whether the function has time-consuming operation corresponding to the code in the modification part.
The preset list may be configured in the code management platform in advance, or may be input into the code management platform by a developer, which is not limited in this disclosure.
In addition, the specific implementation modes of the preset list and the time-consuming function are not limited in the present disclosure.
In some embodiments, the types of time consuming functions in the preset list may include, but are not limited to: the method comprises a lock function, a JSON analysis function, a read-write I/O function and a system time consuming function (if an applied function fun1 calls a time consuming function aFun1 in the Android SDK, the function fun1 belongs to the time consuming function). In addition, the type of time consuming function in the preset list may also include a round function.
When the type of the corresponding function in the second bytecode is within the type range of the preset list, the code management platform may perform step S3031; when the type of the corresponding function in the second bytecode is not within the type range of the preset list, the code management platform may perform step S3032.
S3031, it is determined that there is a time-consuming operation of the corresponding one of the second bytecodes corresponding to the code in the modified portion.
When the type of the corresponding function in the second bytecode is within the type range of the preset list, the code management platform can determine that time-consuming operation exists when the function corresponds to the code in the modification part.
S3032, it is determined that there is no time-consuming operation when the corresponding one of the second bytecodes corresponds to the code in the modified portion.
The code management platform may determine that there is no time-consuming operation for the function corresponding to the code in the modified portion when the type of the corresponding function in the second bytecode is not within the range of types of the preset list.
In summary, the code management platform may determine whether there is a time-consuming operation on the code in the modified portion based on all corresponding functions in the second bytecode.
Thus, the time-consuming static analysis determines whether there is a time-consuming operation to modify the code in the portion.
In addition, based on the above description, the code management platform may take on the principle of "function time consuming has transitivity" to determine whether there is a time consuming operation to modify the code in the portion.
In addition, the code in the modification part may call a function of an existing previous version of the application program, and the code in the modification part does not include the code of the called function. Therefore, all corresponding functions in the second bytecode may not contain the called function.
Therefore, for a corresponding function in the second bytecode, when the function has a called external function and all corresponding functions in the second bytecode do not include the external function called by the function, the code management platform may determine whether the type of the external second function called by the function is within the type range of the preset list, so as to determine whether the function has time-consuming operation. Thereby, it is facilitated to comprehensively determine the time consuming function in the code in the modified portion.
When the external function called by the function is within the type range of the preset list, the code management platform can determine that the function has time-consuming operation corresponding to the code in the modification part.
When the external function called by the function is not in the type range of the preset list, the code management platform can determine that no time-consuming operation exists when the function corresponds to the code in the modification part.
In other embodiments, the code in the modified portion is itself a function (referred to as a first function), and the first function calls a second function. I.e. the second function is a child of the first function and the first function is a parent of the second function. Thus, the code management platform can also determine whether the first function has time-consuming operation by determining whether the type of the second function is within the range of the type of the preset list.
Thus, the code management platform may determine that there is a time-consuming operation with the first function when the second function is within the type range of the preset list. When the second function is not within the type range of the preset list, the code management platform can determine that no time-consuming operation exists for the first function.
For example, assume that the calling relationship of the three functions is function fun1- > function fun2- > function fun3, i.e., function fun1 calls function fun2 and function fun2 calls function fun3. In the case that function fun1 and function fun2 do not belong to the type of time consuming function, if function fun3 belongs to the type of time consuming function, the code management platform may determine that function fun1, function fun2 and function fun3 all belong to time consuming functions, and there are time consuming operations for all three functions corresponding to the codes in the modified part.
In summary, when it is determined that a corresponding function in the second bytecode is time-consuming to operate and involves the target path, the code management platform may determine the function as the target code, determine the position of the function as the position of the target code, and store the target code and the position of the target code into the analysis result.
Illustratively, the present disclosure provides a processing device for an application.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a processing device of an application according to an embodiment of the present disclosure. The processing device of the application program of the present disclosure may be disposed in a code management platform, and the processing method of the application program that can implement the above-described embodiments of fig. 1 to fig. 6 corresponds to the operation of the code management platform.
As shown in fig. 7, the processing device 100 of the application provided by the present disclosure may include: a receiving module 101, a determining module 102 and an output module 103.
A receiving module 101, configured to receive an import code of an application;
a determining module 102, configured to determine whether code in the modified portion of the incorporated code relates to a target path of the application;
a determining module 102, configured to determine whether there is a time-consuming operation on the code in the modified portion;
and the output module 103 is used for outputting an analysis result when the code in the modification part relates to the target path and the time-consuming operation exists, wherein the analysis result comprises the position of the target code and the target code, which relates to the target path and has the time-consuming operation, included in the incorporated code.
In one possible design, the determining module 102 is specifically configured to determine whether there is a time-consuming operation on the code related to the target path in the modified portion after determining that the code related to the target path in the modified portion is related to the target path.
In some embodiments, the determining module 102 is specifically configured to obtain a target file, where all functions related to a target path in all codes of an application are recorded in the target file; based on the target file, it is determined whether the code in the modified portion relates to a target path.
In some embodiments, the determining module 102 is configured to determine that the code in the modified portion relates to the target path when the code in the modified portion is included in the function of the target file record; determining that the code in the modified portion does not relate to the target path when the code in the modified portion is not included in the function of the target file record.
In some embodiments, the determining module 102 is configured to obtain a first file, and determine, based on the first file, a first function set called in the target path in all the codes of the application program; acquiring a second file, and determining a second function set called in a root function of the target path in all codes of the application program based on the second file; and determining the union of the first function set and the second function set as a target file.
In some embodiments, the determining module 102 is further configured to determine the first file. A determining module 102, configured to configure a start function and a stop function of a target path in a compiling stage of an application program; performing instrumentation on all codes of the application program; recording a called function between a start function and a stop function in a first file in the running stage of the application program based on instrumentation; the first file is saved.
In some embodiments, the determining module 102 is further configured to determine the second file. A determining module 102, specifically configured to determine a root function of a configured target path; compiling all codes of an application program into first byte codes; performing static analysis on the first byte code to obtain sub-functions directly and indirectly called by the root function, and recording the root function and the sub-functions in a second file; and saving the second file.
In some embodiments, the determining module 102 is further specifically configured to compile the modified portion into the second bytecode in a compiling stage of the application; for each corresponding function in the second bytecode, determining whether the type of each function is within the type range of a preset list in the running stage of the target path, wherein the type of the time-consuming function is recorded in the preset list; when the type of a corresponding function in the second byte codes is within the type range of the preset list, determining that time-consuming operation exists when the function corresponds to the codes in the modification part; and when the corresponding function type in the second bytecode is not in the type range of the preset list, determining that no time-consuming operation exists when the function corresponds to the code in the modified part.
In some embodiments, the determining module 102 is further configured to determine whether a type of the external function called by the function is within a type range of the preset list when the called external function exists in the corresponding function in the second bytecode and all the corresponding functions in the second bytecode do not include the external function called by the function; determining that time-consuming operation exists in a function when an external function called by the function is within the type range of a preset list; and when the external function called by the function is not in the type range of the preset list, determining that no time-consuming operation exists in the function.
In one possible design, when it is determined that a corresponding function in the second bytecode has a time-consuming operation and involves the target path, the function is determined as the target code, the position of the function is determined as the position of the target code, and the target code and the position of the target code are saved into the analysis result.
In some embodiments, the types of time consuming functions in the preset list include: the method comprises a lock function, a JSON analysis function, a read-write I/O function and a system time consumption function.
In some embodiments, the target path is a main thread of a main process in the launch path of the application.
The processing apparatus for an application provided in the present disclosure may execute the above method embodiments, and specific implementation principles and technical effects thereof may refer to the above method embodiments, which are not described herein again.
Illustratively, the present disclosure provides an electronic device comprising: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; the one or more processors, when executing the one or more computer programs, cause the electronic device to implement the processing methods of the application programs of the foregoing embodiments.
Illustratively, the present disclosure provides a chip system applied to an electronic device including a memory and a sensor; the chip system includes: a processor; when the processor executes the processing method of the application program in the foregoing embodiment.
Exemplarily, the present disclosure provides a computer-readable storage medium on which a computer program is stored, the computer program being executed by a processor such that an electronic device implements the processing method of the application program of the foregoing embodiment.
The present disclosure provides, by way of example, a computer program product which, when run on a computer, causes the computer to perform the processing method of the application program of the foregoing embodiments.
In the above-described embodiments, all or part of the functions may be implemented by software, hardware, or a combination of software and hardware. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The procedures or functions according to the embodiments of the disclosure are wholly or partially generated when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium. Computer-readable storage media can be any available media that can be accessed by a computer or a data storage device, such as a server, data center, etc., that includes one or more available media. The usable medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a component of' 8230; \8230;" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present disclosure, which will enable those skilled in the art to understand or practice the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (16)

1. A processing method of an application program is characterized by comprising the following steps:
receiving an import code of an application program;
determining whether code in a modified portion of the incorporated code relates to a target path of the application;
determining whether there is a time-consuming operation on the code in the modified portion;
when the code in the modification part relates to the target path and time-consuming operation exists, outputting an analysis result, wherein the analysis result comprises the target code which relates to the target path and has time-consuming operation and the position of the target code in the incorporated code.
2. The method of claim 1, wherein determining whether there is a time consuming operation for the code in the modified portion comprises:
and if the codes in the modified part relate to the target path, determining whether time-consuming operation exists in the codes relating to the target path in the modified part.
3. The method of claim 1 or 2, wherein the determining whether code in the modified portion of the incorporated code relates to a target path of the application comprises:
acquiring a target file, wherein all functions related to the target path in all codes of the application program are recorded in the target file;
determining, based on the target file, whether the code in the modified portion relates to the target path.
4. The method of claim 3, wherein determining whether code in the modified portion relates to the target path based on the target file comprises:
determining that the code in the modified portion relates to the target path when the code in the modified portion is included in the function of the target file record;
determining that the code in the modified portion does not relate to the target path when the code in the modified portion is not included in the function of the target file record.
5. The method of claim 3, wherein obtaining the target file comprises:
acquiring a first file, and determining a first function set called in the target path in all codes of the application program based on the first file;
acquiring a second file, and determining a second function set called in the root function of the target path in all codes of the application program based on the second file;
and determining the union of the first function set and the second function set as the target file.
6. The method of claim 5, further comprising: determining the first file; the determining the first file comprises:
configuring a start function and a stop function of the target path in a compiling stage of the application program;
performing instrumentation on all codes of the application program;
recording a called function between the start function and the end function in the first file in a running phase of the application program based on the instrumentation processing;
and saving the first file.
7. The method of claim 5, further comprising: determining the second file; the determining the second file comprises:
determining a root function of the target path
Compiling all code of the application into first bytecode;
performing static analysis on the first byte code to obtain sub-functions directly and indirectly called by the root function, and recording the root function and the sub-functions in the second file;
and saving the second file.
8. The method of any of claims 1-7, wherein determining whether there is a time consuming operation for code in the modified portion comprises:
compiling the modified portion into a second bytecode in a compilation stage of the application;
for each corresponding function in the second bytecode, determining whether the type of each function is within the type range of a preset list, wherein the type of the time-consuming function is recorded in the preset list;
when the type of a corresponding function in the second bytecode is within the type range of the preset list, determining that time-consuming operation exists when the function corresponds to the code in the modified part;
and when the corresponding function type in the second bytecode is not in the type range of the preset list, determining that no time-consuming operation exists when the function type corresponds to the code in the modified part.
9. The method of claim 8, wherein when a corresponding one of the functions in the second bytecode calls an external function, and corresponding all of the functions in the second bytecode do not include the external function, the method further comprises:
determining whether the type of the external function is within a range of types of the preset list;
when the external function is within the type range of the preset list, determining that time-consuming operation exists in the function;
and when the external function is not in the type range of the preset list, determining that the function has no time-consuming operation.
10. The method according to claim 8 or 9, wherein when it is determined that there is a time-consuming operation on the corresponding one of the second bytecodes and the target path is involved, the one function is determined as the target code, the location of the one function is determined as the location of the target code, and the target code and the location of the target code are saved into the analysis result.
11. The method according to any of claims 8-10, wherein the type of time consuming function in the preset list comprises: locking function, JSON analysis function, read-write I/O function and system time consuming function.
12. The method of any of claims 1-11, wherein the target path is a main thread of a main process in a launch path of the application.
13. An apparatus for processing an application program, comprising:
the receiving module is used for receiving the import code of the application program;
a determination module to determine whether code in a modified portion of the incorporated code relates to a target path of the application;
the determining module is further used for determining whether time-consuming operation exists in the code in the modification part;
and the output module is used for outputting an analysis result when the code in the modification part relates to the target path and the time-consuming operation exists, wherein the analysis result comprises the target code which relates to the target path and has the time-consuming operation and the position of the target code in the incorporated code.
14. An electronic device, comprising: one or more processors; a memory; and one or more computer programs; wherein the one or more computer programs are stored in the memory; characterized in that the one or more processors, when executing the one or more computer programs, cause the electronic device to implement a processing method of an application program according to any of claims 1-12.
15. A computer storage medium, comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the processing method of an application program according to any one of claims 1 to 12.
16. A computer program product, characterized in that it causes a computer to carry out the processing method of an application according to any one of claims 1 to 12, when said computer program product is run on said computer.
CN202110407836.3A 2021-04-15 2021-04-15 Application processing method and device and electronic equipment Pending CN115220725A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110407836.3A CN115220725A (en) 2021-04-15 2021-04-15 Application processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110407836.3A CN115220725A (en) 2021-04-15 2021-04-15 Application processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115220725A true CN115220725A (en) 2022-10-21

Family

ID=83605562

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110407836.3A Pending CN115220725A (en) 2021-04-15 2021-04-15 Application processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115220725A (en)

Similar Documents

Publication Publication Date Title
US9274768B2 (en) Runtime code hooking for print driver and functionality testing
US8020149B2 (en) System and method for mitigating repeated crashes of an application resulting from supplemental code
EP2386955B1 (en) Detection of method calls to streamline diagnosis of custom code through dynamic instrumentation
US6681391B1 (en) Method and system for installing software on a computer system
US8938729B2 (en) Two pass automated application instrumentation
US9104794B2 (en) Automatic incremental application dependency discovery through code instrumentation
US7917901B2 (en) Maintainable dynamic instrumentation technique for changing versions of software
WO2010041467A2 (en) USING TRANSIENT PCRs TO REALISE TRUST IN APPLICATION SPACE OF A SECURE PROCESSING SYSTEM
US7321988B2 (en) Identifying a code library from the subset of base pointers that caused a failure generating instruction to be executed
US20050262488A1 (en) System and method for managing cross project dependencies at development time
EP2035922A1 (en) Iterative static and dynamic software analysis
US20090089766A1 (en) Automatically Modifying a Native Code Module Accessed from Virtual Machine Bytecode to Determine Execution Information
US9104781B2 (en) Obtaining metadata set by imperative statement
US20090235284A1 (en) Cross-platform compatibility framework for computer applications
CN111679852B (en) Detection method and device for conflict dependency library
US20130159976A1 (en) Abstract syntax tree transformation
US9183021B2 (en) Runtime optimization of application bytecode via call transformations
EP2885712B1 (en) Imperative attribution for elements in managed runtimes
CN110334031B (en) Memory allocation code detection method and device, computer equipment and storage medium
Bai et al. Effective detection of sleep-in-atomic-context bugs in the Linux kernel
CN115220725A (en) Application processing method and device and electronic equipment
US20120166892A1 (en) Orphan object tracking for objects having acquire-release semantics
US20120117546A1 (en) Run-time Module Interdependency Verification
CN116841890A (en) Method and system for debugging front-end project
Pácal Object Usage Analyser for TypeScript

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