CN112527302B - Error detection method and device, terminal and storage medium - Google Patents

Error detection method and device, terminal and storage medium Download PDF

Info

Publication number
CN112527302B
CN112527302B CN201910885688.9A CN201910885688A CN112527302B CN 112527302 B CN112527302 B CN 112527302B CN 201910885688 A CN201910885688 A CN 201910885688A CN 112527302 B CN112527302 B CN 112527302B
Authority
CN
China
Prior art keywords
class
file
function set
function
establishing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910885688.9A
Other languages
Chinese (zh)
Other versions
CN112527302A (en
Inventor
谭乐华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201910885688.9A priority Critical patent/CN112527302B/en
Publication of CN112527302A publication Critical patent/CN112527302A/en
Application granted granted Critical
Publication of CN112527302B publication Critical patent/CN112527302B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis

Abstract

The disclosure provides an error detection method and device, a terminal and a storage medium. The error detection method comprises the following steps: traversing a file to be detected, obtaining a function set in the file, and establishing the function set into a lookup table; traversing the function set to obtain an instruction in the function set; and judging whether the function set corresponding to the instruction exists in the lookup table, and if not, outputting error reporting information. The error detection method can automatically detect the problem that a called instruction or class function does not exist in a compiling stage before engineering is on line.

Description

Error detection method and device, terminal and storage medium
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a method and device for detecting errors, a terminal and a storage medium.
Background
Java is an object-oriented programming language in which cross-platform application software can be written. In the development process of an application project, sometimes, the main engineering depends on multiple libraries at the same time, and each library sometimes calls a large number of class methods. When multiple parties cooperate to develop a project together, a class method is sometimes modified during library calls. Thus, when the method called by the runtime is modified or deleted, a crash (NoSuchMethodError) may be initiated.
Disclosure of Invention
In order to solve the existing problems, the following technical scheme is adopted in the present disclosure.
In some embodiments, the present disclosure provides a method of error detection, comprising:
traversing a file to be detected, obtaining a function set in the file, and establishing the function set into a lookup table;
traversing the function set to obtain an instruction in the function set; and
Judging whether the function set corresponding to the instruction exists in the lookup table, and if not, outputting error reporting information.
In some embodiments, the present disclosure provides a method of error detection, comprising:
traversing a file to be detected, obtaining a function set in the file, and establishing the function set as a first set;
obtaining an instruction in the function set, and establishing the function set corresponding to the instruction as a second set; and
Obtaining a third set of intersections of the first set with the second set;
and comparing the second set with the third set, and outputting error reporting information if the second set is different from the third set.
In some embodiments, the present disclosure provides an apparatus for error detection, comprising:
the scanning module is used for traversing the file to be detected and the function set in the file;
the acquisition module is used for acquiring the function set and the instructions in the function set;
the establishing module is used for establishing the function set into a lookup table;
the judging module is used for judging whether the function set corresponding to the instruction exists in the lookup table or not; and
And the output module is used for outputting error reporting information.
In some embodiments, the present disclosure provides an apparatus for error detection, comprising:
the scanning module is used for traversing the file to be detected;
the acquisition module is used for acquiring the function set in the file and the instruction in the function set;
the building module is used for building the function set into a first set and building the function set corresponding to the instruction into a second set;
a comparison module for comparing the intersection of the first set with the second set; and
And the output module is used for outputting error reporting information.
In some embodiments, the present disclosure provides a terminal comprising: at least one memory and at least one processor;
the memory is used for storing program codes, and the processor is used for calling the program codes stored in the memory to execute the method.
In some embodiments, the present disclosure provides a storage medium for storing program code for performing the above-described method.
The error detection method, the error detection device, the terminal and the storage medium can automatically detect the problem that a called instruction or a class function possibly exists at least in a compiling stage before engineering is on line.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a flow chart of an error detection method of an embodiment of the present disclosure.
Fig. 2 is a schematic structural diagram of a class diagram of an embodiment of the present disclosure.
FIG. 3 is a flow chart of an error detection method of another embodiment of the present disclosure.
Fig. 4 is a schematic structural view of an error detection apparatus according to an embodiment of the present disclosure.
Fig. 5 is a schematic structural view of an error detection apparatus according to still another embodiment of the present disclosure.
Fig. 6 is a schematic structural diagram of an error detection apparatus according to still another embodiment of the present disclosure.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in and/or in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "a" and "an" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be construed as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The following describes in detail the schemes provided in the embodiments of the present application with reference to the accompanying drawings.
As shown in fig. 1, fig. 1 is a flowchart of an error detection method of an embodiment of the present disclosure. The error detection method provided by the embodiment of the disclosure comprises the following steps.
S100, traversing a file to be detected, obtaining a function set in the file, and establishing the function set into a lookup table.
S200, traversing the function set to obtain instructions in the function set.
S300, judging whether the function set corresponding to the instruction exists in the lookup table, and if not, outputting error reporting information.
Specifically, for example, in the Java language, the application program is developed, first, the source code of the file suffix name is written, then the source code is compiled into binary byte code (bytecode) which is irrelevant to the machine through a compiler, namely: class files, virtual machines (JVMs) of various different platforms are relied on to search and load classes needing to be executed in preset class loading paths and interpret and execute byte code programs during running. The compiler is only responsible for syntax checking when compiling Java code of the main project into a file, but the Java compiler does not check for files in jar or aar relied on in the project. Therefore, it is necessary to perform code checking. Code checking is generally in two schemes, one is static code checking based on Java source code and the other is code checking based on bytecode. Since all the dependency libraries are compiled into class files prior to the compilation build of the project, byte-code based code inspection is a better choice to find out at runtime such application programming interface incompatibility issues.
For ease of understanding, the basic structure of the bytecode file will be briefly described below.
The byte code file refers to a class file produced after the Java source code is compiled, and each class (class) in the Java source code generates a byte code file corresponding to the class file, namely the class file. Class files are binary files made up of a stream of bytes in a specific format that can be identified by the virtual machine. The basic structure of a class file is as follows:
the above information can be obtained by parsing the class file. A class file corresponds to a single class, and among all information of a class, the information which needs to be focused on includes: class name, parent class, the set of functions that this class contains, and all instructions within the set of functions, such as function call instructions. One set of functions returns one result at a time, as each set of functions is configured with a unique tag. Tags can be distinguished in the form of class names, method names, and method signatures. Specifically, an instruction, such as a function call instruction, is composed of an opcode and operands, the opcode being one byte (0-255) in length, and an instruction may include zero or several operands. Taking the invokevirtual instruction as an example, the following table shows:
operation code 182(0×b6)
Operand 1 Indexbyte1
Operand 2 Indexbyte2
The opcode of the Invokeevirtual instruction corresponds to 182 (0 Xb 6) with two operands. Wherein index byte1 and index byte2 are two unsigned operands that can be used to calculate index for a constant pool. The constant pool is mainly used for organizing some values of the same type related to the class file together in an index mode, so that different copies in different places are avoided, and the size of the byte code is reduced. The constant pool stores contents such as constant strings, word denominations of basic data types, and string information of class names, interface names, method names, and the like. The virtual machine constructs a constant table for each constant, and the class file indexes the constant table according to its position in the constant pool. More specifically, index= (< 1 x < 8) | index byte2, through which a symbolic reference of a method can be found in the constant pool, which can be obtained as a method name, a method signature (descriptor) and a symbolic reference of a class defining the method. When a certain function set is called, the unique return is obtained according to the unique class name, the unique method name and the unique method signature mode. The method signature may include, among other things, a method parameter and a method return value.
Based on the above description, the method of the embodiment of the disclosure includes traversing a file to be detected, such as a class file, acquiring function sets therein, configuring labels for the acquired function sets, and building the function sets into a lookup table (map). Thereafter, the set of functions is traversed to obtain instructions therein, such as function call instructions. Judging whether a function set corresponding to an instruction, such as a function call instruction, exists in the lookup table, if so, normally calling; if not, the set of functions that were called, or the specific instructions therein, have been deleted or modified, and cannot be normally called, thus potentially triggering a crash.
Further, the function set may also include an interface function set, an abstract class function set, and an implementation class function set. And when called, what is needed is a set of implementation class functions therein. Therefore, when the obtained function set is an interface function set or an abstract class function set, a corresponding implementation class function set needs to be determined. The determining mode may be that the class name is obtained through the obtained interface function set or abstract class function set, and then the corresponding implementation class function set is obtained through the class name.
Furthermore, java is polymorphic, and when a class of function set is called, no results may be returned. However, since its parent class may contain this set of functions, it is also necessary to retrieve the set of functions in the parent class. In the disclosed embodiments, class diagrams may be built for comprehensive retrieval. Specifically, as described above, a file, such as a class file, is parsed to obtain the corresponding class name and its parent class. Also, because global scanning of all files, such as class files, is a multi-threaded concurrent scanning, one class corresponds to one parent class, but one parent class corresponds to multiple children, i.e., one class corresponds to only one parent class, but one parent class may correspond to multiple children, as shown in fig. 2. For the completeness of the class diagram, parent class information of all classes needs to be obtained first, and a unidirectional pointing to the parent class is constructed; and then after global scanning, determining all subclasses of the parent class according to all acquired unidirectional pointing directions in a reverse direction, and establishing the relationship of the parent class pointing to the subclasses, so that a complete bidirectional relationship class diagram can be obtained. According to the complete class diagram, it is necessary to determine that a function set or instruction is not present, and trace back to the root (Java/lang/Object), for example, no result is returned all the time, so that it is possible to determine that the function set or instruction is not present. Of course, the tracing direction may be traced from the subclass to the parent class or traced from the parent class to the subclass, and the embodiment of the disclosure is not limited specifically.
Further, the above implementation traverses all files, but the storage locations of all files may be different. Thus, it is necessary to acquire all files. In particular, in the embodiment of the present disclosure, the location of the built-in file and the third party application file, that is, the combile sdk and sdk, may be obtained by, for example, appExtension, so as to obtain a complete file.
Furthermore, to facilitate quick localization after obtaining the error-reporting information, in the embodiments of the present disclosure, the location of the function set where the error occurred may be linked into the error-reporting information, for example, the log may be copied to Analyze Stacktrace, and the jump may be made directly to the pointed location, i.e., the location of the function set call, by clicking the line number.
In particular, in some cases, it may be known that some calls do not exist, but are inconvenient to modify after an error is reported, e.g., the modification authority of the function set is limited to the provider. At this point, the whitelist may be newly established in an existing lookup table such that the whitelist is matched when the call does not exist to avoid triggering an alarm. In particular, the whitelist may be expressed in a variety of granularities, such as a class or a set of functions. It will be appreciated that the smaller the granularity, the better the accuracy of the control, so as not to retain unnecessary call information.
The embodiment of the disclosure also provides a method for detecting errors, as shown in fig. 3, comprising the following steps.
S500, traversing a file to be detected, obtaining a function set in the file, and establishing the function set as a first set.
S600, obtaining the instruction in the function set, and establishing the function set corresponding to the instruction into a second set.
And S700, obtaining an intersection third set of the first set and the second set.
S800, comparing the second set with the third set, and if the second set is different from the third set, outputting error reporting information.
Specifically, in the transform phase, all files constructed by apk can be obtained. By analyzing these files, all function sets and instructions for call can be obtained. Wherein all function sets are defined as a first set; according to the called instruction, a called function set is obtained, and all the called function sets are defined as a second set. Normally, the second set should be a subset of the first set. And if the non-existing set of functions is checked, the non-existing set of functions is a subset of the second set but is not present in the first set.
As shown in fig. 4, fig. 4 is a schematic structural diagram of an error detection apparatus according to an embodiment of the present disclosure. The embodiment of the disclosure provides an apparatus 10, which comprises a scanning module 11, an acquisition module 12, a building module 13, a judging module 14 and an output module 15. The scanning module 11 may be configured to traverse the file to be detected and the function set in the file. The fetch module 12 is operable to fetch the set of functions and instructions in the set of functions. The building block 13 may be arranged to build the set of functions as a look-up table. The determining module 14 may be configured to determine whether the function set corresponding to the instruction exists in the lookup table. The output module 15 may be used to output error reporting information.
In another embodiment of the present disclosure, an error detection apparatus 20 is also provided, as shown in fig. 5. Unlike the previous embodiment, the apparatus 20 further comprises a parsing module 26, an identification module 27 and an allocation module 28. Wherein the parsing module 26 is operable to parse the file to obtain a constant pool of the file. The identification module 27 may be configured to identify a class corresponding to the file, so as to obtain a class name of the class. The assignment module 28 is operable to assign labels to the function sets, respectively. It can be appreciated that the above newly added modules may be added simultaneously or separately, and only need to perform their functions, which is not specifically limited in the embodiments of the present disclosure.
As shown in fig. 6, fig. 6 is a schematic structural diagram of an error detection apparatus according to still another embodiment of the present disclosure. The apparatus 30 comprises a scanning module 31, an acquisition module 33, a setup module 35, a comparison module 37 and an output module 39. Wherein the scanning module 31 may be used to traverse the document to be detected. The obtaining module 33 may be configured to obtain the function set in the file and the instruction in the function set. The establishing module 35 may be configured to establish the function set as a first set and the function set corresponding to the instruction as a second set. A comparison module 37 may be used to compare the intersection of the first set with the second set. The output module 39 may be used to output error messages.
For embodiments of the device, reference is made to the description of method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the modules illustrated as separate modules may or may not be separate. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The multi-window parallel method and apparatus of the present disclosure are described above based on embodiments and applications. In addition, the present disclosure also provides a terminal and a storage medium, which are described below.
Referring now to fig. 7, a schematic diagram of an electronic device (e.g., a terminal device or server) 800 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 7 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 7, the electronic device 800 may include a processing means (e.g., a central processor, a graphics processor, etc.) 801, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
In general, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, etc.; storage 808 including, for example, magnetic tape, hard disk, etc.; communication means 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 shows an electronic device 800 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 809, or installed from storage device 808, or installed from ROM 802. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 801.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods of the present disclosure described above.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In accordance with one or more embodiments of the present disclosure, there is provided a method of error detection, comprising:
traversing a file to be detected, obtaining a function set in the file, and establishing the function set into a lookup table;
traversing the function set to obtain an instruction in the function set; and
Judging whether the function set corresponding to the instruction exists in the lookup table, and if not, outputting error reporting information.
According to one or more embodiments of the present disclosure, there is provided a method for detecting an error, wherein the step of traversing a file to be detected, obtaining a function set in the file, and building the function set into a lookup table includes:
analyzing the file to obtain a constant pool of the file; and
And respectively obtaining the method name and the method signature of the function set according to the instruction and the constant pool.
According to one or more embodiments of the present disclosure, there is provided a method for detecting an error, wherein the step of traversing a file to be detected, obtaining a function set in the file, and building the function set into a lookup table further includes:
identifying a class corresponding to the file, and obtaining a class name of the class; and
And respectively distributing labels to the function sets according to the class names, the method names and the method signatures.
According to one or more embodiments of the present disclosure, there is provided a method of error detection, wherein the set of functions includes an interface function set, an abstract class function set, and an implementation class function set;
the step of traversing the file to be detected to obtain a function set in the file and establishing the function set as a lookup table further comprises the steps of:
if the function set is an interface function set or an abstract class function set, determining a corresponding implementation class function set through the class name, and establishing the implementation class function name into a lookup table.
According to one or more embodiments of the present disclosure, there is provided a method of error detection, characterized in that the method further comprises:
analyzing the file to obtain a parent class of the class corresponding to the file; and
And establishing a class diagram according to the class and the parent class.
According to one or more embodiments of the present disclosure, there is provided a method for error detection, wherein the step of creating a class diagram according to the class and the parent class includes:
obtaining a parent class of a first class, and establishing a guide pointing from the first class to the parent class of the first class;
obtaining a parent class of an nth class, wherein N is an integer greater than 1, and establishing a guide from the nth class to the parent class of the nth class.
According to one or more embodiments of the present disclosure, there is provided a method for error detection, wherein the step of building a class diagram according to the class and the parent class further includes:
acquiring all subclasses of the parent class of the first class, and establishing guides respectively pointing to all subclasses of the parent class of the first class from the parent class of the first class; and
And acquiring all subclasses of the parent class of the N-th class, and establishing guides respectively pointing to all subclasses of the parent class of the N-th class from the parent class of the N-th class.
According to one or more embodiments of the present disclosure, there is provided a method for detecting an error, wherein the step of determining whether the function set corresponding to the instruction exists in the lookup table, if not, outputting error reporting information includes:
adding location information of the instruction that is not present in the lookup table to the error reporting information such that the error reporting information points to the location of the instruction that is not present in the lookup table.
According to one or more embodiments of the present disclosure, there is provided a method of error detection, characterized in that the method further comprises:
setting up a white list in the lookup table; wherein the whitelist is different from the set of functions; and
And when the instruction is judged to be not in the lookup table but in the white list, the error reporting information is not output.
In accordance with one or more embodiments of the present disclosure, there is provided a method of error detection, comprising:
traversing a file to be detected, obtaining a function set in the file, and establishing the function set as a first set;
obtaining an instruction in the function set, and establishing the function set corresponding to the instruction as a second set;
obtaining a third set of intersections of the first set with the second set; and
And comparing the second set with the third set, and outputting error reporting information if the second set is different from the third set.
According to one or more embodiments of the present disclosure, there is provided an apparatus for error detection, comprising:
the scanning module is used for traversing the file to be detected and the function set in the file;
the acquisition module is used for acquiring the function set and the instructions in the function set;
the establishing module is used for establishing the function set into a lookup table;
the judging module is used for judging whether the function set corresponding to the instruction exists in the lookup table or not; and
And the output module is used for outputting error reporting information.
According to one or more embodiments of the present disclosure, there is provided an apparatus for error detection, characterized in that the apparatus further comprises:
the analysis module is used for analyzing the file to obtain a constant pool of the file; and/or
The identification module is used for identifying the class corresponding to the file so as to obtain the class name of the class; and/or
And the distribution module is used for distributing labels to the function sets respectively.
According to one or more embodiments of the present disclosure, there is provided an apparatus for error detection, comprising:
the scanning module is used for traversing the file to be detected;
the acquisition module is used for acquiring the function set in the file and the instruction in the function set;
the building module is used for building the function set into a first set and building the function set corresponding to the instruction into a second set;
a comparison module for comparing the intersection of the first set with the second set; and
And the output module is used for outputting error reporting information.
According to one or more embodiments of the present disclosure, there is provided a terminal including: at least one memory and at least one processor;
wherein the at least one memory is configured to store program code, and the at least one processor is configured to invoke the program code stored by the at least one memory to perform any of the methods described above.
According to one or more embodiments of the present disclosure, there is provided a storage medium for storing program code for performing the above-described method.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (13)

1. A method of error detection, comprising:
traversing a file to be detected, obtaining a function set in the file, and establishing the function set into a lookup table;
traversing the function set to obtain an instruction in the function set; and
Judging whether the function set corresponding to the instruction exists in the lookup table or not, and if not, outputting error reporting information;
the step of traversing the file to be detected to obtain a function set in the file and establishing the function set as a lookup table comprises the following steps:
analyzing the file to obtain a constant pool of the file; and
And respectively obtaining the method name and the method signature of the function set according to the instruction and the constant pool.
2. The method of claim 1, wherein traversing the file to be detected, obtaining a set of functions in the file, and establishing the set of functions as a lookup table further comprises:
identifying a class corresponding to the file, and obtaining a class name of the class; and
And respectively distributing labels to the function sets according to the class names, the method names and the method signatures.
3. The method of claim 2, wherein the set of functions comprises a set of interface functions, a set of abstract class functions, and a set of implementation class functions;
the step of traversing the file to be detected to obtain a function set in the file and establishing the function set as a lookup table further comprises the steps of:
if the function set is an interface function set or an abstract class function set, determining a corresponding implementation class function set through the class name, and establishing the implementation class function name into a lookup table.
4. The method according to claim 2, wherein the method further comprises:
analyzing the file to obtain a parent class of the class corresponding to the file; and
And establishing a class diagram according to the class and the parent class.
5. The method of claim 4, wherein the step of creating a class diagram from the class and the parent class comprises:
obtaining a parent class of a first class, and establishing a guide pointing from the first class to the parent class of the first class;
obtaining a parent class of an nth class, wherein N is an integer greater than 1, and establishing a guide from the nth class to the parent class of the nth class.
6. The method of claim 5, wherein the step of building a class diagram from the class and the parent class further comprises:
acquiring all subclasses of the parent class of the first class, and establishing guides respectively pointing to all subclasses of the parent class of the first class from the parent class of the first class; and
And acquiring all subclasses of the parent class of the N-th class, and establishing guides respectively pointing to all subclasses of the parent class of the N-th class from the parent class of the N-th class.
7. The method according to claim 1, wherein the step of determining whether the function set corresponding to the instruction exists in the lookup table, and if not, outputting error reporting information includes:
adding location information of the instruction that is not present in the lookup table to the error reporting information such that the error reporting information points to the location of the instruction that is not present in the lookup table.
8. The method according to claim 1, wherein the method further comprises:
setting up a white list in the lookup table; wherein the whitelist is different from the set of functions; and
And when the instruction is judged to be not in the lookup table but in the white list, the error reporting information is not output.
9. A method of error detection, comprising:
traversing a file to be detected, obtaining a function set in the file, and establishing the function set as a first set;
obtaining an instruction in the function set, and establishing the function set corresponding to the instruction as a second set;
obtaining a third set of intersections of the first set with the second set; and
And comparing the second set with the third set, and outputting error reporting information if the second set is different from the third set.
10. An apparatus for error detection, comprising:
the scanning module is used for traversing the file to be detected and the function set in the file;
the acquisition module is used for acquiring the function set and the instructions in the function set;
the establishing module is used for establishing the function set into a lookup table;
the judging module is used for judging whether the function set corresponding to the instruction exists in the lookup table or not; and
The output module is used for outputting error reporting information;
wherein the apparatus further comprises:
the analysis module is used for analyzing the file to obtain a constant pool of the file; and/or
The identification module is used for identifying the class corresponding to the file so as to obtain the class name of the class; and/or
And the distribution module is used for distributing labels to the function sets respectively.
11. An apparatus for error detection, comprising:
the scanning module is used for traversing the file to be detected;
the acquisition module is used for acquiring the function set in the file and the instruction in the function set;
the building module is used for building the function set into a first set and building the function set corresponding to the instruction into a second set;
a comparison module for comparing the intersection of the first set with the second set; and
And the output module is used for outputting error reporting information.
12. A terminal, comprising:
at least one memory and at least one processor;
wherein the at least one memory is configured to store program code, and the at least one processor is configured to invoke the program code stored by the at least one memory to perform the method of any of claims 1 to 9.
13. A storage medium for storing program code for performing the method of any one of claims 1 to 9.
CN201910885688.9A 2019-09-19 2019-09-19 Error detection method and device, terminal and storage medium Active CN112527302B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910885688.9A CN112527302B (en) 2019-09-19 2019-09-19 Error detection method and device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910885688.9A CN112527302B (en) 2019-09-19 2019-09-19 Error detection method and device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN112527302A CN112527302A (en) 2021-03-19
CN112527302B true CN112527302B (en) 2024-03-01

Family

ID=74974029

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910885688.9A Active CN112527302B (en) 2019-09-19 2019-09-19 Error detection method and device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN112527302B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113127050B (en) * 2021-04-28 2024-03-22 上海米哈游璃月科技有限公司 Application resource packaging process monitoring method, device, equipment and medium
CN114595198B (en) * 2022-03-15 2023-09-05 抖音视界有限公司 Crash analysis method and device, electronic equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101604370A (en) * 2009-07-06 2009-12-16 中国人民解放军信息技术安全研究中心 A kind of method of monitoring Windows kernel function call of highly compatible
CN102567200A (en) * 2011-12-14 2012-07-11 北京航空航天大学 Parallelization security hole detecting method based on function call graph
CN103226583A (en) * 2013-04-08 2013-07-31 北京奇虎科技有限公司 Method and device for recognizing advertisement plugin
CN103631573A (en) * 2012-08-24 2014-03-12 中兴通讯股份有限公司 Method and system for obtaining execution time of transferable functions
CN104281519A (en) * 2013-07-08 2015-01-14 华为技术有限公司 Method and equipment for detecting errors of program
CN105677311A (en) * 2014-11-21 2016-06-15 卓望数码技术(深圳)有限公司 Identification method and device for function call relationships
CN106295348A (en) * 2015-05-29 2017-01-04 阿里巴巴集团控股有限公司 The leak detection method of application program and device
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN107330322A (en) * 2017-06-06 2017-11-07 北京奇虎科技有限公司 File safety protection method, device and equipment
CN108959085A (en) * 2018-06-25 2018-12-07 清华大学 A kind of method and system detecting kernel module suspend mode mistake in atom context
CN110134385A (en) * 2019-05-17 2019-08-16 中国农业银行股份有限公司 Record the method and C language general journal frame of C language function call chain

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101604370A (en) * 2009-07-06 2009-12-16 中国人民解放军信息技术安全研究中心 A kind of method of monitoring Windows kernel function call of highly compatible
CN102567200A (en) * 2011-12-14 2012-07-11 北京航空航天大学 Parallelization security hole detecting method based on function call graph
CN103631573A (en) * 2012-08-24 2014-03-12 中兴通讯股份有限公司 Method and system for obtaining execution time of transferable functions
CN103226583A (en) * 2013-04-08 2013-07-31 北京奇虎科技有限公司 Method and device for recognizing advertisement plugin
CN104281519A (en) * 2013-07-08 2015-01-14 华为技术有限公司 Method and equipment for detecting errors of program
CN105677311A (en) * 2014-11-21 2016-06-15 卓望数码技术(深圳)有限公司 Identification method and device for function call relationships
CN106295348A (en) * 2015-05-29 2017-01-04 阿里巴巴集团控股有限公司 The leak detection method of application program and device
CN106371940A (en) * 2015-07-21 2017-02-01 腾讯科技(深圳)有限公司 Solution method and device for program crash
CN107330322A (en) * 2017-06-06 2017-11-07 北京奇虎科技有限公司 File safety protection method, device and equipment
CN108959085A (en) * 2018-06-25 2018-12-07 清华大学 A kind of method and system detecting kernel module suspend mode mistake in atom context
CN110134385A (en) * 2019-05-17 2019-08-16 中国农业银行股份有限公司 Record the method and C language general journal frame of C language function call chain

Also Published As

Publication number Publication date
CN112527302A (en) 2021-03-19

Similar Documents

Publication Publication Date Title
CN111506900B (en) Vulnerability detection method and device, electronic equipment and computer storage medium
CN111221572B (en) Method, device, medium and equipment for automatically adapting to running environment
CN110764748B (en) Code calling method, device, terminal and storage medium
CN110750545B (en) Dynamic library heat updating method, device, medium and equipment
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN112395253B (en) Index file generation method, terminal device, electronic device and medium
CN112527302B (en) Error detection method and device, terminal and storage medium
CN109947431B (en) Code generation method, device, equipment and storage medium
US9064042B2 (en) Instrumenting computer program code by merging template and target code methods
CN111506904B (en) Method and device for online bug repair
CN111414308B (en) Application package processing method and application running method and device
CN111124541B (en) Configuration file generation method, device, equipment and medium
CN111796865B (en) Byte code file modification method, device, terminal equipment and medium
CN111414152B (en) Method, system, readable medium and electronic device for realizing business logic
CN112379967B (en) Simulator detection method, device, equipment and medium
CN111309323B (en) Parameter initialization method and device and electronic equipment
CN114047923A (en) Error code positioning method, device, storage medium and electronic equipment
CN110489180B (en) Buried point reporting method, device, medium and electronic equipment
CN113778451A (en) File loading method and device, computer system and computer readable storage medium
CN111797009A (en) Method and device for detecting code compatibility and electronic equipment
CN112015394B (en) Android function module development method and device, computer system and storage medium
CN110489341B (en) Test method and device, storage medium and electronic equipment
CN116521175A (en) Dependency introduction method, apparatus, medium and electronic device
CN116594630A (en) File generation method, device, medium and electronic equipment
CN116501634A (en) Test case management method, device, medium and electronic equipment

Legal Events

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