A concurrent defect detection method, test equipment and storage medium

By instrumenting the installation package and local source code files of mobile terminal applications, we can obtain information about target classes and target call statements, detect concurrency defects, solve the problem of concurrency defects caused by native code operating Java objects, and improve the efficiency of applications. Stability and user experience.

CN117707918BActive Publication Date: 2024-09-06HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310620125.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-29
Publication Date
2024-09-06
Estimated Expiration
2043-05-29

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively detect concurrency defects caused by native code operating Java objects in mobile terminal applications, which may cause the application to crash or become unstable, affecting the user experience.

Method used

Provides a concurrent defect detection method that obtains static and dynamic information of target classes and target call statements by instrumenting the installation package and local source code files of the target application, and combines the runtime information of the target programming language and the local programming language. ,detecting concurrency defects.

Benefits of technology

It realizes concurrent defect detection of Java code and native code, improves the stability and user experience of the application, and ensures the quality and performance of the application after release.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707918B
    Figure CN117707918B
Patent Text Reader

Abstract

The present application provides a concurrency defect detection method, test equipment and storage medium, which relate to the field of defect detection and can obtain richer runtime information to obtain more accurate concurrency defect detection results. The method includes: obtaining the installation package of the target application and the local source code file corresponding to the target application; inserting the target class in the first code file in the installation package and obtaining the static information of the target class; identifying and inserting the target call statement in the local source code file and obtaining the static information of the target call statement; generating the target installation package of the target application based on the first code file after the insertion and the local source code file after the insertion; sending the target installation package to the test terminal; receiving the dynamic information of the target class and the dynamic information of the target call statement from the test terminal; determining the concurrency defects of the target application based on the runtime information of all target classes and the runtime information of all target call statements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a concurrent defect detection method, testing equipment and storage medium. Background Art

[0002] With the widespread use of applications on mobile terminals, the development of operating systems and applications for mobile terminals has become increasingly complex. At present, most applications have multi-threaded concurrent execution in actual use, that is, the application has multiple threads executing tasks at the same time. Multi-threaded concurrent execution allows applications to meet the various needs of users, but when multi-threaded concurrent execution occurs, concurrency defects may occur due to mutual interference, competition and conflict when different threads are executed. In order to avoid the application from having execution results that do not meet the user's expectations due to concurrency defects, the user can use code instrumentation technology to collect the runtime information of the application after the initial development of the application is completed, and then use a specific analysis algorithm to analyze the runtime information to determine possible concurrency defects.

[0003] Most of the current applications on mobile terminals mainly use object-oriented Java code to develop most of the functions, so traditional code plugging technology is mostly for Java code plugging. However, some applications with high performance requirements, such as game applications, browser applications, multimedia playback applications, etc., will use native code (such as C or C++ code) to implement some functions (such as graphics rendering, network communication, etc.), and this part of the native code will also operate the Java objects in the Java code through the Java native interface (Java native interface, JNI) interface. Since native code and Java code are different high-level languages, traditional plugging technology for Java code will not be able to effectively collect the runtime information of native code, so that the concurrency defects caused by the native code operating Java objects cannot be detected. The application that has been tested may crash or become unstable due to these concurrency defects, affecting the user experience. Summary of the invention

[0004] The embodiments of the present application provide a concurrency defect detection method, a test device, and a storage medium, which can simultaneously obtain the runtime information of the code corresponding to the target programming language and the runtime information of the code corresponding to the local programming language, so that more accurate concurrency defect detection results can be obtained by using richer runtime information, thereby making the final target application less likely to fail, thereby improving the user experience of users of the target application.

[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0006] In a first aspect, the present application provides a concurrent defect detection method. The method comprises: a test device acquires an installation package of a target application and a local source code file corresponding to the target application; the target application is a multi-threaded application written in a target programming language and a local programming language; the local source code file is a source code file written in a local programming language in the target application; the test device inserts a target class in a first code file in the installation package and acquires static information of the target class; the test device identifies and inserts a target call statement in the local source code file and acquires static information of the target call statement; the target call statement is a call statement to a target interface in the local source code file, and the target interface is used for a code file corresponding to the local programming language to complete interaction with a code file corresponding to the target programming language; the test device generates a target installation package of the target application based on the inserted first code file and the inserted local source code file; the test device sends the target installation package to a test terminal; the test device receives dynamic information of the target class and dynamic information of the target call statement from the test terminal; the test device determines the concurrency defect of the target application based on the runtime information of all target classes and the runtime information of all target call statements; the runtime information of the target class includes static information and dynamic information of the target class, and the runtime information of the target call statement includes static information and dynamic information of the target call statement.

[0007] Based on the above technical solution, the first code file corresponding to the target programming language (i.e., Java code) in the target application can be instrumented to obtain the corresponding runtime information, and the local source code corresponding to the target application can be instrumented to obtain the relevant runtime information of the native code's operation on the Java object. In this way, the user can obtain all the data that may cause concurrency defects in the Java code through the test equipment, so that the test equipment can finally detect the concurrency defects generated by the Java code more comprehensively based on these data to guide the developers to adjust and modify the target application, thereby making the quality and performance of the target application finally released better, and improving the user experience of the target application.

[0008] In a possible implementation of the first aspect, a test device inserts a target class in a first code file in an installation package, including: the test device receives a code file selection operation from a user; the test device responds to the code file selection operation and determines that, among all code files corresponding to a target programming language in a target application installation package, the code file corresponding to the code file selection operation is a first code file; the test device determines a target class in the first code file that needs to be inserted; and the test device inserts the target class in the first code file.

[0009] In practice, for the target programming language, there will be multiple code files corresponding to the target programming language in the installation package of the target application. If the code files are not screened, the final instrumentation result may not meet the user's needs. Based on the above technical solution, the user can select all code files corresponding to the target programming language in the installation package of the target application according to their own needs, and the test equipment can determine the first code file that meets the user's needs based on the user's code file selection operation. In this way, the subsequent instrumentation can smoothly obtain runtime information that meets the user's needs, avoid obtaining runtime information that does not meet the user's needs, and improve the test efficiency of concurrency defects in the target application.

[0010] In a possible implementation of the first aspect, a test device determines a target class that needs to be plugged in a first code file, including: the test device receives a class selection operation of a user; and the test device responds to the class selection operation and determines the class corresponding to the class selection operation as the target class.

[0011] Since the testing of concurrency defects of the target application may be biased in practice, the test device can determine the target class that needs to be plugged in the first code file in any feasible way according to the requirements. Based on the above technical solution, the test device can determine the target class required by the user based on the user's tendency, and then plug the target class, and finally obtain the runtime information required by the user.

[0012] In a possible implementation of the first aspect, the target programming language is Java, and the test device inserts a target class in the first code file in the installation package, including: the test device inserts the target class of the first code file based on the Android version library that the first code file depends on and the DEX library of the Android system framework.

[0013] In practice, the Android platform is a rapidly developing ecosystem, and each new version of the Android system will introduce new APIs and changes. Therefore, when inserting the dex file in the installation package of the Android platform application, it is necessary to consider the interface version compatibility between the application and the Android system. If the wrong or incompatible version library is used, the inserted probe code may be unavailable, crash, or produce other abnormal behaviors. Secondly, Android platform applications usually rely on many third-party libraries and frameworks, which also have version compatibility issues. If the library that the probe code inserted into the dex file depends on is inconsistent with the current Android version library, it may cause compilation failure or runtime errors. Thirdly, the API of each version of the Android system may change in its implementation details (for example, some methods are renamed, moved to different classes, or the value of a flag is modified), and these details may affect the actual effect and accuracy of the probe code. When parsing the dex file, the structure of the dex file, the interpretation of the specific content, and the dependency information are based on the DEX library in the Android system framework. Therefore, to correctly parse the dex file and correctly insert the probe code, it is necessary to consider the DEX library in the Android system framework. Therefore, based on the above technical solution, the test device can successfully and correctly complete the plugging of the target class of the first code file.

[0014] In a possible implementation of the first aspect, the target programming language is Java, and the test device inserts a target class in a first code file in the installation package, including: the test device identifies and inserts a target statement in the target class of the first code file based on a first inserting tool; the target statement is a statement related to a target operation involved in a concurrency defect, and the target operation includes any of the following: an operation on a shared variable, an operation on a synchronization lock, a synchronization operation on a thread, and a conditional branch operation; at this time, the static information of the target class includes the static information of the target statement in the target class.

[0015] The purpose of inserting the target application's installation package to obtain runtime information is to detect concurrency defects corresponding to the Java code. In practice, the concurrency defects of the Java code mainly involve several target operations including: operations on shared variables (read operations and write operations), operations on synchronization locks (acquisition operations and release operations), synchronization operations on threads, conditional branch operations, etc. Therefore, when the test equipment inserts the target class in the first code file, it mainly needs to identify the target statements in the target class corresponding to the above-mentioned target operations. The static information of the target class may specifically include the static information of the target statement in the target class. Based on this, the embodiment of the present application needs to complete the insertion of the target statement in the target class based on the above-mentioned technical solution, implement statement-level insertion, obtain statement-level runtime information related to the concurrency defect, and thereby make the subsequent detection of concurrency defects more accurate.

[0016] In a possible implementation of the first aspect, a test device identifies and inserts a target statement in a target class of a first code file, including: the test device identifies the target statement in the target class of the first code file; the test device inserts a first probe code before or after the target statement; the first probe code is used to obtain runtime information corresponding to the target statement; the runtime information includes static information and dynamic information, the static information includes a variable identifier and an instruction identifier, and the dynamic information includes an operation type, an instance hash value of the variable, a thread identifier, and a sequence identifier.

[0017] Based on the above technical solution, the target statement can be successfully instrumented. At the same time, according to user needs, the probe code can be inserted before or after the target statement, making the instrumentation method more flexible and the runtime information finally obtained more in line with user needs.

[0018] In a possible implementation of the first aspect, a test device identifies and inserts a target call statement in a local source code file, including: the test device uses a local source code compiler to compile a local source code file to obtain a local code file; the test device identifies and inserts the target call statement in the local code file based on a second insertion tool.

[0019] Based on the above technical solution, since direct source code stubbing requires recompiling the program and is greatly affected by the syntax of the source language, the test device can first compile the local source code file to obtain the local code file, and then more conveniently complete the stubbing of the target call statement. After that, the runtime information can be obtained after the target application is installed.

[0020] In a possible implementation of the first aspect, a test device identifies and inserts a target call statement in a local code file based on a second instrumentation tool, including: the test device identifies the target call statement in the local code file based on the second instrumentation tool; the test device inserts a second probe code before or after the target call statement based on the second instrumentation tool; the second probe code is used to obtain runtime information corresponding to the target call statement; the runtime information includes static information and dynamic information, the static information includes a variable identifier and an instruction identifier, and the dynamic information includes an operation type, an instance hash value of a variable, a thread identifier, and a sequence identifier.

[0021] Based on the above technical solution, the target call statement can be successfully instrumented. At the same time, according to user needs, the probe code can be inserted before or after the target call statement, making the instrumentation method more flexible and the runtime information finally obtained more in line with user needs.

[0022] In a possible implementation of the first aspect, a test device obtains static information of a target call statement, including: the test device obtains an instruction identifier of the target call statement; the test device uses the variable identifier of the target statement that is identical to the static feature information of the variable corresponding to the target call statement as the variable identifier of the target call statement; the target statement is a statement in a target class related to a target operation involved in a concurrency defect; the target operation includes any of the following: an operation on a shared variable, an operation on a synchronization lock, a synchronization operation on a thread, and a conditional branch operation; the static feature information of the variable includes: the name of the variable, the type of the variable, and the class to which the variable belongs.

[0023] Based on the above technical solution, the test equipment can successfully complete the instrumentation of the target call statement. In addition, by obtaining the static information of the target call statement based on the static information of the target statement, the variable identifiers for the same object in all the runtime information finally obtained can be the same, and all runtime information related to the same object can be easily found, which can also more accurately locate the objects related to the concurrency defect.

[0024] In a possible implementation of the first aspect, the probe code inserted into the target class and the probe code inserted into the target call statement by the test device both include an instrumentation write interface method, and the instrumentation write interface method is used to write the runtime information obtained by the probe code into a file corresponding to the probe code by passing parameters.

[0025] In this way, the runtime information obtained by the probe code can be smoothly written to a specific storage location. At the same time, the implementation of the plug-in write interface method to write the runtime information can be implemented by the thread where the corresponding target statement or target call statement is located. In this way, the plug-in write interface method is that the threads corresponding to each statement write the runtime information to different files respectively, and the writing operations do not interfere with each other before, avoiding thread synchronization operations.

[0026] In a possible implementation of the first aspect, the method further includes: the test device generates an original operation sequence based on sequence identifiers in the runtime information of all target classes and the sequence identifiers in the runtime information of all target call statements, using operations corresponding to all target classes and operations corresponding to all target call statements, and determines characteristic parameters of the original operation sequence; the test device determines the concurrency defect of the target application based on the runtime information of all target classes and the runtime information of all target call statements, including: the test device determines the concurrency defect of the target application based on the runtime information of all target classes, the runtime information of all target call statements, the original operation sequence and the characteristic parameters of the original operation sequence.

[0027] Based on the above technical solution, after obtaining the runtime information of all target classes and all target call statements, in order to facilitate the subsequent detection of concurrency defects, the test equipment can also group the operations of all target classes and all target call statements into an operation sequence and determine its characteristic parameters. In this way, concurrency defects can be detected on a complete operation sequence, improving the efficiency of concurrency defect detection.

[0028] In a possible implementation manner of the first aspect, the method further includes: the testing device updates the thread identifiers in the runtime information of all target classes and all target call statements from physical thread identifiers to logical thread identifiers.

[0029] Based on this solution, the test equipment can obtain more accurate logical thread identification, and can also avoid the influence of hardware and operating system during the subsequent concurrent defect analysis, making the final concurrent defect analysis results more accurate.

[0030] In a second aspect, the present application provides a testing device, which includes: a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; wherein the memory stores computer program code, the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the testing device executes the concurrent defect detection method provided in the first aspect.

[0031] In a third aspect, the present application provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a test device, the test device executes the concurrent defect detection method provided in the first aspect.

[0032] In a fourth aspect, the present application provides a computer program product, which includes executable instructions. When the computer program product is run on an electronic device, the electronic device executes the concurrent defect detection method provided in the first aspect.

[0033] It can be understood that the beneficial effects that can be achieved by the technical solutions provided in the second to fourth aspects mentioned above can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of the structure of a test system provided in an embodiment of the present application;

[0035] Figure 2 A schematic diagram of the hardware structure of a test device provided in an embodiment of the present application;

[0036] Figure 3 A schematic diagram of the hardware structure of a test terminal provided in an embodiment of the present application;

[0037] Figure 4 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 1 ;

[0038] Figure 5 A schematic diagram of the structure of a test device provided in an embodiment of the present application;

[0039] Figure 6 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 2 ;

[0040] Figure 7 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 3 ;

[0041] Figure 8 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 4 ;

[0042] Fig. 9 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 5 ;

[0043] Fig.10 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 6 ;

[0044] Fig.11 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 7 ;

[0045] Fig.12 A schematic diagram of a concurrent defect process provided in an embodiment of the present application Figure 8 ;

[0046] Fig.13 A schematic diagram of the structure of another testing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to be limiting of the present application. As used in the specification and appended claims of the present application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to also include plural expressions, unless the context clearly indicates otherwise. It should also be understood that " / " means or, for example, A / B can mean A or B; "and / or" in the text is merely a description of an association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0048] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.

[0049] The terms "first" and "second" in the following embodiments of the present application are used for descriptive purposes only and should not be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more.

[0050] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:

[0051] (1) Instrumentation: Instrumentation is a technique that inserts additional code (also called probe code) into a software application to change or monitor behavior. It is often used in performance analysis, debugging, security checks, etc. It can capture and record information about the software application at runtime through instrumentation code. This information usually includes execution time, resource usage, memory usage, etc. By inserting stubs into program code, users can better understand the operation of the application, identify and solve defects in various applications, and improve the quality and performance of the application. Common instrumentation techniques include static instrumentation and dynamic instrumentation:

[0052] Static instrumentation: inserting instrumentation code into an application during the writing, compiling, and linking phases (i.e. before the program runs) to monitor and collect runtime information of the application. Dynamic instrumentation: dynamically injecting instrumentation code into a loaded program when the application is running, thus achieving an effect similar to static instrumentation.

[0053] In the technical solution provided in the present application, a static plugging method is used to plug the intermediate representation code (Intermediate Representation, IR) generated by the application during the compilation stage.

[0054] (2) Intermediate Representation (IR): For electronic devices that actually run applications, the target code (or machine code) that can be directly executed is composed of machine language, while the code of the application is highly abstract and cannot be directly executed. Based on this, before the application is installed on the electronic device, a compiler (or interpreter) is required to compile the source code of the application to generate the target code composed of machine language. In the process of converting the source code to the target code, it will first be converted into an intermediate representation, and then the compiler can complete the steps of register allocation, instruction selection, code scheduling and code optimization according to the intermediate representation, and then convert the intermediate representation into the target code. In an embodiment of the present application, the intermediate representation may include a dex (dalvik executable) file, and the dex file may include bytecodes of multiple classes.

[0055] (3) Concurrency defects: Concurrency defects refer to unpredictable erroneous behaviors and results that may occur in multi-threaded applications. Concurrency defects are caused by interference, competition and conflict between multiple threads during concurrent execution. Specifically, the following are the possible causes of concurrency defects:

[0056] Race conditions: When multiple threads access shared variables, due to different work progress or priorities between threads, inconsistencies in the order of operations on shared variables may occur, leading to unexpected results.

[0057] Deadlock: When multiple threads hold lock resources that they need from each other, they will not be able to continue executing and will be blocked at a certain point, forming an infinite loop.

[0058] Livelock: When multiple threads compete for the same resource, if they continue to give up the resource without substantial progress, livelock occurs.

[0059] Starvation: When some threads are essentially unable to obtain the resources they need, causing them to be permanently excluded from the operation of the entire system.

[0060] Memory model issues: Due to the delays and interactions between different central processing unit (CPU) cores and caches, when the processor performs specific internal cache synchronization operations becomes complicated, making it possible for shared data used by threads to be read and written in an unpredictable order.

[0061] Since there are many unpredictable factors in multithreaded programs, concurrency defects caused by these factors are also quite common. In order to avoid concurrency defects, it is necessary to obtain the runtime information of the application after the initial development, and use a specific algorithm to determine the possible concurrency defects of the application based on the runtime information.

[0062] (4) Shared variables: Shared variables are variables that are shared between multiple threads or processes. Because multiple threads / processes may access shared variables at the same time, if there is no appropriate protection for shared variables, data inconsistency and incorrect results may occur. In other words, the use of shared variables may cause concurrency defects in multi-threaded applications.

[0063] (5) Soot: Soot is a popular Java bytecode analysis and transformation framework (or it can be considered as a development tool or application), which provides many functions, such as class file parsing, control flow graph generation, data flow analysis, optimization, etc. The Soot framework can be used to analyze and transform Java bytecode (intermediate representation of Java code), so Soot can be applied to the instrumentation technology to monitor and modify Java code (i.e. instrumentation).

[0064] (6) Clane: Clang is a modern C, C++, and Objective-C compiler front end based on the C++ language. It can convert source code written in C++ into intermediate identification code IR.

[0065] (7) LLVM: The low level virtual machine (LLVM) is a compiler architecture / framework (or can be considered a compiler application) developed by the University of Illinois at Urbana-Champaign. It is based on the SSA (static single assignment, SSA) representation and provides compiler back-end support, reusable code generation and optimization components.

[0066] Clang and LLVM are often used together. Clang is responsible for parsing the source code at the front end and converting them into IR supported by LLVM. Then LLVM provides highly optimized code generation and analysis tools to process these IRs. Based on this, Clang is often called the compiler front end of LLVM, and LLVM is a general compiler framework.

[0067] (8) LLVM pass plugin: The LLVM pass plugin is a compiler optimization tool that can analyze and modify programs to improve program performance, reduce power consumption, etc. It can be used as a module in the compiler framework to implement various functions for specific target codes or program structures, such as implementing native code instrumentation.

[0068] (9) Operation: An operation is a basic unit for processing or transforming data or status in a system or application, and is represented by op. An operation op is represented by a four-tuple (id, tid, type, obj). Among them, tid represents the thread where the operation op is located, id represents the operation sequence number of the operation op in the thread, type represents the type of operation, and obj represents the object identifier or other identifier of the operation. All types of operations have the first three elements, but may not have the fourth element, such as the branch operation introduced later.

[0069] Operations can be divided into four categories according to the operation type, namely:

[0070] Read and write operations: (n, t, read, x) / (n, t, write, x) means that the nth operation of thread t is a read / write operation on variable x, which can be abbreviated as w(x) / r(x) when there is no ambiguity.

[0071] Lock operation: (n, t, acq, l) / (n, t, rel, l) means that the nth operation of thread t is to acquire / release lock l. It can be abbreviated as acq(l) / rel(l) when there is no ambiguity.

[0072] Branch operation: (n, t, br, -) represents conditional judgment, conditional loop, and object-oriented method call. It can be interpreted as the nth operation of thread t is branch operation br, or the operation sequence number of branch event br in thread t is n. It can be abbreviated to br if there is no ambiguity.

[0073] Thread synchronization operation: (n, t, fork, t') / (n, t, join, t') means that the nth event (or operation) of thread t is a thread creation / merge event, and the child thread being operated is t'. If there is no ambiguity, it can be abbreviated as fork(t, t') / join(t, t').

[0074] (10) Java Native Interface (JNI): JNI is a programming interface provided by the Java language that allows Java programs to interact and call underlying native code. JNI can implement a cross-platform communication mechanism and greatly expand the application scope and performance of Java. In a multi-threaded application developed with a mixture of Java code and native code, the native code calls or operates on Java objects through JNI.

[0075] At present, most applications on mobile terminals mainly use Java code to develop most of their functions, so traditional code instrumentation technology for concurrency defect detection is mostly for Java code instrumentation. However, some applications with high performance requirements will be jointly developed using Java code and native code. Among them, when multiple threads are executed simultaneously during the running of the application, the operation of the native code on the Java object may cause concurrency defects at the Java code level. However, the traditional instrumentation technology for Java code will not be able to collect the runtime information of the Native code, which makes it impossible to detect the concurrency defects caused by the Native code operating the Java object. The application that has finally been tested may crash or become unstable due to these concurrency defects, affecting the user experience.

[0076] In view of the above problems, the present application provides a plug-in solution for code plug-in. In this technical solution, while plugging the java code in the target application, plugging the relevant statements of the java local interface (java native interface, JNI) that operates the java object in the native code of the target application. Because the native code can only complete the operation of the java object through JNI, the plugging of the relevant statements of the java local interface (java native interface, JNI) that operates the java object in the native code can completely obtain the runtime information of the native code operating the java object. In this way, the technical solution can obtain the runtime information of the java code and the runtime information of the native code at the same time, and then based on these two kinds of information, all the concurrency defects related to the java code in the target application can be more completely obtained through a specific algorithm, and the user can also adjust the code of the target application based on the determined concurrency defects, so that the target application that is finally handed over to the user is less likely to fail, thereby improving the user's experience.

[0077] The technical solution provided by the embodiments of the present application is described in detail below with reference to the accompanying drawings.

[0078] The technical solution provided in this application can be applied in Figure 1 In the test system shown, the test system may include a test device 01 and a test terminal 02. The test device 01 and the test terminal communicate with each other via wired or wireless communication.

[0079] The test device 01 is mainly used for users to insert the target application that has been initially developed. The test terminal 02 is mainly used to install the target application and store or send the runtime information generated by the target application that can be used for testing to the test terminal after the test device 01 has completed the insertion of the target application.

[0080] In the present application, the test device 01 may be a mobile phone, a tablet computer, an ultra-mobile personal computer (UMPC), a netbook, a desktop computer, a laptop computer, a small laptop computer, an ultrabook, a personal digital assistant (PDA), etc., which can be used by a user to search and view codes. The present application does not impose any special restrictions on the specific form of the test client.

[0081] For example, refer to Figure 2 As shown, the test device 01 may include a processor 11, a memory 12, a display screen 13, a Wi-Fi device 14, a Bluetooth device 15, an audio circuit 16, a microphone 16A, a speaker 16B, a power system 17, a peripheral interface 18, a sensor module 19 and other components. These components may be connected through one or more communication buses or signal lines ( Figure 2 Those skilled in the art will appreciate that Figure 2 The hardware structure shown in the figure does not constitute a limitation on the test device 01. The test device 01 may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0082] The processor 11 is the control center of the test device 01. It uses various interfaces and lines to connect various parts of the test device 01. It executes various functions of the test device 01 and processes data by running or executing applications stored in the memory 12 and calling data and instructions stored in the memory 12. In some embodiments, the processor 11 may include one or more processing units; the processor 11 may also integrate an application processor and a modem processor; wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 11.

[0083] The memory 12 is used to store applications and data. The processor 11 executes various functions and data processing of the test device 01 by running the applications and data stored in the memory 12. The memory 12 mainly includes a program storage area and a data storage area. The program storage area can store an operating system and an application required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created when using the test device 01 (such as audio data, video data, etc.). In addition, the memory 12 may include a high-speed random access memory and may also include a non-volatile memory, such as a disk storage device, a flash memory device, or other non-volatile solid-state storage devices. The memory 12 can store various operating systems, such as those developed by Apple. Operating system, developed by Microsoft operating system, System and so on.

[0084] The display screen 13 is used to display images, videos, etc. The display screen can be a touch screen. In some embodiments, the test device 01 may include 1 or N display screens 13, where N is a positive integer greater than 1. The test device 01 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 13 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 11 may include one or more GPUs that execute program instructions to generate or change display information.

[0085] The Wi-Fi device 14 is used to provide the test device 01 with network access that complies with Wi-Fi related standard protocols. The test device 01 can access the Wi-Fi access point through the Wi-Fi device 14, thereby helping the user to send and receive emails, browse the web, access streaming media, send the installation package of the target application to the test terminal 02, etc. It provides the user with wireless broadband Internet access. The test device 01 can also establish a Wi-Fi connection with a terminal device connected to the Wi-Fi access point through the Wi-Fi device and the Wi-Fi access point for mutual data transmission. In some other embodiments, the Wi-Fi device 14 can also serve as a Wi-Fi wireless access point, which can provide Wi-Fi network access for other electronic devices.

[0086] The Bluetooth device 15 is used to implement data exchange between the test device 01 and other short-range electronic devices (such as terminals, smart watches, etc.). The Bluetooth device in the embodiment of the present application can be an integrated circuit or a Bluetooth chip, etc.

[0087] The audio circuit 16, the speaker 16B, and the microphone 16A can provide an audio interface between the user and the test device 01. The audio circuit 16 can transmit the electrical signal converted from the received audio data to the speaker 16B, which is converted into a sound signal for output; on the other hand, the microphone 16A converts the collected sound signal into an electrical signal, which is received by the audio circuit 16 and converted into audio data, and then the audio data is sent to any feasible terminal via the Internet, Wi-Fi network, or Bluetooth, or the audio data is output to the memory 12 for further processing.

[0088] The power system 17 is used to charge various components of the test device 01. The power system 17 may include a battery and a power management module. The battery may be logically connected to the processor 11 through a power management chip, so that the power system 17 can manage charging, discharging, and power consumption.

[0089] The peripheral interface 18 is used to provide various interfaces for external input / output devices (such as keyboard, mouse, external display, external memory, user identification module card, etc.). For example, it is connected to the mouse through a universal serial bus interface to achieve the purpose of receiving the relevant operations implemented by the user through the mouse. For another example, it is connected to an external memory through an external memory interface, such as a Micro SD card, to achieve the storage capacity of the extended test device 01. The peripheral interface 110 can be used to couple the above-mentioned external input / output peripheral devices to the processor 11 and the memory 12.

[0090] The sensor module 19 may include at least one sensor. For example, a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor. Among them, the ambient light sensor can adjust the brightness of the display screen 13 according to the brightness of the ambient light. As a kind of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of personal computers (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc. Of course, according to actual needs, the sensor module can also include any other feasible sensors.

[0091] although Figure 2 Not shown, the test device 01 may also include a camera, such as a front camera, a rear camera, etc. The test device 01 may also include a flash, a micro-projection device, a near field communication (NFC) device, etc., which will not be described in detail here.

[0092] Exemplarily, in the present application, the test terminal can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), and other devices that can install and run the target application. The embodiment of the present application does not impose any restrictions on the specific type of the test terminal 02.

[0093] Take the test terminal 02 as an example, which is a mobile phone. Figure 3 It shows a schematic diagram of the structure of the test terminal 02 provided in this application.

[0094] Reference Figure 3As shown, the test terminal 02 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a display screen 293, a subscriber identification module (SIM) card interface 294, and a camera 295, etc. Among them, the sensor module 280 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.

[0095] The processor 210 may include one or more processing units, for example, the processor 210 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0096] The controller can be the nerve center and command center of the test terminal 02. The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0097] The processor 210 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. The memory may store instructions or data that the processor 210 has just used or cyclically used. If the processor 210 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

[0098] In some embodiments, the processor 210 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0099] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor and baseband processor.

[0100] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0101] The mobile communication module 250 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to electronic devices. The mobile communication module 250 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 250 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 250 can be set in the processor 210. In some embodiments, at least some of the functional modules of the mobile communication module 250 can be set in the same device as at least some of the modules of the processor 210.

[0102] The wireless communication module 260 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to electronic devices. The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 210. The wireless communication module 260 can also receive the signal to be sent from the processor 210, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0103] In some embodiments, the antenna 1 of the electronic device is coupled to the mobile communication module 250, and the antenna 2 is coupled to the wireless communication module 260, so that the electronic device can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology.

[0104] The electronic device implements the display function through a GPU, a display screen 293, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 293 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 210 may include one or more GPUs that execute program instructions to generate or change display information.

[0105] The display screen 293 is used to display images, videos, etc. The display screen 293 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 293, where N is a positive integer greater than 1.

[0106] The electronic device can realize the shooting function through the ISP, the camera 295, the video codec, the GPU, the display screen 293 and the application processor, etc. In some embodiments, the electronic device can include 1 or N cameras 295, where N is a positive integer greater than 1.

[0107] The external memory interface 220 can be used to connect to an external non-volatile memory to expand the storage capacity of the test terminal 02. The external non-volatile memory communicates with the processor 210 through the external memory interface 220 to implement a data storage function. For example, files such as music and videos are stored in the external non-volatile memory.

[0108] The internal memory 221 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory can be directly read and written by the processor 210, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data, etc. The non-volatile memory can also store executable programs and store user and application data (such as runtime information), etc., which can be loaded into the random access memory in advance for direct reading and writing by the processor 210. In an embodiment of the present application, the internal memory 221 can store runtime information generated by the test terminal 02 when running the target application.

[0109] A touch sensor is also called a "touch control device". The touch sensor can be arranged on the display screen 293. The touch sensor and the display screen 293 form a touch screen, also called a "touch control screen". The touch sensor is used to detect a touch operation acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 293. In other embodiments, the touch sensor can also be arranged on the surface of the test terminal 02, which is different from the position of the display screen 293.

[0110] The pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor can be set on the display screen 293. There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor, the capacitance between the electrodes changes. The test terminal 02 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 293, the test terminal 02 detects the touch operation intensity according to the pressure sensor. The test terminal 02 can also calculate the touch position according to the detection signal of the pressure sensor. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0111] Of course, it is understandable that the above Figure 3 The figure is only an exemplary description when the test terminal 02 is in the form of a mobile phone. If the test terminal 02 is in the form of a tablet computer, a handheld computer, a PC, a PDA, a wearable device (such as a smart watch, a smart bracelet), etc., the structure of the test terminal 02 may include Figure 3 The structure shown in the figure is less than Figure 3 More structures are shown in the figure, which are not limited here.

[0112] Based on the structure of the above-mentioned test system and corresponding equipment, the concurrent defect detection method provided in the embodiment of the present application is introduced below, taking the test terminal as a mobile phone as an example.

[0113] Reference Figure 4 As shown in FIG. 1 , a flow chart of a concurrent defect detection method provided in an embodiment of the present application is shown. The method can be applied to Figure 1 In the test system shown in FIG. , take the test terminal as a mobile phone as an example. Figure 4As shown, the method may include S401-S412:

[0114] S401: The test device obtains an installation package of a target application and a local source code file corresponding to the target application.

[0115] The target application is a multi-threaded application written in a mixture of the target programming language and the local programming language, and the local source code file is a source code file directly written in the target application using the local programming language.

[0116] for In terms of systems, in practice, Java code and Native code (generally C language code or C++ language code) each have their own advantages. For example, Native code is usually more suitable than Java code for some scenarios that require high performance, such as graphics rendering, audio and video processing, etc. Compared with Native code, Java code requires less development time and is more concise to write. In addition, Java code itself provides many public libraries and frameworks, making it more convenient to use. Java code is a virtual machine-based language that can automatically manage memory and run across platforms, so it can ensure that applications can run normally on different operating systems. Java code can run easily on different operating systems. Using Java code for cross-platform development can reduce workload and allow developers to release software updates faster. Native code can directly access underlying operating system resources to achieve finer-grained control and optimize program behavior. Java code can encapsulate Native code so that it can be more conveniently called by the upper layer. Based on this, when developing multi-threaded applications, most users will use Java code and Native code, two different programming languages, to achieve better results.

[0117] In a possible implementation, in the embodiment of the present application, the target application can be any multi-threaded application written in Java code and native code. The Java language corresponding to the Java code is the target programming language, and the C language or C++ language corresponding to the native code is the local programming language. This is used as an example in the subsequent embodiments and will not be described in detail.

[0118] For example, the target application may be (which can complete real-time communication while rendering and adjusting the user interface), real-time battle game applications (which can perform various calculations and simulations (such as physics engine control, collision detection, etc.) while updating the images on the screen), multimedia playback applications (which can download audio while playing audio), etc.

[0119] In the embodiment of the present application, the installation package can be a user (the user in the embodiment of the present application is a developer) who uses Java code and Native code to program the target application to obtain source code composed of a high-level programming language, and then uses a specific compiler to compile the source code to obtain an installable file that can be installed on an electronic device, namely, an APK file. The APK file mainly includes the following main parts:

[0120] AndroidManifest.xml: Configuration information file, which contains the application's version information, permission requirements, component information, application name, etc.

[0121] Classes.dex: This is the main binary code file of the application, which contains The bytecode of the SDKJava class will be converted into Dalvik bytecode at runtime. In some possible implementations, the APK file of an Android application can contain multiple secondary dex files in addition to the main classesdex file. These secondary dex files can store additional Java code and third-party libraries in the application.

[0122] Resource files: These files include images, audio, layouts, strings, and other resource files that your application needs for use at runtime.

[0123] lib directory: If the application uses native libraries, these dynamic link libraries will be stored in this directory. Native libraries refer to shared libraries written in C / C++ in Android applications, which usually interact with Java code as part of JNI. Native libraries are libraries compiled into native machine code, so they can provide more efficient and faster performance, and are suitable for processing some tasks and operations that require high-speed computing. In practice, native libraries are usually stored in the form of .so (shared object) files in the application's lib directory ( / lib).

[0124] assets directory: Contains any files that can be accessed by the application but do not belong to the "resource" category by data type, such as HTML files.

[0125] META-INF directory: Contains package certificates and other special files, such as the MANIFEST.MF file, which contains summary information of the APK file and can be verified to confirm the integrity and source of the APK file.

[0126] In the embodiment of the present application, the installation package of the target application can be obtained after the user develops and compiles on the test device, or it can be obtained from other devices. For example, for the dex file corresponding to the Java code in the apk file, the Java code can be compiled into Java bytecode (.class file) using the Java development kit (Java developmentkit, JDK), and then the bytecode is converted into Dalvik bytecode (dex file) through the dx tool in the Android software development kit (software development kit, SDK).

[0127] In the embodiment of the present application, the local source code file corresponding to the target application may be developed by the user on the test device, or may be obtained from other devices.

[0128] For example, refer to Figure 5 As shown, the test device or the instrumentation device in the test device may include a Java configuration module 51 and a native configuration module 52. The Java configuration module 51 and the native configuration module 52 are mainly used to perform some necessary preparatory operations before instrumenting the installation package of the target application.

[0129] In order to implement S401, the Java configuration module 51 may include an input file selection unit 511. The input file selection unit 511 is used to determine the location of the installation package of the target application or receive the user's operation to determine the location of the installation package of the target application. Of course, in practice, there may be multiple application installation packages in the test device, and the input file selection unit 511 can display multiple application options to the user through the display screen of the test device, so that the user can select the target application that needs to be instrumented, and then determine the location of the installation package of the target application to obtain the installation package of the target application.

[0130] The native configuration module 52 may include an input file unit 521. The input file unit 521 is used to determine the specific location of the local source code file corresponding to the target application or to receive the user's operation to determine the location of the local source code file. Of course, in practice, there may be local source code files of multiple applications in the test device, and the input file selection unit 521 can display the options of multiple applications to the user through the display screen of the test device, so that the user can select the target application that needs to be instrumented, and then determine the location of the local source code file of the target application to obtain the local source code file corresponding to the target application.

[0131] S402: The testing device determines a first code file corresponding to a target programming language in an installation package of a target application.

[0132] In an embodiment of the present application, the test device or the instrumentation device (or system) that performs instrumentation in the test device can, after clarifying the specific location of the installation package of the target application (which can be used to parse the code file corresponding to the target programming language that needs to be instrumented), determine the first code file corresponding to the target programming language by identifying and parsing the installation package of the target application.

[0133] When the test device obtains the installation package of the target application, the test device can automatically determine the storage location or storage path of the installation package of the target application, and identify the location of the first code file corresponding to the target programming language in the installation package of the target application. Of course, the location of the installation package of the target application can also be actively input into the test device by the user. In this way, the test device can subsequently use a specific plug-in framework (or plug-in software) to complete the plug-in of the first code file corresponding to the Java code in the installation package of the target application.

[0134] For example, refer to Figure 5 As shown, in order to implement S401, the input file selection unit 511 in the Java configuration module 51 is further configured to parse the installation package to obtain a dex file (including the first code file) corresponding to the Java code in the installation package of the target application after determining the location of the installation package of the target application.

[0135] In practice, for Android platform applications, their installation packages will contain multiple dex files, and the Java codes in these dex files are compiled and packaged separately. Based on this, there may be the following situations:

[0136] The first case: Different dex files may have different functions for applications, and there may be dependencies between different dex files (for example, a class or a method in dex file A may depend on a class or method in dex file B). Therefore, when users need to detect concurrency defects for certain specific functions, they can select specific dex files and their dependent dex files for instrumentation according to their needs.

[0137] The second case: For some instrumentation tools (such as soot) that can implement instrumentation functions, they may default to processing one dex file in an apk file at the same time. If you do not select multiple dex files in the apk file, the instrumentation tool may only instrument one dex file (such as the classesdex file) in the end. This may cause the dex file that the end user needs to instrument to fail to complete the instrumentation smoothly, and the subsequent detection of concurrency defects in the target application will not be complete. Therefore, when the user needs to detect concurrency defects for certain specific functions, you can select specific multiple dex files according to your needs for the instrumentation tool to instrument.

[0138] The third case: Since there are multiple dex files in the apk file, the Java code in each dex file is compiled and packaged separately. If the dex file is not selected, the same or similar probe code (used to store the runtime information of the object corresponding to the probe code in a specific file when the target application is running) may be inserted into different multiple dex files during the instrumentation. This will not only cause redundant code to be repeatedly referenced and occupy additional memory space, but also may destroy the structure of classes and methods in the original java code, thereby affecting the normal operation and debugging process of the application. Therefore, when users need to detect concurrency defects for certain specific functions, they can select specific multiple dex files for instrumentation according to their needs.

[0139] Based on the above description, in some embodiments, combined with Figure 4 , refer to Figure 6 S402 shown may specifically include S601 and S602:

[0140] S601: The testing device receives a code file selection operation from a user.

[0141] Taking the code file corresponding to the target programming language in the target application as a dex file as an example, in a possible implementation, the selection operation can be a trigger operation of the user on the options of multiple dex files. Exemplarily, after the test device determines the target application and parses the installation package of the target application and determines all the dex files therein, it can display the options corresponding to each dex file. Afterwards, the test device can receive the user's trigger operation (such as a click operation) on some options in the options of all dex files, and in response to the trigger operation, determine the corresponding code file as the subsequent first code file.

[0142] Of course, in practice, the code file selection operation may also be implemented in any other feasible manner, and this application does not impose any specific limitation on this.

[0143] S602: In response to the code file selection operation, the testing device determines that the code file corresponding to the code file selection operation among all code files corresponding to the target programming language in the target application installation package is the first code file.

[0144] After receiving the code file selection operation, the test device may determine the code file corresponding to the code file selection operation as the first code file.

[0145] For example, refer to Figure 5 As shown, the process (eg, S601 and S602 ) of determining the first code file by the testing device may be implemented by the input file selection unit 511 in the Java configuration module 51 .

[0146] Based on the technical solutions corresponding to S601 and S602 above, the user can select all code files corresponding to the target programming language in the installation package of the target application according to his own needs, and the test device can determine the first code file that meets the user's needs based on the user's code file selection operation. In this way, the subsequent implementation of the plug-in can smoothly obtain the runtime information that meets the user's needs, avoid obtaining the runtime information that does not meet the user's needs, and improve the test efficiency of the concurrency defects of the target application.

[0147] S403: The testing device determines a target class in the first code file that needs to be plugged in.

[0148] In the embodiment of the present application, the technical solution provided by the present application is explained by taking the target programming language as Java language (or Java code) and the code file corresponding to the Java code as a dex file as an example.

[0149] After the test device obtains the installation package of the target application that needs to be instrumented, it can successfully parse and obtain the first code file. Afterwards, since the test of concurrency defects in the target application may be biased in practice, the test device can use any feasible method to determine the target class that needs to be instrumented in the first code file according to the needs.

[0150] In a possible implementation, the test device may assume that all classes in the first code file are target classes, that is, all classes in the first code file need to be instrumented.

[0151] In another possible implementation, the test device may receive a class selection operation from the user, and in response to the class selection operation, determine the class corresponding to the class selection operation as a target class that needs to be plugged in the first code file. Exemplarily, the class selection operation may be a class name directly input by the user, or a trigger operation (e.g., a click) by the user on some of the options corresponding to all class names in the first code file displayed by the test device, or an operation in which the user inputs a class name by voice input, etc.

[0152] In another possible implementation, the test device may receive a class filtering operation from the user, and in response to the class filtering operation, determine the class corresponding to the class filtering operation as a filter class that does not need to be plugged in the first code file, and then determine the class other than the filtered class in the first code file as the target class. Exemplarily, the class filtering operation may be a class name directly input by the user, or a trigger operation (e.g., a click) by the user on some of the options corresponding to all class names in the first code file displayed by the test device, or an operation in which the user inputs a class name by voice input, etc.

[0153] For example, refer to Figure 5 As shown, the java configuration module 51 may include a target class screening unit 512. The target class screening unit 512 may be used to implement S402, and the specific implementation of S402 may be the several possible implementations listed above or any other feasible implementation.

[0154] S404: The testing device inserts a target class of the first code file and obtains static information of the target class.

[0155] Taking the target programming language as Java as an example, in the embodiment of the present application, the instrumentation of the target class of the first code file by the test device can be implemented based on the first instrumentation tool (or framework). Exemplarily, the first instrumentation tool can be the soot instrumentation framework.

[0156] For example, refer to Figure 5 As shown, in order to implement step S403, the test device also includes a statement plugging module 53. The statement plugging module 53 is used to implement the plugging of the target class in the first code file. Of course, the plugging of the target class in the first code file by the statement plugging module 53 needs to be implemented on the basis that the java configuration module 51 determines the first code file in the installation package of the target application and determines the target class of the first code file.

[0157] Taking the soot instrumentation framework as an example, the first instrumentation tool for instrumenting the target class of the first code file is mainly implemented by analyzing and rewriting the intermediate representation of the java code, jimple. Therefore, after S403, before instrumenting the target class of the first code file, the first code file needs to be converted into a second code file. The first code file is a dex file, and the second code file is composed of the intermediate representation of jimple.

[0158] In a possible implementation, converting the dex file into a second code file composed of jimple may include the following two steps:

[0159] (1) Use the dx tool in the Android SDK to convert the dex file into a Java archive (JAR) package. Specifically, the dx tool can convert the dex file into a Java class file (.class file), and then package it into a JAR package.

[0160] (2) Use the soot instrumentation framework to convert the jar package into a second code file. Exemplarily, the soot instrumentation framework can load the class in the JAR package through the Scene.v().loadClassAndSupport() method, and then use the parser to parse the class and convert it into Jimple representation, thereby obtaining the second code file.

[0161] For example, refer to Figure 5 As shown, in order to achieve the purpose of converting the dex file into a second code file composed of jimples, the java configuration module 51 may also include an intermediate code conversion unit 514. The intermediate code conversion unit 514 can realize the function of converting the dex file into a second code file composed of jimples. Of course, after the test device completes the instrumentation based on the soot instrumentation framework, the intermediate code conversion unit 514 will also convert the instrumented second code file into a dex file.

[0162] Of course, in practice, converting the first code file into the second code file may also be implemented in any other feasible manner, and this application does not impose any specific limitation on this.

[0163] In addition, when using the soot instrumentation framework to instrument dex files, it is necessary to insert probe code into the dex file or modify the original code, which requires the soot instrumentation framework to correctly parse the dex file and insert probe code that meets the requirements of the target application.

[0164] In practice, the Android platform is a rapidly developing ecosystem, and each new version of the Android system will introduce new APIs and changes. Therefore, when inserting the dex file in the installation package of the Android platform application, it is necessary to consider the interface version compatibility between the application and the Android system. If the wrong or incompatible version library is used, the inserted probe code may be unavailable, crash, or produce other abnormal behaviors. Secondly, Android platform applications usually rely on many third-party libraries and frameworks, which also have version compatibility issues. If the library that the probe code inserted into the dex file depends on is inconsistent with the current Android version library, it may cause compilation failure or runtime errors. Thirdly, the API of each version of the Android system may change in its implementation details (for example, some methods are renamed, moved to different classes, or the value of a flag is modified), and these details may affect the actual effect and accuracy of the probe code. When parsing the dex file, the structure of the dex file, the interpretation of the specific content, and the dependency information are based on the DEX library in the Android system framework. Therefore, to correctly parse the dex file and correctly insert the probe code, it is necessary to consider the DEX library in the Android system framework. Exemplarily, the DEX library in the Android system framework may be a JAR package containing a dex file in the Android system framework, such as framework.jar.

[0165] Based on this, in some embodiments, in order for the soot instrumentation framework to correctly parse the first code file (i.e., dex file) and correctly instrument the first code file, before S404, the test device also needs to obtain the Android version library that the first code file depends on, and the DEX library in the Android system framework. The specific acquisition method can be any feasible method, and this application does not impose specific restrictions on this. Obtaining the Android version library that the first code file depends on, and the DEX library in the Android system framework can be any feasible time before S404, such as after the test device obtains the installation package of the target application.

[0166] For example, in order to obtain the Android version library that the first code file depends on and the DEX library in the Android system framework, refer to Figure 5 As shown, the java configuration module 51 of the test device may also include a dependency version library configuration unit 513. The dependency version library configuration unit 513 is used to obtain the Android version library that the first code file depends on, and the input file selection unit 511 in the java configuration module 51 can be used to obtain the DEX library in the Android system framework. The DEX library in the Android system framework can be input to the test device by the user through the function of the input file selection unit 511.

[0167] When the test device obtains the Android version library and the DEX library of the Android system framework that the first code file depends on, combined with Figure 4 , refer to Figure 7 As shown, S404 may specifically be S404A:

[0168] S404A: The test device inserts a target class of the first code file based on the Android version library that the first code file depends on and the DEX library of the Android system framework, and obtains static information of the target class.

[0169] Exemplary, based on S404A, refer to Figure 5 As shown, when the statement instrumentation module 53 in the test device instruments the target class in the first code file, it needs to be completed based on the cooperation of the Java configuration module 51.

[0170] In this way, the test device can successfully and correctly complete the instrumentation of the target class of the first code file.

[0171] In the embodiment of the present application, the purpose of inserting the target application's installation package to obtain runtime information is to detect concurrency defects corresponding to the Java code. In practice, the concurrency defects of the Java code mainly involve several target operations including: operations on shared variables (read operations and write operations), operations on synchronization locks (acquisition operations and release operations), synchronization operations on threads, conditional branch operations, etc. Therefore, when the test device inserts the target class in the first code file, it mainly needs to identify the target statements in the target class that correspond to the above-mentioned target operations. The static information of the target class can specifically include the static information of the target statements in the target class. Based on this, combined with Figure 4 , refer to Figure 8 As shown, S403 may specifically be S403B:

[0172] S404B: The testing device identifies and inserts a target statement in the target class of the first code file, and obtains static information of the target statement in the target class.

[0173] Among them, the target statement is specifically a statement related to the concurrency defect, that is, the target statement is a statement related to the target operation involved in the concurrency defect. The test device identifies and inserts the target statement in the target class of the first code file specifically as follows: the test device identifies the target statement in the target class of the first code file, and inserts the probe code before or after the target statement based on the first instrumentation tool (such as the soot instrumentation framework). The probe code here is the first probe code mentioned in this application.

[0174] Among them, the probe code is used to obtain the runtime information corresponding to the target statement, and the runtime information may include the operation type, variable identifier (used to indicate the name of the variable (i.e., the operation object), the type of the variable, the class of the variable, and the instance hash value of the variable, which can be obtained by mapping the name of the variable, the type of the variable, the class of the variable, and the instance hash value of the variable), thread identifier (specifically physical thread identifier), instruction identifier (used to indicate the offset of the insertion position of the probe code in the method to which it belongs, the method name of the method to which it belongs, and the class to which it belongs) and sequence identifier. The variable identifier can be obtained by mapping the name of the variable, the type of the variable, the class of the variable, and the instance hash value of the variable according to specific rules. Of course, if the instance hash value of the variable does not exist, the variable identifier can be completed in any feasible way; when the instance hash value of the variable is subsequently obtained, the variable identifier can be readjusted. The instruction identifier can be obtained by mapping the offset of the insertion position of the probe code in the method to which the target statement belongs, the method name of the method to which the target statement belongs, and the class to which the target statement belongs according to another specific rule.

[0175] Among them, the variable identifier (content other than the instance hash value of the variable) and the instruction identifier are static information of the target statement, which are obtained when the probe code is inserted into the target statement. Each insertion position or insertion point (that is, the position of the insertion code in the corresponding method) corresponds to an instruction identifier.

[0176] The operation type, instance hash value of the variable, thread ID and sequence ID are dynamic information that can be obtained when the target application installation package is actually running on the mobile phone after installation. For example, in order to obtain the instance hash value of the variable, the probe code can include the code of the identifyHashcode() method, and the identifyHashcode() method can obtain the instance hash value of the variable of the operation object of the target statement operation corresponding to the probe code when the target application is installed and running.

[0177] It should be noted that the operation type can be obtained during the instrumentation or after the target application is running. This application only uses the operation type as the dynamic information obtained when the target application is running as an example for explanation. In practice, the operation type can also be used as static information, and this application does not make specific restrictions on this.

[0178] The process of identifying the target statement of the test device may be as follows: the test device scans and identifies all statements in each method in the target class, and determines a statement related to any target operation as a target statement.

[0179] For example, in order to realize the recognition of the target sentence, refer to Figure 5As shown, the statement instrumentation module 53 in the test device may include a statement recognition unit 531. The statement recognition unit 531 can be used to identify target operations such as shared variable read and write operations, synchronous lock acquisition / release operations, thread synchronization operations, and conditional branch operations for each method of the target class in the first code file, thereby completing the identification and determination of the target statement. In this way, the statement instrumentation module 53 can determine which statements are target statements, thereby completing the instrumentation of the target statement.

[0180] In one possible implementation, for the target operation of the read / write operation of the shared variable in the target class, the target statement can be an Assign statement inside the method. The Assign statement is a type of statement commonly used in computer programming, which is used to assign a value or expression to a variable. It usually contains a left value and a right value, and uses the equal sign "=" to connect them together. For example, a=b means assigning b to a. The test equipment inserts the probe code before or after the Assign statement to the target statement in the target class.

[0181] For the target statement corresponding to the read / write operation of the shared variable, the operation type is a read / write operation, the variable is the operation object targeted by the read / write operation, that is, the shared variable, and the variable identifier is the identifier of the shared variable; the thread identifier is used to indicate the ID of the thread where the read / write operation of the shared variable is located; the instruction identifier is used to indicate the signature of the method where the read / write operation of the shared variable is located, the class name described in the method, and the offset of the probe code within the method; the sequence identifier is used to identify the execution order of the read / write operation of the shared variable in all operations when the target application is running.

[0182] In one possible implementation, for the target operation of acquiring / releasing the synchronization lock in the target class, the target statement is the EnterMonitor statement and the ExitMonitor statement in the method in the target class. The test device inserts the probe code before or after the EnterMonitor statement and the ExitMonitor statement in the target class.

[0183] For the target statement corresponding to the acquisition / release operation of the synchronization lock, the operation type is a lock operation, the variable is the operation object targeted by the acquisition / release operation, namely the synchronization lock, and the variable identifier is the identifier of the synchronization lock (such as the name, type, class, and instance hash value of the variable); the thread identifier is used to represent the ID of the thread where the acquisition / release operation of the synchronization lock is located; the instruction identifier is used to represent the signature of the method where the acquisition / release operation of the synchronization lock is located, the class name described in the method, and the offset of the probe code within the method; the sequence identifier is used to identify the execution order of the acquisition / release operation of the synchronization lock in all operations when the target application is running.

[0184] In one possible implementation, for the target operation of thread synchronization operation in the target class, the target statement is the call statement of the start method (corresponding to the thread creation event) and the join method (corresponding to the thread merging event) inside the method in the target class. The test equipment inserts the probe code before or after the start method and the join method call statement in the target class.

[0185] For the target statement corresponding to the thread synchronization operation, the operation type is the thread synchronization operation, the variable is the operation object targeted by the thread synchronization operation, namely the child thread, and the variable identifier is the identifier of the child thread (for example, the child thread ID); the thread identifier is used to represent the ID of the thread where the thread synchronization operation is located; the instruction identifier is used to represent the signature of the method where the thread synchronization operation is located, the class name described in the method, and the offset of the probe code within the method; the sequence identifier is used to identify the execution order of the thread synchronization operation in all operations when the target application is running.

[0186] In a possible implementation, for a target operation of a conditional branch operation in a target class, the target statement is an If statement inside a method. The test device inserts a probe code before or after the If statement into the target statement in the target class.

[0187] For the target statement corresponding to the conditional branch operation, the operation type is a branch operation; since the conditional branch operation does not operate on any object, there is no variable; the thread identifier is used to represent the ID of the thread where the conditional branch operation is located; the instruction identifier is used to represent the signature of the method where the conditional branch operation is located, the class name described in the method, and the offset of the probe code within the method; the sequence identifier is used to identify the execution order of the conditional branch operation among all operations when the target application is running.

[0188] It should be noted that by inserting the probe code before the target statement, it can be determined that when the runtime information of the target statement is obtained, the operation corresponding to the target statement has not yet been executed, that is, the runtime information obtained at this time is generated before the target statement is executed. In this case, it can be determined that when the runtime information of the target statement is obtained, the operation object (i.e., variable) corresponding to the target statement has no other target operations (or target events), and the target operation is the operation corresponding to the target statement. In addition, inserting the probe code before the target statement can also facilitate the probe code to make appropriate modifications to the target statement before the target statement is executed, increasing the user's testing possibilities.

[0189] By inserting the probe code after the target statement, it can be determined that when the runtime information of the target statement is obtained, the operation corresponding to the target statement has been executed, that is, the runtime information obtained at this time is generated after the target statement is executed. In this case, it can be ensured that the runtime information after the target statement is executed is obtained, and it can be determined whether the execution of the target statement will cause concurrency defects.

[0190] Taking the acquisition / release operation of the synchronization lock as an example, the target statement can be the EnterMonitor statement and the ExitMonitor statement in the method in the target class. An instrumentation probe can be inserted after the EnterMonitor statement to determine that the synchronization lock has been acquired when the runtime information is acquired, and another instrumentation probe can be inserted before the ExitMonitor statement to determine that there will be no other locking operations on the synchronization lock (i.e., the acquisition operation of the synchronization lock) when the runtime information is acquired.

[0191] In the implementation of this application, whether the probe code is inserted before or after the target statement depends on the needs, and this application does not make any specific restrictions on this.

[0192] Based on S402-S405, the test device can complete the insertion of the first code file in the installation package of the target application and obtain the static information of the first code file (specifically, it may include the static information of the target statement in the target class in the first code file).

[0193] S405: The test device identifies and inserts a target call statement in the local source code file, and obtains static information of the target call statement.

[0194] Among them, the target call statement is a call statement for the target interface in the local source code file. The target interface is used for the code file corresponding to the local programming language in the target application to complete the interaction with the code file corresponding to the target programming language. For example, the target interface can be used for native code to complete the operation of Java objects. In the embodiment of the present application, the technical solution is described with the local programming language as C language and the target interface as JNI (including methods or interfaces such as GetStaticObjectField() and SetStaticObjectField()), which will not be repeated later.

[0195] In the embodiment of the present application, the purpose of inserting the local source code file corresponding to the target application to obtain runtime information is to detect the situation where the local source code file causes concurrency defects corresponding to the Java code. In practice, the concurrency defects of the Java code involve operations in the local source code file, specifically the calling operations of JNI in the local source code file. Therefore, when the test device inserts the local code file, it specifically inserts the target calling statement.

[0196] For example, in order to identify the target call statement, refer to Figure 5 As shown, the statement plugging module 53 in the test device may include an interface identification unit 532. The interface identification unit 532 can be used to identify all JNIs that operate Java objects in the local code file, and then complete the identification and determination of the target call statement. In this way, the statement plugging module 53 can subsequently determine which statements are target call statements, and then complete the plugging of the target call statement.

[0197] In an embodiment of the present application, the test device's instrumentation of the target call statement can be specifically implemented based on a second instrumentation tool (or framework), that is, the test device identifies and instruments the target call statement in the local source code file based on the second instrumentation tool.

[0198] In the embodiment of the present application, the second instrumentation tool can be the LLVM instrumentation framework. Furthermore, although the LLVM instrumentation framework itself has the instrumentation capability, this capability is implemented by its extended module LLVM pass plug-in, which does not exist in the LLVM instrumentation framework in advance. Therefore, in the embodiment of the present application, before instrumenting the target call statement, it is also necessary to generate and compile the LLVM pass plug-in based on the source code of the LLVM instrumentation framework. Based on this, refer to Figure 5 As shown, the native configuration module 52 also includes an LLVM configuration module 521. The LLVM configuration module 521 can build an LLVM pass plug-in based on the source code of the LLVM instrumentation framework, and the version of the LLVM pass plug-in is the same as the LLVM instrumentation framework. Specifically, the LLVM configuration module 521 can display the CMakeLists.txt of the pass project when building the instrumented LLVM pass plug-in, so that the user can specify the LLVM source code path used to build the LLVM pass plug-in in CMakeLists.txt, so as to compile and generate the LLVM pass plug-in. In an embodiment of the present application, the specific format of the LLVM pass plug-in can be so format.

[0199] In addition, in order to make the LLVM pass plug-in more accurately identify the target interface - JNI, the test equipment can also configure the identification of the JNI to be identified in it when generating the LLVM pass plug-in. In this way, the test equipment can use the LLVM pass plug-in to accurately identify the target call statements related to JNI under the LLVM instrumentation framework, and then complete the instrumentation of the local source code file.

[0200] For example, to configure the JNI identifiers that need to be recognized in the LLVM pass plugin, refer to Figure 5 As shown, the native configuration module 52 in the test device may also include a JNI standard interface configuration unit 523, and the JNI standard interface configuration unit 523 may cooperate with the LLVM configuration unit 522 to generate an LLVM pass plug-in configured with the identifier of the JNI to be identified.

[0201] Taking the local programming language as C language and the second instrumentation tool as LLVM instrumentation framework as an example, the LLVM instrumentation framework mainly implements the instrumentation of C language code by analyzing and rewriting the intermediate identifier of C language LLVMIR supported by LLVM. Figure 4 , refer to Fig. 9 As shown, S405 may specifically include S901 and S902:

[0202] S901. The testing device compiles a local source code file using a local source code compiler to obtain a local code file.

[0203] Exemplarily, the native source code compiler may be clong.

[0204] When using clong to compile local source code files, since the subsequent instrumentation is completed based on the LLVM instrumentation framework using the LLVMpass plug-in, it is necessary to make the compilation optimization level of the LLVM IR in the local code file compiled by clong meet the requirements of the LLVM instrumentation framework and the LLVM pass plug-in (the compilation optimization level of LLVM IR is required to be O1 or O2). Based on this, when using clong to compile local source code files, the LLVM pass plug-in can be passed to clang as a plug-in parameter to set clang's compilation optimization level to O1 or O2. In this way, the local code file finally generated by clang is a file that can be processed by the LLVM pass plug-in.

[0205] For example, refer to Figure 5 As shown, the compilation of the native source code file can be implemented by the LLVM configuration unit 522 in the native configuration module.

[0206] It should be noted that after the local source code file is inserted, the runtime information is ultimately required to be obtained, and the original Android system does not allow this operation. Moreover, after the local source code file is inserted, the target application may need to access some sensitive paths and files of the Android system, which is also not allowed by the Android system. Based on this, at the right time, such as when the local source code file is compiled, the Android open source project (AOSP) on the mobile phone, that is, the package_allowed_list.txt and MediaProvider.java in the Android system can be modified. Among them, package_allowed_list.txt defines the classes included in the system library framework.jar after building the AOSP back. The user's modification of package_allowed_list.txt can make the target application that is finally inserted installed on the mobile phone. The classes related to the runtime information output can be compiled, that is, by modifying package_allowed_list.txt, the runtime information of the target application running on the mobile phone can be obtained. MediaProvider.java is mainly responsible for managing multimedia data and is used to provide an operating interface for multimedia files. Therefore, by modifying MediaProvider.java, the user can make the instrumented application, when running on the mobile phone, access any file that the user needs the target application to access, thereby obtaining more comprehensive runtime information.

[0207] The user can modify package_allowed_list.txt and MediaProvider.java in any feasible way, such as sending relevant modification instructions to the mobile phone through the test device, or modifying it directly on the mobile phone. The specific modification content depends on the plug-in requirements, and this application does not make specific restrictions on this.

[0208] S902: The testing device identifies and inserts a target call statement in the local code file based on the second insertion tool, and obtains static information of the target call statement.

[0209] In the embodiment of the present application, the test device recognizes and inserts the target call statement based on the second plugging tool, and specifically can insert the probe code before or after the target call statement after the second plugging tool recognizes the target call statement. The probe code here is equivalent to the second probe code mentioned in the present application.

[0210] Among them, the probe code is used to obtain the runtime information corresponding to the target call statement, which runtime information may include operation type, variable identifier (used to indicate the name of the variable (i.e., operation object), the type of the variable, the class of the variable, and the instance hash value of the variable), thread identifier, instruction identifier, and sequence identifier.

[0211] Among them, the variable identifier (the content other than the instance hash value of the variable) and the instruction identifier are static information of the target call statement, which are obtained when the probe code is inserted into the target call statement. Each insertion position or insertion point (that is, the position of the insertion code in the corresponding method) corresponds to an instruction identifier. The operation type, the instance hash value of the variable, the thread identifier and the sequence identifier are dynamic information obtained when the target application is installed on the mobile phone and actually runs.

[0212] Based on the technical solutions corresponding to S901 and S902, the test device can complete the instrumentation of the target call statement, so that the runtime information can be obtained after the target application is installed after the instrumentation. At the same time, the static information of the target call statement obtained at this time is part of the runtime information required later, so that the test device can obtain complete runtime information.

[0213] In the embodiment of the present application, in order to realize the management and maintenance of static information, refer to Figure 5 As shown, the test device may also include a static information management module 54. The static information management module 54 may store the mapping relationship of the variable identifiers and the mapping relationship of the instruction identifiers of all target statements, as well as the mapping relationship of the variable identifiers and the mapping relationship of the instruction identifiers of the target call statements, and adjust the information stored therein whenever adjustment is required. The mapping relationship of the variable identifier is used to characterize the association relationship between the variable identifier and the content indicated by it (the name of the variable, the type of the variable, the class of the variable, the instance hash value of the variable), and the mapping relationship of the instruction identifier is used to characterize the association relationship between the instruction identifier and the content indicated by it (the offset of the insertion position of the probe code in the method to which it belongs, the method description of the method to which it belongs, and the class to which it belongs).

[0214] In the embodiment of the present application, the purpose of the instrumentation is mainly to detect the concurrency defects of the corresponding Java code that may be caused by the running of the Java code and the native code in the multi-threaded target application. The concurrency defects in the native code that cause the corresponding Java code are mainly due to the operations on the Java objects in the native code. Based on this, the runtime information corresponding to the Java code and the runtime information corresponding to the native code finally obtained by the concurrency defect detection method provided by the present application, for the runtime information of the same Java object, the unique ID (i.e., variable identifier) ​​recorded that can indicate the Java object is the same. In this way, when the concurrency defects are finally detected using the acquired runtime information, the Java object corresponding to the concurrency defects can also be accurately determined and located.

[0215] Therefore, after the target statement in the first code file corresponding to the Java code (i.e., the target programming language) in the target application is inserted to obtain the static information of the target statement (i.e., after S404 is executed), when the target call statement is inserted to obtain its static information (i.e., S405), it is necessary to query the static information of the target statement and set the variables of the target statement with the same information for the Java object to the same content. The same information of the Java object means that the name of the variable represented by the variable identifier, the type of the variable, and the class of the variable are all the same.

[0216] Based on this, combined Figure 4 , refer to Fig.10 As shown, S405 may specifically include S1001-S1004:

[0217] S1001. The test device identifies and inserts target call statements in a local source code file.

[0218] S1002: The testing device obtains an instruction identifier of a target calling statement.

[0219] The specific implementation of S1001 and S1002 may refer to the related descriptions of S405 and S902 in the aforementioned embodiments, which will not be repeated here.

[0220] S1003. The testing device uses the variable identifier of the target statement that has the same static feature information as the variable corresponding to the target calling statement as the variable identifier of the target calling statement.

[0221] The variable is the operation object targeted by the target call statement, and the static characteristic information of the variable may include: the name of the variable, the type of the variable, and the class to which the variable belongs.

[0222] Exemplarily, when implementing S1003 , the test device needs to follow the mapping relationship of the instruction identifier of the target statement recorded in the static information management module 54 .

[0223] S1004: The testing device uses the instruction identifier and the variable identifier of the target calling statement as static information of the target calling statement.

[0224] Based on the technical solutions corresponding to S1001-S1004 above, the test equipment can successfully complete the instrumentation of the target call statement. In addition, by obtaining the static information of the target call statement based on the static information of the target statement, the variable identifiers for the same object (such as a Java object) in all the runtime information finally obtained can be the same, and all runtime information related to the same object can be easily found, and objects related to concurrency defects can be more accurately located.

[0225] In an embodiment of the present application, in order to enable the runtime information acquired by the probe code to be smoothly written to a specific storage location, the probe code inserted for the target statement and the target call statement may also include a plug-in write interface method, which can write the runtime information (including static information and dynamic information) acquired by the probe code into a specific file by passing parameters. The plug-in write interface method used by each probe code is the same, but different functions of the plug-in write interface method will be called depending on the statement.

[0226] In an embodiment of the present application, in order to avoid interference between different processes, the plug-in write interface method can write the runtime information obtained by the probe code in the " / sdcard / trace / process timestamp / thread program number identifier" file of the mobile phone, where the process timestamp is to distinguish the situation where the target application may trigger multiple processes to avoid interference between different processes, and the thread program number identifier is used to distinguish the execution sequence of different threads. This file also corresponds to the probe code. The implementation of the plug-in write interface method to write the runtime information can be implemented by the thread where the corresponding target statement or target call statement is located. In this way, the way of plug-in write interface is that the threads corresponding to each statement write the runtime information into different files respectively, and there is no interference before the write operation, thus avoiding thread synchronization operation.

[0227] For example, in order to implement the probe code including the plug-in writing interface method, refer to Figure 5 As shown, the statement instrumentation module 53 in the test device also includes a statement writing unit 533. The statement writing unit 533 is used to add an instrumentation writing interface method to the probe code and configure the writing position.

[0228] S406: The testing device generates a target installation package of the target application based on the instrumented first code file and the instrumented local source code file.

[0229] The local source code file after the instrumentation is specifically composed of machine codes compiled by the local programming language, such as a .so file.

[0230] In one achievable manner, when obtaining the first code file in the embodiment of the present application, the original target application installation package has been unpacked, and multiple files including the first code file have been obtained. Based on this, when a new target installation package needs to be generated, the file after the local code file is plugged using the second plugging tool, which may be a compiled file of native code such as a .so file, can be copied to the libs directory of the target application installation package, and the files that are not plugged in to implement the same function can be deleted.

[0231] Secondly, since the permissions of the original application cannot achieve the purpose of instrumentation, such as writing runtime information. Therefore, it is necessary to modify the unpacked AndroidManifest.xml file to change the permissions of the target application so that the target application after instrumentation can achieve the purpose of instrumentation, that is, writing runtime information. In addition, since instrumentation will change the code of the target application, this will also cause changes to the classes in the target application, and the signature (digital certificate) of the installation package of the target application is related to the classes in the target application, so it is also necessary to modify the signature of the original installation package of the target application to obtain a new installation package signature.

[0232] Exemplarily, the modification of the AndroidManifest.xml file can be completed with the help of AXMLEditor.jar, and the modification of the signature of the installation package of the benchmark application can be completed through zipalign and apksigner.jar in the SDK.

[0233] Finally, the modified AndroidManifest.xml file, the first code file after the instrumentation, the new libs directory, the new installation package signature, and other files obtained after unpacking except the AndroidManifest.xml file, the first code file, and the libs directory can be repackaged into an apk installation package to obtain the target installation package. In practice, the process of generating the target installation package by the test device can be efficiently and automatically executed through a pre-set script.

[0234] For example, in order to realize the generation of the target installation package, refer to Figure 5As shown, the test device may also include an installation module 55. The installation module 55 includes a permission change unit 551 and a re-signing unit 552. The permission change unit 551 can complete the modification of the AndroidManifest.xml file, and the re-signing unit 552 can generate a new installation package signature. The installation module 55 can also generate a target installation package based on the modified AndroidManifest.xml file and the new installation package signature obtained by the permission change unit 551 and the re-signing unit 552, as well as other necessary files (i.e., the first code file after the plugging, the new libs directory and other files after unpacking).

[0235] S407: The test device sends the target installation package to the mobile phone for installation.

[0236] Exemplarily, the test device may use an adb tool to install the target installation package on the mobile phone.

[0237] For example, to implement S407, refer to Figure 5 As shown, the installation module 55 in the test device may also include a device installation unit 553. The device installation unit 553 can achieve the purpose of installing the target installation package to the mobile phone.

[0238] S408: The mobile phone runs the target installation package to install the target application.

[0239] S409, the mobile phone simulates and generates user events and injects them into the target application program to obtain dynamic information of the target class and the target call statement.

[0240] The dynamic information of the target class may specifically be the dynamic information of the target sentence in the target class.

[0241] In one achievable manner, the mobile phone simulation generating user events may be completed by the user operating the mobile phone. Specifically, the mobile phone simulation user events may be completed by the user operating the mobile phone with the help of the Monkey tool.

[0242] In another achievable manner, the target installation package contains a first script that instructs the mobile phone to simulate generating user events. After the target installation package is run, the first script can instruct the mobile phone to simulate generating user events. Specifically, the mobile phone simulates user events by using the Monkey tool after the mobile phone runs the first script.

[0243] In addition, in order for the mobile phone to allow the target application to write runtime information to a specific file after running, the mobile phone needs to enable the file access permission of the target application. This can also be done based on user operation, or the second script pre-existing in the target installation package controls the mobile phone after the target installation package runs, and this application does not make specific restrictions on this.

[0244] It should be noted that if a script needs to be used to control the mobile phone to automatically complete S409, the test device needs to add the corresponding scripts (first script and second script) to the target installation package when generating the target installation package. The specific adding method is not specifically limited in this application.

[0245] S410. The mobile phone sends dynamic information of the target class and the target calling statement to the test device.

[0246] For example, the mobile phone can send the dynamic information of the target class and the target call statement to the test device through the adb pull command. As described after S409, the implementation of S410 can also be completed by the user through the operation of the mobile phone, or by the third script pre-existing in the target installation package controlling the mobile phone after the target installation package is run.

[0247] Of course, in practice, the mobile phone may also send to the test device the complete runtime information (including static information and dynamic information) of the target class and target call statement. The specific content sent may be determined according to actual needs, and this application does not make specific restrictions on this.

[0248] S411. The test device receives dynamic information of a target class and a target call statement from the mobile phone to obtain runtime information consisting of dynamic information and static information of the target class and runtime information consisting of dynamic information and static information of the target call statement.

[0249] In an embodiment of the present application, in order to facilitate the detection of subsequent concurrent defects, the runtime information written by the instrumentation writing method to a specific file or the runtime information obtained by S411 can be represented by 20 bytes. Among them, 1-2 bytes represent the event type (ie, the operation type); 3-4 bytes represent the thread identifier; 5-8 bytes represent the thread-local operation sequence identifier; 9-12 bytes represent the operation object identifier (ie, the variable identifier); 13-16 bytes represent the sequence identifier; 17-20 bytes represent the instruction identifier. In this case, the runtime information can also be called an operation sequence.

[0250] It should be noted that the thread-local operation sequence identifier is an integer local variable (thread local variable) maintained by the thread. The local variable is used to identify the event sequence within the thread (that is, the execution order of the corresponding operation in all operations of the thread), and the operation sequence identifier is obtained from the local variable of the thread. Of course, in the embodiment of the present application (not explained in the aforementioned embodiment), the plug-in probe inserted by the test equipment into the target class is also used to obtain the thread-local operation sequence identifier corresponding to the target class (specifically the target statement in the target class); the plug-in probe inserted by the test equipment into the target call statement is also used to obtain the thread-local operation sequence identifier corresponding to the target call statement. The thread-local operation sequence identifier is also part of the runtime information.

[0251] S412: The testing device determines the concurrency defects of the target application based on the runtime information of all target classes and the runtime information of all target call statements.

[0252] Based on the technical solution provided by the embodiment of the present application, the first code file corresponding to the target programming language (i.e., Java code) in the target application can be instrumented to obtain the corresponding runtime information, and the local source code corresponding to the target application can be instrumented to obtain the relevant runtime information of the native code's operation on the Java object. In this way, the user can obtain all the data that may cause concurrency defects in the Java code through the test equipment, so that the test equipment can finally detect the concurrency defects generated by the Java code more comprehensively based on these data to guide the developers to adjust and modify the target application, thereby making the quality and performance of the target application finally released better, and improving the user experience of the target application.

[0253] After obtaining the runtime information of all target classes and all target call statements, in order to facilitate the subsequent detection of concurrent defects, the test equipment can also group the operations of all target classes and all target call statements into an operation sequence and determine its characteristic parameters. In this way, concurrent defects can be detected on a complete operation sequence, improving the efficiency of concurrent defect detection. Based on this, combined with Figure 4 , refer to Fig.11 As shown, the method further includes S411A between S411 and S412, and S412 is replaced by S412A at this time:

[0254] S411A. The test device generates an original operation sequence according to the sequence identifiers in the runtime information of all target classes and all target call statements, using the operations corresponding to all target classes and the operations corresponding to all target call statements, and determines the characteristic parameters of the original operation sequence.

[0255] The characteristic parameters of the operation sequence may include any one or more of the following: the number of threads, the total number of operations, the number of operations within each thread, the number of shared variables, the number of locks, the number of operations of various types, etc.

[0256] Exemplarily, in order to implement S412, refer to Figure 5 As shown, the test device may further include a runtime information processing module 56. The runtime information processing module 56 may generate an original operation sequence using a sequence merging unit 561, and may determine characteristic parameters of the original sequence using an information statistics unit 562.

[0257] S412A. The testing device determines the concurrency defects of the target application based on the runtime information of all target classes, the runtime information of all target call statements, the original operation sequence and the characteristic parameters of the original operation sequence.

[0258] In this way, since the test equipment can detect concurrent defects in a complete operation sequence, the detection efficiency of concurrent defects is improved.

[0259] In addition, since concurrency defects are related to specific hardware and operating systems, the physical thread ID will be different when the same thread runs on different devices or operating systems. Therefore, it is not accurate to detect concurrency defects based on physical thread ID.

[0260] It does not depend on specific hardware and operating system and corresponds exactly to the threads in the application.

[0261] Therefore, after the test equipment obtains the runtime information of all target classes and all target call statements (i.e., S411), in order to facilitate more accurate detection results of subsequent concurrent defects, the thread identifiers in the runtime information of all target classes and all target call statements will be replaced by logical thread identifiers instead of physical thread identifiers. Figure 4 , refer to Fig.12 As shown, the method further includes S411B between S411 and S412:

[0262] S411B: The testing device updates the thread IDs in the runtime information of all target classes and all target call statements from physical thread IDs to logical thread IDs.

[0263] Specifically, in S411B, the test device updates the thread identifiers in the runtime information of all target classes from physical thread identifiers to logical thread identifiers, and updates the thread identifiers in the runtime information of all target call statements from physical thread identifiers to logical thread identifiers. The test device may store a mapping relationship between physical thread identifiers and logical thread identifiers, and any physical thread identifier may be updated to a corresponding logical thread identifier based on the mapping relationship.

[0264] For example, to implement S411B, refer to Figure 5 As shown, the runtime information processing module 56 in the test device may further include a mapping modification unit 563. The mapping modification unit 563 completes the determination of the thread identifier.

[0265] Based on this technical solution, the test equipment can obtain more accurate logical thread identification, and can also avoid the influence of hardware and operating system during the subsequent concurrent defect analysis, making the final concurrent defect analysis results more accurate.

[0266] In some embodiments, after the test device obtains the runtime information of all target classes and all target call statements, determines the original operation sequence and adjusts the thread identifier, the test device can use a feature detection algorithm based on all this information to detect concurrency defects corresponding to the Java code (i.e., the target programming language) in the target application. That is, the test device detects concurrency defects of the target application based on the runtime information of all target classes, the runtime information of all target call statements, the original operation sequence and the feature parameters of the original operation sequence.

[0267] It is understandable that, in order to realize the above functions, the above test equipment includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the embodiments of the present invention can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of the present application.

[0268] The embodiment of the present application can divide the functional modules of the above-mentioned electronic device according to the above-mentioned method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present invention is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0269] In the case of dividing each functional module into corresponding functional modules, refer to Fig.13 As shown, an embodiment of the present application provides a testing device, including: an acquisition module 1301, a plugging module 1302, a generation module 1303, a sending module 1304, a receiving module 1305 and a detection module 1306.

[0270] Among them, the acquisition module 1301 is used to obtain the installation package of the target application and the local source code file corresponding to the target application; the target application is a multi-threaded application written in the target programming language and the local programming language; the local source code file is a source code file written in the local programming language in the target application; the plug-in module 1302 is used to plug the target class in the first code file in the installation package obtained by the acquisition module 1301, and obtain the static information of the target class; the plug-in module 1302 is also used to identify and plug the target call statement in the local source code file obtained by the acquisition module 1302, and obtain the static information of the target call statement; the target call statement is a call statement to the target interface in the local source code file, and the target interface is used for the code file corresponding to the local programming language Complete the interaction with the code file corresponding to the target programming language; the generation module 1303 is used to generate the target installation package of the target application based on the first code file after the insertion module 1302 is inserted and the local source code file after the insertion module 1302 is inserted; the sending module 1304 is used to send the target installation package generated by the generation module 1303 to the test terminal; the receiving module 1305 is used to receive the dynamic information of the target class and the dynamic information of the target call statement from the test terminal; the detection module 1306 is used to determine the concurrency defects of the target application based on the runtime information of all target classes and the runtime information of all target call statements; the runtime information of the target class includes the static information and dynamic information of the target class, and the runtime information of the target call statement includes the static information and dynamic information of the target call statement.

[0271] The acquisition module 1301 , the plugging module 1302 , the generation module 1303 , the sending module 1304 , the receiving module 1305 and the detection module 1306 are also used to cooperate in implementing the concurrent defect detection method provided in the aforementioned implementation.

[0272] Regarding the electronic device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the information display method in the above embodiment, and will not be elaborated here. The relevant beneficial effects can also refer to the relevant beneficial effects of the above information display method, and will not be repeated here.

[0273] In other embodiments, the virtual module structure of the test device can be as follows: Figure 5 shown.

[0274] The present application also provides a test device, which includes: a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; wherein the memory stores a computer program code, the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the test device executes the concurrent defect detection method provided in the above embodiment. The specific structure of the test device can be referred to Figure 2 The structure of the test equipment is shown in .

[0275] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a test device, the test device executes the concurrent defect detection method provided in the above embodiment.

[0276] An embodiment of the present application also provides a computer program product, which includes executable instructions. When the computer program product is run on a test device, the test device executes the concurrent defect detection method provided in the above embodiment.

[0277] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0278] In the several embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0279] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0280] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0281] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0282] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A concurrent defect detection method, applied to a test device, characterized in that: The method comprises: The test device obtains an installation package of a target application and a local source code file corresponding to the target application; the target application is a multi-threaded application written in a target programming language and a local programming language; the local source code file is a source code file in the target application written in a local programming language; The testing device performs instrumentation on a target class in a first code file in the installation package, and obtains static information of the target class; The test device identifies and inserts a target call statement in the local source code file, and obtains static information of the target call statement; the target call statement is a call statement for a target interface in the local source code file, and the target interface is used for the code file corresponding to the local programming language to complete the interaction with the code file corresponding to the target programming language; The test device generates a target installation package of the target application based on the first code file after being inserted and the local source code file after being inserted; The test device sends the target installation package to the test terminal; The test device receives the dynamic information of the target class and the dynamic information of the target call statement from the test terminal; The testing device determines the concurrency defects of the target application based on the runtime information of all the target classes and the runtime information of all the target call statements; the runtime information of the target class includes the static information and dynamic information of the target class, and the runtime information of the target call statement includes the static information and dynamic information of the target call statement.

2. The method according to claim 1, characterized in that The testing device performs instrumentation on a target class in a first code file in the installation package, including: The test device receives a code file selection operation by a user; The testing device determines, in response to the code file selection operation, that among all code files corresponding to the target programming language in the target application installation package, the code file corresponding to the code file selection operation is the first code file; The testing device determines a target class that needs to be plugged in the first code file; The testing device performs instrumentation on the target class of the first code file.

3. The method according to claim 2, characterized in that The test device determines the target class that needs to be plugged in the first code file, including: The test device receives a class selection operation by a user; In response to the class selection operation, the test device determines the class corresponding to the class selection operation as the target class.

4. The method according to any one of claims 1 to 3, characterized in that: The target programming language is Java language, and the testing device performs plugging on the target class in the first code file in the installation package, including: The testing device inserts the target class of the first code file based on the Android version library on which the first code file depends and the DEX library of the Android system framework.

5. The method according to any one of claims 1 to 3, characterized in that: The target programming language is Java language, and the testing device performs plugging on the target class in the first code file in the installation package, including: The test device identifies and inserts the target statement in the target class of the first code file based on the first instrumentation tool; the target statement is a statement related to the target operation involved in the concurrency defect, and the target operation includes any one of the following: operation on shared variables, operation on synchronization locks, synchronization operation on threads, conditional branch operation; at this time, the static information of the target class includes the static information of the target statement in the target class.

6. The method according to claim 5, characterized in that The testing device identifies and inserts a target statement in the target class of the first code file, including: The testing device identifies a target statement in the target class of the first code file; The test device inserts a first probe code before or after the target statement; the first probe code is used to obtain runtime information corresponding to the target statement; the runtime information includes static information and dynamic information, the static information includes variable identifier and instruction identifier, and the dynamic information includes operation type, instance hash value of the variable, thread identifier and sequence identifier.

7. The method according to any one of claims 1 to 3, characterized in that: The test device identifies and inserts a target call statement in the local source code file, including: The test device compiles the local source code file using a local source code compiler to obtain a local code file; The test device identifies and inserts the target call statement in the local code file based on the second insertion tool.

8. The method according to claim 7, characterized in that The test device identifies and inserts a target call statement in a local code file based on a second insert tool, including: The test device identifies a target call statement in the local code file based on a second instrumentation tool; The test device inserts a second probe code before or after the target call statement based on a second instrumentation tool; the second probe code is used to obtain runtime information corresponding to the target call statement; the runtime information includes static information and dynamic information, the static information includes variable identification and instruction identification, and the dynamic information includes operation type, instance hash value of the variable, thread identification and sequence identification.

9. The method according to claim 8, characterized in that The test device obtains static information of the target call statement, including: The testing device obtains the instruction identifier of the target calling statement; The test device uses the variable identifier of the target statement that is identical to the static feature information of the variable corresponding to the target call statement as the variable identifier of the target call statement; the target statement is a statement in the target class related to the target operation involved in the concurrency defect; the target operation includes any one of the following: operations on shared variables, operations on synchronization locks, synchronization operations on threads, and conditional branch operations; the static feature information of the variable includes: the name of the variable, the type of the variable, and the class to which the variable belongs.

10. The method according to claim 1, characterized in that The probe code inserted by the test device after instrumenting the target class, and the probe code inserted by the test device after instrumenting the target call statement both include an instrumentation write interface method, and the instrumentation write interface method is used to write the runtime information obtained by the probe code into a file corresponding to the probe code by passing parameters.

11. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The test device generates an original operation sequence using operations corresponding to all the target classes and operations corresponding to all the target call statements according to sequence identifiers in the runtime information of all the target classes and sequence identifiers in the runtime information of all the target call statements, and determines characteristic parameters of the original operation sequence; The testing device determines the concurrency defect of the target application based on the runtime information of all the target classes and the runtime information of all the target call statements, including: the testing device determines the concurrency defect of the target application based on the runtime information of all the target classes, the runtime information of all the target call statements, the original operation sequence and the characteristic parameters of the original operation sequence.

12. The method according to any one of claims 1 to 3, characterized in that The method further includes: the testing device updating the thread identifiers in the runtime information of all the target classes and all the target call statements from physical thread identifiers to logical thread identifiers.

13. A testing device, characterized in that: It includes a display screen, a memory and one or more processors; the display screen and the memory are coupled to the processor; wherein the memory stores computer program code, the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the test equipment executes the concurrent defect detection method as described in any one of claims 1-12.

14. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on a test device, enable the test device to execute the concurrent defect detection method according to any one of claims 1 to 12.