Anomalous data acquisition method and apparatus, device, and computer-readable storage medium
By configuring the target acquisition policy in the executor, capturing exception data and generating exception data files, the problem of time-consuming locating exceptions when the software runs crash is solved, improving processing efficiency and helping developers quickly distinguish responsibilities.
Patent Information
- Application Number
- PCT/CN2024/081918
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-10-31
- Filing Date
- 2024-03-15
- Publication Date
- 2025-05-08
AI Technical Summary
When the software under the release version crashes, it is difficult for the existing technology to quickly locate the abnormality, resulting in a long time and low processing efficiency.
Generate an exception data file by preconfiguring the target acquisition policy in the executor, capturing the exception data when the run crashes and writing it to a file. This file represents the call situation of a function that has an exception at runtime.
It quickly captures exception data that characterizes the abnormal function call situation when the execution program crashes, helps developers quickly locate exceptions and distinguish responsibilities, and improves processing efficiency.
Smart Images

Figure CN2024081918_08052025_PF_FP_ABST
Abstract
Description
Abnormal data acquisition method, device, equipment and computer-readable storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This disclosure is based on and claims the priority of a Chinese patent application with application number 202311430335.2, application date October 31, 2023, and invention name “Abnormal data acquisition method, device, equipment and computer-readable storage medium”. The entire content of the Chinese patent application is hereby incorporated into this disclosure as a reference. Technical Field
[0003] The present disclosure relates to the field of computer technology, and in particular to a method, apparatus, device, and computer-readable storage medium for acquiring abnormal data. Background Art
[0004] When a released version of software crashes during operation, the only way to locate the anomaly is to analyze the software's corresponding source code, which is time-consuming and inefficient.
[0005] Summary of the Invention
[0006] To solve the above technical problems, the embodiments of the present disclosure hope to provide a method, apparatus, device and computer-readable storage medium for acquiring abnormal data, which solve the problems of long processing time and low processing efficiency in related technologies.
[0007] The technical solution of the present disclosure is achieved as follows:
[0008] A method for obtaining abnormal data, comprising:
[0009] Based on a target acquisition strategy pre-configured in an execution program, abnormal data generated when the execution program crashes during operation is captured; the abnormal data is written into a file to obtain an abnormal data file; wherein the abnormal data file represents the calling of abnormal functions of the execution program during operation.
[0010] It can be understood that through the target acquisition strategy, abnormal data representing the call of abnormal functions when the execution program crashes can be quickly captured; writing the abnormal data into a file can help developers quickly locate the abnormality and clarify the responsibility.
[0011] In some embodiments, the abnormal data acquisition method also includes: determining the target acquisition strategy; integrating the target acquisition strategy into the initial program corresponding to the business software; adjusting the engineering properties of the initial program to obtain the execution program, so that the execution program generates a running crash file when the execution program crashes.
[0012] It can be understood that adjusting the engineering properties of the initial program can enable the executable program under the release version to generate a crash file when it crashes during operation, so as to capture the exception; integrating the pre-set target acquisition strategy into the initial program can locate and capture the exception data including the call stack data after capturing the exception.
[0013] In some embodiments, determining the target acquisition strategy includes: determining the thread type corresponding to the execution program; determining the data capture logic, exception capture logic and write interface corresponding to different thread types; the exception capture logic is used to detect whether the execution program crashes; the write interface is used to write the captured exception data into a file; and determining the target acquisition strategy based on the data capture logic, the exception capture logic and the write interface corresponding to different thread types.
[0014] It can be understood that the data capture logic is set for different thread types. Therefore, the target acquisition strategy is determined based on the data capture logic, exception capture logic and write interface corresponding to different thread types. The target acquisition strategy can be used to capture exception data of different types of threads in a targeted manner, thereby improving the accuracy of exception data capture.
[0015] In some embodiments, the thread types include first-class threads and second-class threads; the target acquisition strategy is determined based on the data capture logic, the exception capture logic and the write interface corresponding to the different thread types, including: determining the first capture strategy corresponding to the first-class thread based on the data capture logic and the exception capture logic corresponding to the first-class thread; determining the second capture strategy corresponding to the second-class thread based on the data capture logic and the exception capture logic corresponding to the second-class thread; and determining the target acquisition strategy based on the first capture strategy, the second capture strategy and the write interface.
[0016] It can be understood that the first capture strategy corresponding to the first type of thread, the second capture strategy corresponding to the second type of thread and the write interface are integrated to obtain the target acquisition strategy; in this way, it is possible to realize exception capture of different types of threads, location and capture of exception data, and write the captured exception data into a file.
[0017] In some embodiments, the second type of thread includes a first thread and a second thread; the first thread is included in the thread pool corresponding to the execution program, and the second thread is not included in the thread pool; the second capture strategy corresponding to the second type of thread is determined based on the data capture logic and the exception capture logic corresponding to the second type of thread, including: determining the data capture logic of the first thread as the first data capture logic, and determining the capture strategy of the first thread based on the first data capture logic and the exception capture logic; determining the data capture logic of the second thread as the second data capture logic, and determining the capture strategy of the second thread based on the second data capture logic and the exception capture logic.
[0018] It can be understood that setting different data capture logic for different threads in the same class can be compatible with different scenarios where threads of the same class are located, thereby improving the applicability of exception capture.
[0019] In some embodiments, the method of capturing abnormal data generated by the execution program when the execution program crashes during operation based on a target acquisition strategy pre-configured in the execution program includes: determining the operation crash file generated by the execution program when the execution program crashes during operation based on the abnormal capture logic in the target acquisition strategy; and capturing the abnormal data based on the operation crash file and the target acquisition strategy.
[0020] It can be understood that the exception is captured first, and then the capture logic corresponding to the abnormal thread is determined to capture the call stack data of the abnormal thread; in this way, the call stack data of the abnormal thread can be printed.
[0021] In some embodiments, the thread types corresponding to the execution program include first-class threads and second-class threads; capturing the exception data based on the running crash file and the target acquisition strategy includes: when the running crash file represents a first-class thread exception in the execution program, capturing the exception data based on the first capture strategy in the target acquisition strategy; when the running crash file represents a second-class thread exception in the execution program, capturing the exception data based on the second capture strategy in the target acquisition strategy.
[0022] It can be understood that when the first type of thread is abnormal, the first capture strategy is used to print the call stack data; when the second type of thread is abnormal, the second capture strategy is used to print the call stack data; in this way, different capture strategies are used for different types of threads to improve the accuracy of exception capture.
[0023] In some embodiments, the second type of thread includes a first thread and a second thread; the first thread is included in the thread pool corresponding to the execution program, and the second thread is not included in the thread pool; the capturing of the exception data based on the second capture strategy in the target acquisition strategy when the running crash file represents an exception of the second type of thread in the execution program includes: capturing the exception data based on the capture strategy of the first thread in the second capture strategy when the running crash file represents an exception of the first thread in the execution program; capturing the exception data based on the capture strategy of the second thread in the second capture strategy when the running crash file represents an exception of the second thread in the execution program.
[0024] It can be understood that adopting different capture strategies for different threads in the same class can improve the accuracy of exception capture.
[0025] In some embodiments, the exception data includes call stack data; writing the exception data into a file to obtain the exception data file includes: writing the call stack data into a file based on a write interface in the target acquisition strategy to obtain the exception data file.
[0026] It is understandable that writing call stack data to a file can help developers quickly locate exceptions and clarify responsibilities.
[0027] In some embodiments, in the case of an algorithm corresponding to the execution program at the point where the execution program crashes, the first line in the exception data file records the code path of the algorithm, and the other lines in the exception data file except the first line record the code path of the software corresponding to the execution program; in the case of software corresponding to the execution program at the point where the execution program crashes, all lines in the exception data file record the code path of the software.
[0028] It is understandable that depending on the location of the crash, abnormal data files containing different data will be obtained, so that software developers, algorithm personnel and other personnel can clearly and accurately distinguish the responsibilities.
[0029] In some embodiments, adjusting the project properties of the initial program includes: setting the debugging information format in the project properties to a program database; or setting the generate debugging information option in the project properties to generate debugging information.
[0030] It can be understood that the engineering properties of the initial program are adjusted so that the executable program under the release version generates a crash file when it crashes, so that it can be found through the Windows API function when it crashes.
[0031] On the other hand, an embodiment of the present disclosure provides an abnormal data acquisition device, which includes: a processing module for capturing abnormal data generated when the execution program crashes during operation based on a target acquisition strategy pre-configured in the execution program; a writing module for writing the abnormal data into a file to obtain the abnormal data file; wherein, the abnormal data file represents the calling situation of abnormal functions during the operation of the execution program.
[0032] A computer device comprising: a processor, a memory, and a communication bus;
[0033] The communication bus is used to realize the communication connection between the processor and the memory;
[0034] The processor is configured to execute the computer program in the memory to implement the steps of the above method.
[0035] A computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the above method.
[0036] The exception data acquisition method, apparatus, device, and computer-readable storage medium provided by the embodiments of the present disclosure can capture exception data generated by an execution program when it crashes, based on a target acquisition strategy pre-configured in the execution program; write the exception data into a file to obtain an exception data file; wherein the exception data file represents the call status of the function with abnormalities during the execution of the execution program. In this way, through the target acquisition strategy, exception data representing the call status of the function with abnormalities when the execution program crashes can be quickly captured; writing the exception data into a file can help developers quickly locate the exception and clarify the responsibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] FIG1 is a flow chart of a method for acquiring abnormal data according to an embodiment of the present disclosure;
[0038] FIG2 is a second flow chart of a method for acquiring abnormal data provided by an embodiment of the present disclosure;
[0039] FIG3 is a flow chart of a target acquisition strategy in a method for determining abnormal data acquisition provided by an embodiment of the present disclosure;
[0040] FIG4 is a schematic structural diagram of an abnormal data acquisition device provided by an embodiment of the present disclosure;
[0041] FIG5 is a schematic structural diagram of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0042] The technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present disclosure.
[0043] It should be understood that the “embodiments of the present disclosure” or “the aforementioned embodiments” mentioned throughout the specification mean that the specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present disclosure. Therefore, “in the embodiments of the present disclosure” or “in the aforementioned embodiments” appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial numbers of the above-mentioned embodiments of the present disclosure are for description only and do not represent the advantages and disadvantages of the embodiments.
[0044] Unless otherwise specified, when an electronic device performs any step in the embodiments of the present disclosure, the processor of the electronic device may perform the step. It is also worth noting that the embodiments of the present disclosure do not limit the order in which the electronic device performs the following steps. In addition, the methods used to process data in different embodiments may be the same method or different methods. It should also be noted that any step in the embodiments of the present disclosure can be independently executed by the electronic device, that is, when the electronic device performs any step in the following embodiments, it can be independent of the execution of other steps.
[0045] It should be understood that the specific embodiments described herein are only used to illustrate the present disclosure and are not intended to limit the present disclosure.
[0046] The present disclosure provides an abnormal data acquisition method, which can be applied to a processor of a computer device. As shown in FIG1 , the method includes the following steps 101 to 102:
[0047] Step 101: Based on a target acquisition strategy pre-configured in an execution program, abnormal data generated when the execution program crashes is captured.
[0048] Here, the execution program can be a program of the business software under the release version; illustratively, the execution program can be the code of the business software under the release version. The business software can be software for processing business; illustratively, the business software can be a software application (Application, APP) implemented based on C++. The target acquisition strategy is used to locate exceptions, as well as to locate and capture the function call situation of the execution program when it crashes during operation, and to reflect it in the form of a file. The exception data is used to characterize the call situation of the function with exceptions when the execution program is running; illustratively, the exception data can be call stack data.
[0049] In a feasible implementation method, a target acquisition strategy can be first adopted to determine whether the execution program crashes during the business processing process; when it is determined that the execution program crashes during the business processing process, the target acquisition strategy is adopted to locate and capture the abnormal function call situation, and the captured data is used as abnormal data.
[0050] Step 102: Write the abnormal data into a file to obtain an abnormal data file; wherein the abnormal data file represents the calling of abnormal functions when the execution program is running.
[0051] Here, the exception data file is used to represent the call status of abnormal functions during the execution of the program. Exemplarily, the exception data file may include, but is not limited to, a call stack file and a dump file. The call stack file may include all data in the call stack, such as the function with the abnormality in the entire code flow corresponding to the execution program, the line number of the abnormal function, the name of the abnormal function, and the method of the abnormal function; the dump file may include thread data, module data, and exception data.
[0052] In a feasible implementation, the abnormal data file may be written into a file in a text format of txt to obtain the abnormal data file.
[0053] It should be noted that it is impossible to accurately locate the exception in the released version; therefore, in order to accurately locate the exception, the embodiment of the present disclosure specifically sets up a target acquisition strategy to capture abnormal data that characterizes the call of functions with abnormalities when the execution program crashes; and, in order to help developers quickly locate the exception and clarify responsibilities, the abnormal data is written into a file.
[0054] It can be understood that through the target acquisition strategy, abnormal data representing the call of abnormal functions when the execution program crashes can be quickly captured; writing the abnormal data into a file can help developers quickly locate the abnormality and clarify the responsibility.
[0055] The present disclosure provides an abnormal data acquisition method, which can be applied to a processor of a computer device. As shown in FIG2 , the method includes the following steps 201 to 205:
[0056] Step 201: Determine the target acquisition strategy.
[0057] In one feasible implementation, the target acquisition strategy can be determined based on the exception capture logic, data capture logic, and write interface. The exception capture logic is used to capture exceptions; the data capture logic is used to locate and capture exception data (call stack data); and the write interface is used to write the captured exception data into a file.
[0058] Step 202: Integrate the target acquisition strategy into the initial program corresponding to the business software.
[0059] Here, the initial program may refer to the code of the business software to be released.
[0060] Generally, the executable code under the release version does not have the ability to capture call stack data. Therefore, the set target acquisition strategy can be integrated into the code under the release version to obtain the initial program with the ability to capture call stack data.
[0061] Step 203: Adjust the engineering properties of the initial program to obtain the execution program, so that the execution program generates a crash file when the execution program crashes.
[0062] Here, project properties may refer to various properties of the initial program; illustratively, project properties may include debug information formats and debug information generation options, as well as properties for linkers, manifest tools, events, and custom properties. A runtime crash file is used to represent the path of executed code and basic data; it may include function names, variable names, source code file names, line numbers, and so on. For example, the runtime crash file may be a Program Database File (PDB file).
[0063] The purpose of adjusting the project properties of the initial program is to generate a crash file (PDB file) when the executable program under the release version crashes, so that it can be found through Windows API functions when the crash occurs.
[0064] In one embodiment, the specific implementation method of "adjusting the project properties of the initial program" in step 203 can be: setting the debugging information format in the project properties to program database; or setting the generate debugging information option in the project properties to generate debugging information.
[0065] In a feasible implementation, the debug information format in the project properties may be set to program database ( / Zi); or the generate debug information option in the project properties may be set to generate debug information ( / DEBUG).
[0066] It can be understood that adjusting the project properties of the initial program can cause the executable program under the release version to generate a crash file when it crashes, so that it can be found through the Windows API function when it crashes.
[0067] Step 204: Based on the target acquisition strategy pre-configured in the execution program, capture abnormal data generated when the execution program crashes.
[0068] Step 205: Write the abnormal data into a file to obtain an abnormal data file; wherein the abnormal data file represents the calling of abnormal functions when the execution program is running.
[0069] Here, the above steps 204 to 205 correspond to the above steps 101 to 102 respectively, and when implementing, reference may be made to the specific implementation of the above steps 101 to 102.
[0070] It can be understood that adjusting the engineering properties of the initial program can enable the executable program under the release version to generate a crash file when it crashes during operation, so as to capture the exception; integrating the pre-set target acquisition strategy into the initial program can locate and capture the call stack data after capturing the exception.
[0071] In some embodiments, the above step 201 can be implemented through the following steps 2011 to 2013:
[0072] Step 2011: Determine the thread type corresponding to the execution program.
[0073] Here, thread types can include first-class threads and second-class threads. For example, the first-class thread may refer to the main thread, and the second-class thread may refer to the child thread. Furthermore, the second-class thread can be divided into first and second threads based on different scenarios. For example, the second class can be divided into first and second threads based on the relationship between the child thread and the thread pool. The first thread may refer to a child thread included in the thread pool of the business software, and the second thread may refer to a child thread not included in the thread pool of the business software.
[0074] Step 2012: Determine the data capture logic, exception capture logic, and write interface corresponding to different thread types; the exception capture logic is used to detect whether the execution program crashes; the write interface is used to write the captured exception data into a file.
[0075] Here, the data capture logic is used to print call stack data when a business crashes. Different thread types have different data processing logic. Setting different data capture logic for each thread type allows for targeted exception data capture, improving accuracy. The exception capture logic is used to detect whether the executing program has crashed. The write interface is used to write captured exception data to a file.
[0076] In one feasible implementation, data capture strategies corresponding to different thread types can be determined separately; the same exception capture logic corresponding to different thread types can be determined; and the same write interface corresponding to different thread types can be determined. For example, the exception capture logic can be a CatlCaptureDump function, and the write interface can be a CatlMiniDump function.
[0077] Step 2013: Determine the target acquisition strategy based on the data capture logic, the exception capture logic, and the write interface corresponding to the different thread types.
[0078] In a feasible implementation, the data capture logic corresponding to different thread types can be integrated with the exception capture logic to obtain the capture logic corresponding to different thread types; the capture logic corresponding to different thread types can be integrated with the write interface to obtain the target acquisition strategy.
[0079] The data capture logic corresponding to different thread types is integrated with the exception capture logic to obtain the capture logic corresponding to different thread types. This is to ensure that the capture logic corresponding to different thread types not only includes the functions of the data capture logic, but also the functions of the exception capture logic. In this way, when an exception occurs in a different thread type, the capture logic corresponding to the different thread types can be used to capture the exception and locate and capture the abnormal data. The capture logic corresponding to different thread types is integrated with the write interface so that after the abnormal data is captured by the capture logic corresponding to the different thread types, the write interface can be called to write the abnormal data to a file, thereby obtaining an abnormal data file.
[0080] It can be understood that the data capture logic is set for different thread types. Therefore, the target acquisition strategy is determined based on the data capture logic, exception capture logic and write interface corresponding to different thread types. The target acquisition strategy can be used to capture exception data of different types of threads in a targeted manner, thereby improving the accuracy of exception data capture.
[0081] In some embodiments, when the thread type includes first-type threads and second-type threads, step 2013 may be implemented by the following steps 2013a to 2013c:
[0082] Step 2013a: Determine a first capture strategy corresponding to the first type of thread based on the data capture logic and the exception capture logic corresponding to the first type of thread.
[0083] Here, the first capture strategy includes capturing exceptions caused by a crash of an execution program during business processing, and locating and capturing exception data of the first type of thread.
[0084] In one feasible implementation, the data capture logic corresponding to the first type of thread can be Qapplication in Qt (an application development framework developed by Qt), and the exception capture logic can be CatlCaptureDump. In this case, the first capture strategy can be determined based on Qapplication and CatlCaptureDump. CatlCaptureDump implements exception capture based on Windows' __try{}__except{}.
[0085] Step 2013b: Determine a second capture strategy corresponding to the second type of thread based on the data capture logic and the exception capture logic corresponding to the second type of thread.
[0086] Here, the second capture strategy includes capturing exceptions caused by a crash of the execution program during business processing, and locating and capturing exception data of the second type of thread.
[0087] In a feasible implementation, the data capture logic corresponding to the second type of thread can be Qrunnable or QThread in Qt, and the exception capture logic can be CatlCaptureDump; at this time, the second capture strategy can be determined based on CatlCaptureDump and Qrunnable, or based on CatlCaptureDump and QThread.
[0088] Step 2013c: Determine the target acquisition strategy based on the first capture strategy, the second capture strategy, and the write interface.
[0089] In a feasible implementation, since both the first capture strategy and the second capture strategy include exception capture logic, the first capture strategy, the second capture strategy and the write interface can be integrated through the exception capture logic to obtain the target acquisition strategy.
[0090] It can be understood that both the first capture strategy and the second capture strategy include exception capture logic. Through the exception capture logic, the first capture strategy corresponding to the first type of thread, the second capture strategy corresponding to the second type of thread and the write interface are integrated to obtain the target acquisition strategy; in this way, exception capture of different types of threads, positioning and capture of exception data, and writing the captured exception data into a file can be achieved.
[0091] In some embodiments, the second type of thread includes a first thread and a second thread; the first thread is included in a thread pool corresponding to the executing program, and the second thread is not included in the thread pool; in this case, step 2013b can be implemented by the following steps A to B:
[0092] Step A: Determine the data capture logic of the first thread as the first data capture logic, and determine the capture strategy of the first thread based on the first data capture logic and the exception capture logic.
[0093] Here, the data capture logic of the first thread may be Qrunnable in Qt. At this time, the capture strategy of the first thread may be determined based on Qrunnable and CatlCaptureDump; the capture strategy of the first thread may be CatlRunnable.
[0094] Step B: determining the data capture logic of the second thread as the second data capture logic, and determining the capture strategy of the second thread based on the second data capture logic and the exception capture logic.
[0095] Here, the data capture logic of the second thread can be Qrunnable in Qt. At this time, the capture strategy of the second thread can be determined based on QThread and CatlCaptureDump; the capture strategy of the second thread can be CatlThread.
[0096] During implementation, as shown in Figure 3, Qt can be used to develop business software. Based on Qthread35 and CatlCaptureDump36, CatlThread32 is determined. All instances of Qthread35 are replaced with CatlThread32 to print the call stack data (exceptional data) of the child threads not included in the thread pool when the business software crashes. Based on Qrunnable37 and CatlCaptureDump36, CatlRunnable33 is determined. All instances of Qrunnable37 are replaced with CatlRunnable33 to print the call stack data of the child threads included in the thread pool when the business software crashes. Based on Qapplication34 and CatlCaptureDump36, CatlApplication31 is determined. All instances of Qapplication34 are replaced with CatlApplication31 to print the call stack data of the main thread when the business software crashes. CatlCaptureDump36 combines CatlThread32, CatlRunnable33, CatlApplication31, and CatlMiniDump38 to create a target acquisition strategy. After capturing call stack data, CatlMiniDump38 is called to write the captured call stack data to a file. For example, if the business software interface crashes, CatlApplication31 in the target acquisition strategy can be used to print the call stack data. If the business logic crashes, such as when an H5 (fifth-generation Hypertext Markup Language 5) refresh exception occurs, CatlThread32 can be used to print the call stack data. Furthermore, to address thread jamming issues, a thread pool is set up, so if the business logic crashes, CatlRunnable33 can be used to print the call stack data.
[0097] It should be noted that if there is no thread pool set in the business software, the target acquisition strategy can be determined based on CatlApplication31, CatlThread32 and CatlMiniDump38; if there is a thread pool set in the business software and all child threads are included in the thread pool, the target acquisition strategy can be determined based on CatlApplication31, CatlRunnable33 and CatlMiniDump38; if there is a thread pool set in the business software and not all child threads are included in the thread pool, the target acquisition strategy can be determined based on CatlApplication31, CatlRunnable33, CatlThread32 and CatlMiniDump38.
[0098] It can be understood that setting different data capture logic for threads in the same class can be compatible with different scenarios where threads of the same class exist, thereby improving the applicability of abnormal data capture.
[0099] In some embodiments, the above step 204 may be implemented by the following steps 2041 to 2042:
[0100] Step 2041: Based on the exception capture logic in the target acquisition strategy, determine the operation crash file generated when the execution program crashes.
[0101] In a feasible implementation, based on CatlCaptureDump (exception capture logic), Windows' __try{}__except{} can be used to capture exceptions and obtain a pdb file (run crash file).
[0102] Step 2042: Capture the abnormal data based on the running crash file and the target acquisition strategy.
[0103] In a feasible implementation, the thread type of the abnormal thread can be determined based on the running crash file; the capture strategy corresponding to the abnormal thread is determined from the target acquisition strategy to capture the call stack data (exception data) of the abnormal thread.
[0104] It can be understood that the exception is captured first, and then the capture logic corresponding to the abnormal thread is determined to capture the call stack data of the abnormal thread; in this way, the call stack data of the abnormal thread can be printed.
[0105] In some embodiments, the above step 2042 may be implemented by the following steps 2042a to 2042b:
[0106] Step 2042a: When the running crash file indicates a first type of thread exception in the executing program, the exception data is captured based on a first capture strategy in the target acquisition strategy.
[0107] In a feasible implementation, when the pdb file indicates that the main thread is abnormal, call stack data is captured based on CatlApplication.
[0108] Step 2042b: When the running crash file indicates a second type of thread exception in the executing program, the exception data is captured based on the second capture strategy in the target acquisition strategy.
[0109] In one embodiment, the second type of thread includes a first thread and a second thread; the first thread is included in the thread pool corresponding to the execution program, and the second thread is not included in the thread pool; the specific implementation method of step 2042b can be: when the running crash file represents that the first thread in the execution program is abnormal, the abnormal data is captured based on the capture strategy of the first thread in the second capture strategy; when the running crash file represents the second thread in the execution program, the abnormal data is captured based on the capture strategy of the second thread in the second capture strategy.
[0110] In a feasible implementation, when the pdb file indicates that a child thread not included in the thread pool is abnormal, call stack data is captured based on CatlThread; further, when the pdb file indicates that a child thread in the thread pool is abnormal, call stack data is captured based on CatlRunnable.
[0111] It can be understood that when the first type of thread is abnormal, the first capture strategy is used to print the call stack data; when the second type of thread is abnormal, the second capture strategy is used to print the call stack data; in this way, different capture strategies are used for different threads to improve the accuracy of exception capture.
[0112] In some embodiments, the specific implementation of step 205 may be: based on the write interface in the target acquisition strategy, the call stack data is written into a file to obtain the exception data file.
[0113] Here, the write interface is used to write the captured exception data into a file; illustratively, the write interface may be CatlMiniDump.
[0114] In one feasible implementation, the CatlMiniDump function in the target acquisition strategy can be used to write the abnormal data file into a txt file to obtain the abnormal data file. This helps developers quickly locate the abnormality and clarify the responsibility.
[0115] In some embodiments, in the case of an algorithm corresponding to the execution program at the point where the execution program crashes, the first line in the exception data file records the code path of the algorithm, and the other lines in the exception data file except the first line record the code path of the software corresponding to the execution program; in the case of software corresponding to the execution program at the point where the execution program crashes, all lines in the exception data file record the code path of the software.
[0116] During implementation, if the program crashes within the algorithm, the first line in the exception data file records the algorithm's code path, and the remaining lines record the software's code path. If the program crashes within the software, all lines in the exception data file record the software's code path. This way, software developers, algorithm developers, and others can clearly identify the crash exception and the team responsible by opening the exception data file.
[0117] FIG4 is a schematic diagram of the structure of an abnormal data acquisition device provided by an embodiment of the present disclosure. As shown in FIG4 , the abnormal data acquisition device 400 includes: a processing module 410 and a writing module 420, wherein:
[0118] The processing module 410 is configured to capture abnormal data generated when the execution program crashes based on a target acquisition strategy pre-configured in the execution program;
[0119] The writing module 420 is configured to write the abnormal data into a file to obtain an abnormal data file; wherein the abnormal data file represents the calling of abnormal functions when the execution program is running.
[0120] In some embodiments, the processing module 410 is specifically used to: determine the target acquisition strategy; integrate the target acquisition strategy into the initial program corresponding to the business software; adjust the engineering properties of the initial program to obtain the execution program, so that the execution program generates a running crash file when the execution crashes.
[0121] In some embodiments, the processing module 410 is specifically used to: determine the thread type corresponding to the execution program; determine the data capture logic, exception capture logic and write interface corresponding to different thread types; the exception capture logic is used to detect whether the execution program crashes; the write interface is used to write the captured exception data into a file; based on the data capture logic, the exception capture logic and the write interface corresponding to different thread types, determine the target acquisition strategy.
[0122] In some embodiments, the thread types include first-class threads and second-class threads; the processing module 410 is specifically used to: determine the first capture strategy corresponding to the first-class threads based on the data capture logic and the exception capture logic corresponding to the first-class threads; determine the second capture strategy corresponding to the second-class threads based on the data capture logic and the exception capture logic corresponding to the second-class threads; determine the target acquisition strategy based on the first capture strategy, the second capture strategy and the write interface.
[0123] In some embodiments, the second type of thread includes a first thread and a second thread; the first thread is included in the thread pool corresponding to the execution program, and the second thread is not included in the thread pool; the processing module 410 is specifically used to: determine the data capture logic of the first thread as the first data capture logic, and determine the capture strategy of the first thread based on the first data capture logic and the exception capture logic; determine the data capture logic of the second thread as the second data capture logic, and determine the capture strategy of the second thread based on the second data capture logic and the exception capture logic.
[0124] In some embodiments, the processing module 410 is specifically used to: determine the operation crash file generated by the execution program when the execution crashes based on the exception capture logic in the target acquisition strategy; and capture the exception data based on the operation crash file and the target acquisition strategy.
[0125] In some embodiments, the thread types corresponding to the execution program include first-class threads and second-class threads; the processing module 410 is specifically used to: when the running crash file represents a first-class thread exception in the execution program, capture the exception data based on the first capture strategy in the target acquisition strategy; when the running crash file represents a second-class thread exception in the execution program, capture the exception data based on the second capture strategy in the target acquisition strategy.
[0126] In some embodiments, the second type of thread includes a first thread and a second thread; the first thread is included in the thread pool corresponding to the execution program, and the second thread is not included in the thread pool; the processing module 410 is specifically used to: when the running crash file represents that the first thread in the execution program is abnormal, based on the capture strategy of the first thread in the second capture strategy, capture the abnormal data; when the running crash file represents that the second thread in the execution program is abnormal, based on the capture strategy of the second type of sub-thread in the second capture strategy, capture the abnormal data.
[0127] In some embodiments, the exception data includes call stack data; the writing module 420 is specifically used to: write the call stack data into a file in a text format of txt based on the write interface in the target acquisition strategy to obtain the exception data file.
[0128] In some embodiments, in the case of an algorithm corresponding to the execution program at the point where the execution program crashes, the first line in the exception data file records the code path of the algorithm, and the other lines in the exception data file except the first line record the code path of the software corresponding to the execution program; in the case of software corresponding to the execution program at the point where the execution program crashes, all lines in the exception data file record the code path of the software.
[0129] In some embodiments, the processing module 410 is specifically configured to: set the debugging information format in the project properties to a program database; or set the generate debugging information option in the project properties to generate debugging information.
[0130] The description of the above device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided by the embodiment of the present disclosure can be used to perform the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present disclosure, please refer to the description of the method embodiment of the present disclosure for understanding.
[0131] It should be noted that, in the embodiments of the present disclosure, if the above-mentioned abnormal data acquisition method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present disclosure is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiments of the present disclosure are not limited to any specific hardware, software or firmware, or any combination of hardware, software and firmware.
[0132] An embodiment of the present disclosure provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0133] The present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps in the above method. The computer-readable storage medium may be transient or non-transient.
[0134] An embodiment of the present disclosure provides a computer program, including computer-readable codes. When the computer-readable codes are executed in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.
[0135] The present disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, implements some or all of the steps in the above method. The computer program product can be implemented specifically by hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium. In other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0136] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between the embodiments, and reference can be made to the similarities or similarities between them. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above-mentioned method embodiments and have similar beneficial effects as the method embodiments. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product disclosed herein, please refer to the description of the method embodiments disclosed herein for understanding.
[0137] It should be noted that FIG5 is a schematic diagram of a hardware entity of a computer device in an embodiment of the present disclosure. As shown in FIG5 , the hardware entity of the computer device 500 includes: a processor 501, a communication interface 502, and a memory 503, wherein:
[0138] Processor 501 generally controls the overall operation of computer device 500 .
[0139] The communication interface 502 enables the computer device to communicate with other terminals or servers through a network.
[0140] The memory 503 is configured to store instructions and applications executable by the processor 501. It can also cache data to be processed or processed by the processor 501 and various modules in the computer device 500 (for example, image data, audio data, voice communication data, and video communication data). This can be implemented using flash memory (FLASH) or random access memory (RAM). Data can be transmitted between the processor 501, the communication interface 502, and the memory 503 via a bus 504.
[0141] It should be understood that “one embodiment” or “an embodiment” mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, “in one embodiment” or “in an embodiment” appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned steps / processes does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial numbers of the embodiments of the present disclosure are for description only and do not represent the advantages and disadvantages of the embodiments.
[0142] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0143] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0144] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, the functional units in the various embodiments of the present disclosure may all be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0145] The above is only an embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the present disclosure, and they should all be covered by the protection scope of the present disclosure. Industrial Applicability
[0146] The exception data acquisition method, apparatus, device, and computer-readable storage medium provided by the embodiments of the present disclosure can capture exception data generated by an execution program when it crashes, based on a target acquisition strategy pre-configured in the execution program; write the exception data into a file to obtain an exception data file; wherein the exception data file represents the call status of the function with abnormalities during the execution of the execution program. In this way, through the target acquisition strategy, exception data representing the call status of the function with abnormalities when the execution program crashes can be quickly captured; writing the exception data into a file can help developers quickly locate the exception and clarify the responsibility.
Claims
1. A method for acquiring abnormal data, the method comprising: Based on the target acquisition strategy pre-configured in the execution program, capturing abnormal data generated when the execution program crashes during operation; The abnormal data is written into a file to obtain an abnormal data file; wherein the abnormal data file represents the calling situation of the function with abnormality when the execution program is running.
2. The abnormal data acquisition method according to claim 1, wherein: The abnormal data acquisition method further includes: determining the target acquisition strategy; Incorporating the target acquisition strategy into the initial program corresponding to the business software; The engineering properties of the initial program are adjusted to obtain the execution program, so that the execution program generates an operation crash file when the execution program crashes during operation.
3. The abnormal data acquisition method according to claim 2, wherein: Determining the target acquisition strategy includes: Determine the thread type corresponding to the execution program; Determine the data capture logic, exception capture logic and write interface corresponding to different thread types; the exception capture logic is used to detect whether the execution program crashes; the write interface is used to write the captured exception data into a file; The target acquisition strategy is determined based on the data capture logic, the exception capture logic and the write interface corresponding to the different thread types.
4. The abnormal data acquisition method according to claim 3, wherein: The thread types include first-class threads and second-class threads; The determining the target acquisition strategy based on the data capture logic, the exception capture logic and the write interface corresponding to the different thread types includes: Determine a first capture strategy corresponding to the first type of thread based on the data capture logic and the exception capture logic corresponding to the first type of thread; Determine a second capture strategy corresponding to the second type of thread based on the data capture logic and the exception capture logic corresponding to the second type of thread; The target acquisition strategy is determined based on the first capture strategy, the second capture strategy, and the write interface.
5. The abnormal data acquisition method according to claim 4, wherein: The second type of thread includes a first thread and a second thread; the first thread is included in a thread pool corresponding to the execution program, and the second thread is not included in the thread pool; The determining, based on the data capture logic and the exception capture logic corresponding to the second type of threads, a second capture strategy corresponding to the second type of threads, comprises: Determine the data capture logic of the first thread as the first data capture logic, and determine the capture strategy of the first thread based on the first data capture logic and the exception capture logic; The data capture logic of the second thread is determined as the second data capture logic, and a capture strategy of the second thread is determined based on the second data capture logic and the exception capture logic.
6. The abnormal data acquisition method according to any one of claims 1 to 5, wherein: The method of capturing abnormal data generated when the execution program crashes based on the target acquisition strategy pre-configured in the execution program includes: Based on the exception capture logic in the target acquisition strategy, determining the operation crash file generated when the execution program crashes during operation; The abnormal data is captured based on the running crash file and the target acquisition strategy.
7. The abnormal data acquisition method according to claim 6, wherein: The thread types corresponding to the execution program include first-class threads and second-class threads; The capturing of the abnormal data based on the running crash file and the target acquisition strategy includes: In a case where the running crash file represents a first type of thread exception in the executing program, capturing the exception data based on a first capture strategy in the target acquisition strategy; In a case where the running crash file represents a second type of thread exception in the executing program, the exception data is captured based on a second capture strategy in the target acquisition strategy.
8. The abnormal data acquisition method according to claim 7, wherein: The second type of thread includes a first thread and a second thread; the first thread is included in a thread pool corresponding to the execution program, and the second thread is not included in the thread pool; In the case where the running crash file represents a second type of thread exception in the execution program, capturing the exception data based on the second capture strategy in the target acquisition strategy includes: When the running crash file indicates that the first thread in the executing program is abnormal, based on the capture strategy of the first thread in the second capture strategy, capturing the abnormal data; When the running crash file indicates that the second thread in the executing program is abnormal, the abnormal data is captured based on the capture strategy of the second thread in the second capture strategy.
9. The abnormal data acquisition method according to any one of claims 1 to 8, wherein: The exception data includes call stack data; The step of writing the abnormal data into a file to obtain the abnormal data file comprises: Based on the write interface in the target acquisition strategy, the call stack data is written into a file to obtain the abnormal data file.
10. The abnormal data acquisition method according to any one of claims 1 to 8, wherein: In the case where the execution program crashes at an algorithm corresponding to the execution program, the first line in the abnormal data file records a code path of the algorithm, and other lines in the abnormal data file except the first line record a code path of the software corresponding to the execution program; In the case where the execution program crashes in the software corresponding to the execution program, all the lines in the abnormal data file record the code path of the software.
11. The abnormal data acquisition method according to any one of claims 2 to 10, wherein: The adjusting the engineering properties of the initial program includes: Setting the debugging information format in the project properties to a program database; or, The Generate Debug Information option in the project properties is set to Generate Debug Information.
12. An abnormal data acquisition device, the abnormal data acquisition device comprising: A processing module, used for capturing abnormal data generated when the execution program crashes, based on a target acquisition strategy pre-configured in the execution program; The writing module is used to write the abnormal data into a file to obtain an abnormal data file; wherein the abnormal data file represents the calling situation of the function with abnormality when the execution program is running.
13. A computer device, wherein: The device comprises: a processor, a memory and a communication bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is used to execute the computer program in the memory to implement the steps of the abnormal data acquisition method according to any one of claims 1 to 11.
14. A computer-readable storage medium, wherein: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the abnormal data acquisition method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Abnormity processing method and device and electronic equipment
CN110032502A
Data exception identification method and device
CN111443997A
Android thread exception processing method, terminal and computer readable storage medium
CN112559235A
Application program exception handling method and equipment
CN115934404A
Abnormal data acquisition method, device and equipment and computer readable storage medium
CN117149667A