Crash source code location method, device, medium and electronic device
By changing the location of source code statements in the source code file and obtaining assembly instruction encoding files, the problem of inaccuracy and low efficiency of locating source code crashes in the existing technology is solved, and fast and efficient crash source code positioning is achieved, improving the user experience.
Patent Information
- Application Number
- CN202110268962.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-12
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-03-12
AI Technical Summary
The prior art is inefficient in locating crash problems caused by source code, resulting in a decline in user experience.
By changing the location of the source code statements in the source code file, the changed source code file is generated, and by obtaining the assembly instruction encoding file and crash stack information, the location changes of the assembly code are determined, thereby positioning the crash location of the source code.
It realizes rapid positioning of crash source code, improving positioning efficiency and user experience.
Smart Images

Figure CN113918444B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of source code positioning, and in particular to a crash source code positioning method, device, medium and electronic device. Background Art
[0002] Currently, crashes caused by source code are mainly investigated by debugging offline integrated development tools. For example, the operating system running the source code is the Android system, and the integrated development tool is Android Studio. The crash source code located in this way has low accuracy and low efficiency, which reduces the user experience.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present invention, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a crash source code location method, device, medium and electronic device, which can at least to a certain extent be able to quickly locate the crash source code, improve the efficiency of locating the crash source code, and improve the user experience.
[0005] Other features and advantages of the present invention will become apparent from the following detailed description, or may be learned in part by practice of the present invention.
[0006] According to a first aspect of an embodiment of the present invention, a crash source code locating method is provided, comprising: obtaining a changed source code file by changing the position of a source code statement in a source code file; obtaining a first assembly instruction encoding file according to the changed source code file; obtaining assembly code of a crash point in a second assembly instruction encoding file according to crash stack information, the first assembly instruction encoding file and the second assembly instruction encoding file being different; determining a position change of the assembly code of the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file; determining a crash position of source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction encoding file; and locating the crashed source code in the source code file according to the crash position of the source code in the source code file.
[0007] In some embodiments of the present invention, obtaining the changed source code file by changing the position of source code statements in the source code file includes: changing the position of source code statements in the source code file by inserting new source code to obtain the changed source code file; or changing the position of source code statements in the source code file by deleting source code to obtain the changed source code file.
[0008] In some embodiments of the present invention, obtaining the first assembly instruction encoding file according to the changed source code file includes: compiling the changed source code file to obtain a binary file of the source code; and decompiling the binary file of the source code to obtain the first assembly instruction encoding file.
[0009] In some embodiments of the present invention, obtaining the assembly code of the crash point in the second assembly instruction encoding file according to the crash stack information includes: obtaining the crashed binary file and the instruction crash position in the crashed binary file according to the crash stack information; decompiling the crashed binary file to obtain the second assembly instruction encoding file; and determining the assembly code of the crash point in the second assembly instruction encoding file according to the instruction crash position in the crashed binary file.
[0010] In some embodiments of the present invention, determining the position change of the assembly code of the crash point in the first assembly instruction encoding file based on the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file includes: determining the assembly code of the crash point in the first assembly instruction encoding file based on the assembly code of the crash point in the second assembly instruction encoding file; determining the position change of the assembly code of the crash point in the first assembly instruction encoding file based on the position of the assembly code of the crash point in the first assembly instruction encoding file and the position of the assembly code of the crash point in the second assembly instruction encoding file.
[0011] In some embodiments of the present invention, determining the crash position of the source code in the source code file according to the position change of the assembly code at the crash point in the first assembly instruction encoding file includes: when the position of the assembly code at the crash point in the first assembly instruction encoding file changes, determining the crash position of the source code in the source code file according to the position where new code is inserted or the position where the source code is deleted in the source code file.
[0012] In some embodiments of the present invention, the crash stack information is online crash stack information, and the method further includes: executing the source code that crashes in the source code file in a test environment to obtain the crash stack information of the test environment; and comparing the crash stack information of the test environment with the online crash stack information.
[0013] According to a second aspect of an embodiment of the present invention, a crash source code locating device is provided, comprising: a source code statement position changing module, used for obtaining a changed source code file by changing the position of a source code statement in a source code file; a first acquisition module, used for acquiring a first assembly instruction encoding file according to the changed source code file; a second acquisition module, used for acquiring the assembly code of a crash point in a second assembly instruction encoding file according to crash stack information, wherein the first assembly instruction encoding file and the second assembly instruction encoding file are different; a first determination module, used for determining a position change of the assembly code of a crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file; a second determination module, used for determining a crash position of a source code in the source code file according to a position change of the assembly code of the crash point in the first assembly instruction encoding file; and a positioning module, used for locating the crashed source code in the source code file according to the crash position of the source code in the source code file.
[0014] In some embodiments of the present invention, the module for changing the position of source code statements is configured to include: changing the position of source code statements in the source code file by inserting new source code to obtain a changed source code file; or changing the position of source code statements in the source code file by deleting source code to obtain a changed source code file.
[0015] In some embodiments of the present invention, the above-mentioned first acquisition module includes: a compilation module, used to compile the changed source code file to obtain a binary file of the source code; a first decompilation module, used to decompile the binary file of the source code to obtain the first assembly instruction encoding file.
[0016] In some embodiments of the present invention, the above-mentioned second acquisition module includes: an instruction crash position acquisition module, which is used to obtain the crashed binary file and the instruction crash position in the crashed binary file according to the crash stack information; a second decompilation module, which is used to decompile the crashed binary file to obtain the second assembly instruction encoding file; and a first assembly code determination module, which is used to determine the assembly code of the crash point in the second assembly instruction encoding file according to the instruction crash position in the crashed binary file.
[0017] In some embodiments of the present invention, the above-mentioned first determination module includes: a second assembly code determination module, used to determine the assembly code of the crash point in the first assembly instruction coding file based on the assembly code of the crash point in the second assembly instruction coding file; an assembly code position change determination module, used to determine the position change of the assembly code of the crash point in the first assembly instruction coding file based on the position of the assembly code of the crash point in the first assembly instruction coding file and the position of the assembly code of the crash point in the second assembly instruction coding file.
[0018] In some embodiments of the present invention, the second determination module is configured to determine the crash position of the source code in the source code file according to the position where the new code is inserted or the position where the source code is deleted in the source code file when the position of the assembly code of the crash point in the first assembly instruction encoding file changes.
[0019] In some embodiments of the present invention, the crash stack information is online crash stack information, and the device also includes: an execution module, used to execute the source code that crashes in the source code file in a test environment to obtain the crash stack information of the test environment; and a comparison module, used to compare the crash stack information of the test environment with the online crash stack information.
[0020] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the crash source code locating method as described in the first aspect of the above embodiment.
[0021] According to a fourth aspect of an embodiment of the present invention, a computer readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the crash source code locating method described in the first aspect of the above embodiment is implemented.
[0022] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:
[0023] In the technical solutions provided by some embodiments of the present invention, the changed source code file is obtained by changing the position of the source code statement in the source code file, and the first assembly instruction encoding file is obtained according to the changed source code file. The assembly code of the crash point in the second assembly instruction encoding file is obtained according to the crash stack information, and the position change of the assembly code of the crash point in the first assembly instruction encoding file is determined according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file. The crash position of the source code in the source code file is determined according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, and the source code that crashed in the source code file is located according to the crash position of the source code in the source code file. In this way, the crash source code can be quickly located, the efficiency of locating the crash source code is improved, and the user experience is improved.
[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings herein are incorporated into and constitute a part of the specification, showing embodiments consistent with the present invention, and together with the specification, are used to explain the principles of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0026] Figure 1 A schematic diagram showing an exemplary system architecture to which a crash source code location method or a crash source code location device according to an embodiment of the present invention can be applied;
[0027] Figure 2 A flowchart of a method for locating a crash source code according to an embodiment of the present invention is schematically shown;
[0028] Figure 3 A flowchart of a method for locating a crash source code according to another embodiment of the present invention is schematically shown;
[0029] Figure 4 A flowchart of a method for locating a crash source code according to another embodiment of the present invention is schematically shown;
[0030] Figure 5 A flowchart of a method for locating a crash source code according to another embodiment of the present invention is schematically shown;
[0031] Figure 6 A flowchart of a method for locating a crash source code according to another embodiment of the present invention is schematically shown;
[0032] Figure 7 A block diagram schematically shows a crash source code location device according to an embodiment of the present invention;
[0033] Figure 8 A block diagram schematically shows a crash source code location device according to another embodiment of the present invention;
[0034] Fig. 9 A block diagram schematically shows a crash source code location device according to another embodiment of the present invention;
[0035] Fig.10 A block diagram schematically shows a crash source code location device according to another embodiment of the present invention;
[0036] Fig.11 A block diagram schematically shows a crash source code location device according to another embodiment of the present invention;
[0037] Fig.12 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0038] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the present invention will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0039] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0040] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0041] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0042] Figure 1 A schematic diagram showing an exemplary system architecture to which the crash source code locating method or crash source code locating device according to an embodiment of the present invention can be applied is shown.
[0043] like Figure 1 As shown, the system architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0044] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.
[0045] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, portable computers, desktop computers, etc.
[0046] The server 105 may be a server that provides various services. For example, the server 105 obtains the source code file and the crash stack information generated when the application is run online from the terminal device 103 (which may also be the terminal device 101 or 102). The server 105 may obtain the changed source code file by changing the position of the source code statement in the source code file, obtain the first assembly instruction encoding file according to the changed source code file, obtain the assembly code of the crash point in the second assembly instruction encoding file according to the crash stack information, determine the position change of the assembly code of the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file, determine the crash position of the source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, and locate the crashed source code in the source code file according to the crash position of the source code in the source code file, so that the crashed source code can be quickly located, the efficiency of locating the crashed source code is improved, and the user experience is improved.
[0047] In some embodiments, the crash source code location method provided by the embodiments of the present invention is generally executed by the server 105, and accordingly, the crash source code location device is generally set in the server 105. In other embodiments, some terminals may have functions similar to those of the server to execute the method. Therefore, the crash source code location method provided by the embodiments of the present invention is not limited to being executed on the server side.
[0048] Figure 2 The flowchart of the method for locating a crash source code according to an embodiment of the present invention is schematically shown.
[0049] like Figure 2 As shown, the crash source code location method may include steps S210 to S260.
[0050] In step S210, the changed source code file is obtained by changing the position of the source code statement in the source code file.
[0051] In step S220, a first assembly instruction encoding file is obtained according to the changed source code file.
[0052] In step S230, the assembly code of the crash point in the second assembly instruction code file is obtained according to the crash stack information, and the first assembly instruction code file and the second assembly instruction code file are different.
[0053] In step S240, a position change of the assembly code at the crash point in the first assembly instruction code file is determined based on the assembly code at the crash point in the first assembly instruction code file and the second assembly instruction code file.
[0054] In step S250, the crash position of the source code in the source code file is determined according to the position change of the assembly code of the crash point in the first assembly instruction code file.
[0055] In step S260, the crashed source code in the source code file is located according to the crash position of the source code in the source code file.
[0056] The method can obtain a changed source code file by changing the position of a source code statement in a source code file, obtain a first assembly instruction encoding file according to the changed source code file, obtain the assembly code of the crash point in the second assembly instruction encoding file according to the crash stack information, determine the position change of the assembly code of the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file, determine the crash position of the source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, and locate the crashed source code in the source code file according to the crash position of the source code in the source code file, so that the crashed source code can be quickly located, the efficiency of locating the crashed source code is improved, and the user experience is improved.
[0057] In one embodiment of the present invention, the source code file includes source code statements written in C / C++ language. For example, the source code file may include multiple C / C++ statements.
[0058] In one embodiment of the present invention, the source code file may be run in an operating system of a terminal, such as an Android system or an iOS system.
[0059] In the related art, since the above-mentioned Android system is an open source operating system, each terminal manufacturer has its own customized ROM, which leads to the fragmentation of the Android system. The corresponding terminal environments of the Android system are also different and ever-changing, which leads to the Android application to adapt to various versions and models. It is inevitable that crashes will occur in some environments, and such crashes are difficult to reproduce in the development and test environments of developers. And because such online crashes are difficult to reproduce in local development environments and test environments, and if the C++ source code of the Android application is complex, it is difficult to find the cause of the crash in the integrated development tool, resulting in the inability to modify the crash bug in time.
[0060] Through the embodiments of the present disclosure, the crash source code position can be located according to the crash stack log collected online and the limited number of changes and compilations to the source code position in the source code file, and the crash can be simulated and reproduced and the crash code can be modified. For example, by changing the position of the source code statement in the source code file, the changed source code file is obtained, and according to the changed source code file, the first assembly instruction encoding file is obtained, and according to the crash stack information, the assembly code of the crash point in the second assembly instruction encoding file is obtained, and according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file, the position change of the assembly code of the crash point in the first assembly instruction encoding file is determined, and according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, the crash position of the source code in the source code file is determined, and according to the crash position of the source code in the source code file, the source code of the crash in the source code file is located, so that the crash source code can be quickly located, the efficiency of locating the crash source code is improved, and the user experience is improved. And based on the located crash source code, it can be modified in time.
[0061] In one embodiment of the present invention, the above-mentioned changing the position of the source code statement in the source code file to obtain the changed source code file may include: changing the position of the source code statement in the source code file by inserting new source code to obtain the changed source code file; or changing the position of the source code statement in the source code file by deleting source code to obtain the changed source code file. For example, inserting new source code at any position in the source code file can change the original position of the source code statement in the source code file to obtain the changed source code file. It should be noted that inserting new source code will not affect the processing logic of the original source code file. For another example, deleting some source code in the source code file that is not related to the processing logic can also change the original position of the source code statement in the source code file to obtain the changed source code file.
[0062] In one embodiment of the present invention, the above crash stack information may be online crash stack information. For example, when an application crashes while running online, log data needs to be uploaded to a server, and the log data includes the crash stack information.
[0063] In one embodiment of the present invention, the first assembly instruction code file may be obtained based on the changed source code file. For example, the changed source code file is compiled, and then the compiled result is decompiled to obtain the first assembly instruction code file.
[0064] In one embodiment of the present invention, the second assembly instruction code file can be obtained based on the crashed so library. For example, the crashed so library is decompiled to obtain the second assembly instruction code file. In this embodiment, the so library is associated with the source code file.
[0065] In one embodiment of the present invention, according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, determining the crash position of the source code in the source code file includes: when the position of the assembly code of the crash point in the first assembly instruction encoding file changes, according to the position of inserting new code or deleting source code in the source code file, determining the crash position of the source code in the source code file. For example, when the position of the assembly code of the crash point in the first assembly instruction encoding file changes, it means that the position of the source code crash is after the position of inserting new code or deleting source code this time. On the contrary, if the position of the assembly code of the crash point in the first assembly instruction encoding file does not change, it means that the position of the source code crash is before the position of inserting new code or deleting source code this time. In this embodiment, if the position of the source code crash is before the position of inserting new code or deleting source code this time, the position of the source code is continuously changed forward according to the position of inserting new code or deleting source code last time. If the position of the assembly code of the crash point in the first assembly instruction encoding file changes, it means that the position of the source code crash is after the position of inserting new code or deleting source code this time, that is, the position of the source code crash is between two modified codes (for example, one causing instruction change and one not causing instruction change). In this way, the position of the source code crash can be gradually determined by repeating the above steps, and then the crash is located to a certain source code in the source code file according to the position.
[0066] Figure 3 The following schematically shows a flow chart of a method for locating a crash source code according to another embodiment of the present invention.
[0067] like Figure 3 As shown, the above step S220 may specifically include steps S310 and S320.
[0068] In step S310, the changed source code file is compiled to obtain a binary file of the source code.
[0069] In step S320, the binary file of the source code is decompiled to obtain the first assembly instruction encoding file.
[0070] The method can quickly obtain the first assembly instruction code file based on the changed source code file, so as to facilitate the subsequent acquisition of the assembly code of the crash point in the first assembly instruction code file according to the first assembly instruction code file.
[0071] In one embodiment of the present invention, the source code file is compiled before the position of the source code statement is changed, and then the compiled result is decompiled to obtain an assembly instruction code file. The order of the assembly code in the assembly instruction code file is the same as the order of the assembly code in the second assembly instruction code file. Based on this situation, if the position of the source code statement in the source code file is changed, the order of the assembly code in the first assembly instruction code file obtained based on the changed source code file may change. In this way, based on the order of the assembly code in the first assembly instruction code file and the order of the assembly code in the second assembly instruction code file, and the assembly code of the crash point in the second assembly instruction code file, it can be determined whether the position of the assembly code of the crash point in the first assembly instruction code file has changed.
[0072] Figure 4 The following schematically shows a flow chart of a method for locating a crash source code according to another embodiment of the present invention.
[0073] like Figure 4 As shown, the above step S230 may specifically include steps S410 to S430.
[0074] In step S410, the crashed binary file and the crash position of the instruction in the crashed binary file are obtained according to the crash stack information.
[0075] In step S420, the crashed binary file is decompiled to obtain the second assembly instruction code file.
[0076] In step S430, the assembly code of the crash point in the second assembly instruction code file is determined according to the instruction crash position in the crashed binary file.
[0077] The method can obtain the crashed binary file and the instruction crash position in the crashed binary file according to the crash stack information, then decompile the crashed binary file to obtain a second assembly instruction encoding file, and determine the assembly code of the crash point in the second assembly instruction encoding file according to the instruction crash position in the crashed binary file. In this way, the assembly code of the crash point in the second assembly instruction encoding file associated with the so library can be quickly determined, so that the position change of the assembly code of the crash point in the first assembly instruction encoding file can be determined subsequently according to the assembly code of the crash point in the second assembly instruction encoding file.
[0078] In one embodiment of the present invention, the above crash stack information may be as follows:
[0079] Caused By:SIGSEGV(SEGV_MAPERR)Address Not Mapped To Object
[0080] REGS Info:
[0081]
[0082]
[0083]
[0084] backtrace:
[0085] #00pc 0001a478 / data / app / com.jd.jrapp-_tIlUnQxxkggOcdgaeDyoQ== / lib / arm / libbiometric.so
[0086] #01pc 0007e827 / system / lib / libc.so(je_free+70)
[0087] By using a preset script to process the above crash stack information, you can obtain the crashed binary file and the crash position of the instruction in the crashed binary file. For example, the crashed binary file is libbiometric.so The crash location of the binary file is 0001a478 .
[0088] In one embodiment of the present invention, the crashed binary file is decompiled to obtain a second assembly instruction code file. For example, the objdump tool provided by NDK can be used to decompile libbiometric.so to obtain the assembly instruction code file of the so library, such as: objdump-d libbiometric.so>dissemble.txt.
[0089] In one embodiment of the present invention, the content included in the second assembly instruction encoding file is as follows:
[0090]
[0091] The assembly code of the crash point in the second assembly instruction encoding file is obtained by a preset script according to the instruction crash position in the crashed binary file. For example, the assembly code of the crash point in the second assembly instruction encoding file is 1a478:6860ldr r0,[r4,#4].
[0092] Figure 5The following schematically shows a flow chart of a method for locating a crash source code according to another embodiment of the present invention.
[0093] like Figure 5 As shown, the above step S240 may specifically include step S510 and step S520.
[0094] In step S510, the assembly code of the crash point in the first assembly instruction code file is determined according to the assembly code of the crash point in the second assembly instruction code file.
[0095] In step S520, a position change of the assembly code at the crash point in the first assembly instruction code file is determined according to the position of the assembly code at the crash point in the first assembly instruction code file and the position of the assembly code at the crash point in the second assembly instruction code file.
[0096] The method determines the assembly code of the crash point in the first assembly instruction coding file based on the assembly code of the crash point in the second assembly instruction coding file, and then determines the position change of the assembly code of the crash point in the first assembly instruction coding file based on the position of the assembly code of the crash point in the first assembly instruction coding file and the position of the assembly code of the crash point in the second assembly instruction coding file. In this way, it can be quickly determined whether the position of the assembly code of the crash point in the first assembly instruction coding file has changed due to changing the position of the source code statement in the source code file.
[0097] In one embodiment of the present invention, the assembly code of the crash point in the first assembly instruction encoding file is determined according to the assembly code of the crash point in the second assembly instruction encoding file. For example, if the assembly code of the crash point in the second assembly instruction encoding file is 1a478:6860ldr r0,[r4,#4], then the assembly code of the crash point in the first assembly instruction encoding file is 1a478:6860ldr r0,[r4,#4].
[0098] In one embodiment of the present invention, based on the position of the assembly code of the crash point in the first assembly instruction coding file and the position of the assembly code of the crash point in the second assembly instruction coding file, the position change of the assembly code of the crash point in the first assembly instruction coding file is determined. For example, if the position of the assembly code of the crash point in the first assembly instruction coding file is the same as the position of the assembly code of the crash point in the second assembly instruction coding file, it means that the position of the assembly code of the crash point in the first assembly instruction coding file has not changed. For another example, if the position of the assembly code of the crash point in the first assembly instruction coding file is different from the position of the assembly code of the crash point in the second assembly instruction coding file, it means that the position of the assembly code of the crash point in the first assembly instruction coding file has changed.
[0099] Figure 6 The following schematically shows a flow chart of a method for locating a crash source code according to another embodiment of the present invention.
[0100] like Figure 6 As shown, the above method may further include step S610 and step S620.
[0101] In step S610, the crashed source code in the source code file is executed in the test environment to obtain the crash stack information of the test environment.
[0102] In step S620 , the crash stack information of the test environment is compared with the online crash stack information.
[0103] In this method, after the crashed source code is determined from the source code file, the crashed source code in the source code file can be executed in a test environment to obtain the crash stack information of the test environment, and the crash stack information of the test environment is compared with the online crash stack information. This makes it easy to verify whether the crashed source code in the source code file is accurately located, and effectively avoids subsequent modifications to the source code file based on the erroneous crashed source code.
[0104] In one embodiment of the present invention, the source code of the crash in the source code file is executed in a test environment to obtain the crash stack information of the test environment. For example, the execution condition of the code segment that causes the crash is released (the crash did not occur in the development environment and the test environment, and it is very likely that the code segment was not executed under the environmental conditions), so that the code segment can be executed in the test environment, thereby triggering the crash, and checking whether the crash stack is consistent with the online crash stack (since the code has been modified, the instruction position may be different, but the assembly instructions before and after should be consistent). In this way, the source code position of the crash is located and the crash that occurred online is reproduced. Then the developer makes his own modifications to the crash.
[0105] Figure 7 The block diagram of the crash source code location device according to an embodiment of the present invention is schematically shown.
[0106] like Figure 7 As shown, the crash source code locating device 700 includes a source code statement position changing module 710 , a first obtaining module 720 , a second obtaining module 730 , a first determining module 740 , a second determining module 750 and a locating module 760 .
[0107] Specifically, the source code statement position changing module 710 is used to obtain a changed source code file by changing the position of a source code statement in the source code file.
[0108] The first acquisition module 720 is used to acquire a first assembly instruction code file according to the changed source code file.
[0109] The second acquisition module 730 is used to acquire the assembly code of the crash point in the second assembly instruction code file according to the crash stack information, wherein the first assembly instruction code file and the second assembly instruction code file are different.
[0110] The first determining module 740 is configured to determine a position change of the assembly code at the crash point in the first assembly instruction code file according to the assembly code at the crash point in the first assembly instruction code file and the second assembly instruction code file.
[0111] The second determination module 750 is used to determine the crash position of the source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction code file.
[0112] The positioning module 760 is used to locate the crashed source code in the source code file according to the crash position of the source code in the source code file.
[0113] The crash source code locating device 700 can obtain a changed source code file by changing the position of the source code statement in the source code file, obtain a first assembly instruction encoding file according to the changed source code file, obtain the assembly code of the crash point in the second assembly instruction encoding file according to the crash stack information, determine the position change of the assembly code of the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file, determine the crash position of the source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, and locate the crashed source code in the source code file according to the crash position of the source code in the source code file. In this way, the crash source code can be quickly located, the efficiency of locating the crash source code is improved, and the user experience is improved.
[0114] According to an embodiment of the present invention, the crash source code location device 700 can be used to implement Figure 2 The embodiment describes a method for locating a crash source code.
[0115] In some embodiments of the present invention, the above-mentioned source code statement position changing module 710 is configured to include: changing the position of the source code statement in the source code file by inserting new source code to obtain a changed source code file; or changing the position of the source code statement in the source code file by deleting source code to obtain a changed source code file.
[0116] Figure 8A block diagram of a crash source code location device according to another embodiment of the present invention is schematically shown.
[0117] like Figure 8 As shown, the first acquisition module 720 may specifically include a compilation module 721 and a first decompilation module 722 .
[0118] Specifically, the compiling module 721 is used to compile the changed source code file to obtain a binary file of the source code.
[0119] The first decompiling module 722 is used to decompile the binary file of the source code to obtain the first assembly instruction encoding file.
[0120] The first acquisition module 720 can quickly obtain the first assembly instruction code file based on the changed source code file, so as to facilitate the subsequent acquisition of the assembly code of the crash point in the first assembly instruction code file according to the first assembly instruction code file.
[0121] According to an embodiment of the present invention, the first acquisition module 720 can be used to implement Figure 3 The embodiment describes a method for locating a crash source code.
[0122] Fig. 9 A block diagram of a crash source code location device according to another embodiment of the present invention is schematically shown.
[0123] like Fig. 9 As shown, the second acquisition module 730 may specifically include an instruction crash location acquisition module 731 , a second decompiling module 732 and a first assembly code determination module 733 .
[0124] Specifically, the instruction crash position acquisition module 731 is used to acquire the crashed binary file and the instruction crash position in the crashed binary file according to the crash stack information.
[0125] The second decompiling module 732 is used to decompile the crashed binary file to obtain the second assembly instruction code file.
[0126] The first assembly code determination module 733 is used to determine the assembly code of the crash point in the second assembly instruction encoding file according to the instruction crash position in the crashed binary file.
[0127] The second acquisition module 730 can obtain the crashed binary file and the instruction crash position in the crashed binary file according to the crash stack information, and then decompile the crashed binary file to obtain the second assembly instruction coding file, and determine the assembly code of the crash point in the second assembly instruction coding file according to the instruction crash position in the crashed binary file. In this way, the assembly code of the crash point in the second assembly instruction coding file associated with the so library can be quickly determined, so that the position change of the assembly code of the crash point in the first assembly instruction coding file can be determined according to the assembly code of the crash point in the second assembly instruction coding file.
[0128] According to an embodiment of the present invention, the second acquisition module 730 can be used to implement Figure 4 The embodiment describes a method for locating a crash source code.
[0129] Fig.10 A block diagram of a crash source code location device according to another embodiment of the present invention is schematically shown.
[0130] like Fig.10 As shown, the first determining module 740 may specifically include a second assembly code determining module 741 and an assembly code position change determining module 742 .
[0131] Specifically, the second assembly code determining module 741 is used to determine the assembly code of the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the second assembly instruction encoding file.
[0132] The assembly code position change determination module 742 is used to determine the position change of the assembly code at the crash point in the first assembly instruction encoding file according to the position of the assembly code at the crash point in the first assembly instruction encoding file and the position of the assembly code at the crash point in the second assembly instruction encoding file.
[0133] The first determination module 740 can determine the assembly code of the crash point in the first assembly instruction coding file based on the assembly code of the crash point in the second assembly instruction coding file, and then determine the position change of the assembly code of the crash point in the first assembly instruction coding file based on the position of the assembly code of the crash point in the first assembly instruction coding file and the position of the assembly code of the crash point in the second assembly instruction coding file. In this way, it can be quickly determined whether the position of the assembly code of the crash point in the first assembly instruction coding file has changed due to changing the position of the source code statement in the source code file.
[0134] According to an embodiment of the present invention, the first determination module 740 can be used to implement Figure 5 The embodiment describes a method for locating a crash source code.
[0135] In some embodiments of the present invention, the second determination module 750 is configured to determine the crash position of the source code in the source code file according to the position where the new code is inserted or the position where the source code is deleted in the source code file when the position of the assembly code of the crash point in the first assembly instruction encoding file changes.
[0136] Fig.11 A block diagram of a crash source code location device according to another embodiment of the present invention is schematically shown.
[0137] like Fig.11 As shown, the crash source code location device 700 may further include an execution module 770 and a comparison module 780 .
[0138] Specifically, the execution module 770 is used to execute the crashed source code in the source code file in the test environment to obtain the crash stack information of the test environment.
[0139] The comparison module 780 is used to compare the crash stack information of the test environment with the online crash stack information.
[0140] In the crash source code locating device 700, after the crashed source code is determined from the source code file, the crashed source code in the source code file can be executed in a test environment to obtain the crash stack information of the test environment, and the crash stack information of the test environment is compared with the online crash stack information. This can facilitate verification of whether the crashed source code in the source code file is accurately located, and effectively avoid subsequent modifications to the source code file based on the erroneous crashed source code.
[0141] According to an embodiment of the present invention, the crash source code location device 700 can be used to implement Figure 6 The embodiment describes a method for locating a crash source code.
[0142] Since each module of the crash source code location device 700 of the exemplary embodiment of the present invention can be used to implement the above 2~ Figure 6 The steps of the exemplary embodiment of the crash source code location method are described, so for details not disclosed in the embodiment of the device of the present invention, please refer to the above-mentioned embodiment of the crash source code location method of the present invention.
[0143] It is understandable that the source code statement position change module 710, the first acquisition module 720, the compilation module 721, the first decompilation module 722, the second acquisition module 730, the instruction crash position acquisition module 731, the second decompilation module 732, the first assembly code determination module 733, the first determination module 740, the second assembly code determination module 741, the assembly code position change determination module 742, the second determination module 750, the positioning module 760, the execution module 770, and the comparison module 780 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the source code statement position changing module 710, the first acquisition module 720, the compilation module 721, the first decompilation module 722, the second acquisition module 730, the instruction crash position acquisition module 731, the second decompilation module 732, the first assembly code determination module 733, the first determination module 740, the second assembly code determination module 741, the assembly code position change determination module 742, the second determination module 750, the positioning module 760, the execution module 770, and the comparison module 780 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented in hardware or firmware in any other reasonable way of integrating or packaging the circuit, or in an appropriate combination of software, hardware and firmware. Alternatively, at least one of the source code statement position changing module 710, the first acquisition module 720, the compilation module 721, the first decompilation module 722, the second acquisition module 730, the instruction crash position acquisition module 731, the second decompilation module 732, the first assembly code determination module 733, the first determination module 740, the second assembly code determination module 741, the assembly code position change determination module 742, the second determination module 750, the positioning module 760, the execution module 770, and the comparison module 780 can be at least partially implemented as a computer program module, and when the program is run by a computer, the function of the corresponding module can be executed.
[0144] Reference below Fig.12 , which shows a schematic diagram of the structure of a computer system 1200 of an electronic device suitable for implementing an embodiment of the present invention. Fig.12 The computer system 1200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0145] like Fig.12As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. Various programs and data required for system operation are also stored in the RAM 1203. The CPU 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0146] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that a computer program read therefrom is installed into the storage section 1208 as needed.
[0147] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1209, and / or installed from a removable medium 1211. When the computer program is executed by a central processing unit (CPU) 1201, the above-mentioned functions defined in the system of the present application are executed.
[0148] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0150] The units involved in the embodiments of the present invention may be implemented by software or hardware, and the units described may also be arranged in a processor. The names of these units do not, in some cases, limit the units themselves.
[0151] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the crash source code location method described in the above embodiment.
[0152] For example, the electronic device can implement Figure 2 As shown in: In step S210, by changing the position of the source code statement in the source code file, a changed source code file is obtained. In step S220, according to the changed source code file, a first assembly instruction encoding file is obtained. In step S230, according to the crash stack information, the assembly code of the crash point in the second assembly instruction encoding file is obtained, and the first assembly instruction encoding file and the second assembly instruction encoding file are different. In step S240, according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file, the position change of the assembly code of the crash point in the first assembly instruction encoding file is determined. In step S250, according to the position change of the assembly code of the crash point in the first assembly instruction encoding file, the crash position of the source code in the source code file is determined. In step S260, according to the crash position of the source code in the source code file, the source code that crashed in the source code file is located.
[0153] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0154] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation of the present invention.
[0155] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.
[0156] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for locating a crash source code, characterized in that: The method includes: By changing the position of the source code statement in the source code file, a changed source code file is obtained; According to the changed source code file, obtaining a first assembly instruction encoding file; Obtaining, according to the crash stack information, an assembly code of a crash point in a second assembly instruction encoding file, wherein the first assembly instruction encoding file and the second assembly instruction encoding file are different; Determining a position change of the assembly code at the crash point in the first assembly instruction code file according to the assembly code at the crash point in the first assembly instruction code file and the second assembly instruction code file; Determining a crash position of a source code in the source code file according to a position change of the assembly code of the crash point in the first assembly instruction encoding file; Locating the crashed source code in the source code file according to the crash position of the source code in the source code file; Wherein, determining the crash position of the source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction encoding file includes: When the position of the assembly code of the crash point in the first assembly instruction encoding file changes, the crash position of the source code in the source code file is determined according to the position where the new code is inserted or the position where the source code is deleted in the source code file.
2. The method according to claim 1, characterized in that By changing the position of the source code statement in the source code file, the changed source code file is obtained, including: Changing the position of source code statements in the source code file by inserting new source code to obtain a changed source code file; or The position of the source code statement in the source code file is changed by deleting the source code to obtain a changed source code file.
3. The method according to claim 1, characterized in that According to the changed source code file, obtaining the first assembly instruction encoding file includes: Compiling the changed source code file to obtain a binary file of the source code; Decompile the binary file of the source code to obtain the first assembly instruction encoding file.
4. The method according to claim 1, characterized in that: Acquiring the assembly code of the crash point in the second assembly instruction encoding file according to the crash stack information includes: According to the crash stack information, obtaining a crashed binary file and an instruction crash position in the crashed binary file; Decompiling the crashed binary file to obtain the second assembly instruction encoding file; According to the instruction crash position in the crashed binary file, the assembly code of the crash point in the second assembly instruction encoding file is determined.
5. The method according to claim 1, characterized in that: Determining a position change of the assembly code at the crash point in the first assembly instruction encoding file according to the assembly code at the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file includes: Determine the assembly code of the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the second assembly instruction encoding file; A position change of the assembly code at the crash point in the first assembly instruction encoding file is determined according to the position of the assembly code at the crash point in the first assembly instruction encoding file and the position of the assembly code at the crash point in the second assembly instruction encoding file.
6. The method according to claim 1, characterized in that The crash stack information is online crash stack information, and the method further includes: Executing the crashed source code in the source code file in the test environment to obtain crash stack information of the test environment; The crash stack information of the test environment is compared with the online crash stack information.
7. A crash source code location device, characterized in that: The device includes: A source code statement position changing module is used to obtain a changed source code file by changing the position of the source code statement in the source code file; A first acquisition module, used for acquiring a first assembly instruction encoding file according to the changed source code file; A second acquisition module is used to acquire the assembly code of the crash point in a second assembly instruction encoding file according to the crash stack information, wherein the first assembly instruction encoding file and the second assembly instruction encoding file are different; A first determining module, configured to determine a position change of the assembly code at the crash point in the first assembly instruction encoding file according to the assembly code of the crash point in the first assembly instruction encoding file and the second assembly instruction encoding file; A second determination module is used to determine the crash position of the source code in the source code file according to the position change of the assembly code of the crash point in the first assembly instruction code file; A positioning module, used for locating the crashed source code in the source code file according to the crash position of the source code in the source code file; The second determination module is also used to determine the crash position of the source code in the source code file according to the position of inserting new code or deleting source code in the source code file when the position of the assembly code of the crash point in the first assembly instruction encoding file changes.
8. An electronic device, comprising: one or more processors; as well as A storage device, used for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the method according to any one of claims 1 to 6.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Application crash log acquisition method and apparatus
CN105630659A
System for module selection in software application testing including generating a test executable based on an availability of root access
US9268670B1