Application processing method, terminal, server, device and storage medium
By obtaining thread and heap memory information when application exceptions and sending it to the server for debugging, the problem of complex and time-consuming debugging process in the existing technology is solved, and more targeted application debugging is achieved, reducing debugging difficulty and cost.
Patent Information
- Application Number
- CN202111283907.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-01
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-11-01
AI Technical Summary
The existing technology needs to pass manual repeated testing when debugging and applying, resulting in complex processes, long cycles, slow progress, and requires a lot of manpower and material resources, and the debugging effect is not good.
By obtaining information about multiple threads and heap memory when the application is in an abnormal running state, determining the status information of the target thread and dirty memory, and sending this information to the server, combining the application's run log and other information to generate an information dump file for debugging.
The collected information is realized to simulate or restore the application situation at the moment of application crash, making debugging more targeted, reducing the difficulty and complexity of debugging, reducing debugging time and workload, and saving manpower and material resources.
Smart Images

Figure CN113986599B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an application processing method, a terminal, a server, a device, and a storage medium. Background Art
[0002] With the development of science and technology and the continuous advancement of Internet technology, the functions of smart devices are becoming more and more powerful. People can generally install various types of applications in smart devices to meet the needs of daily life, which brings great convenience to people's daily life, study and work.
[0003] During use, due to problems with the application itself, such as problems with the underlying code, or compatibility with the terminal, version issues, etc., the application may have problems such as interface confusion, application freezes, flashbacks, or even crashes, so the application needs to be debugged. However, for application debugging, most of the time, it is necessary to manually test the application repeatedly to simulate similar problems as much as possible in the test, so as to analyze the problems of the application. However, this not only has a complicated process, a long debugging cycle, and slow debugging progress, but also requires a lot of manpower and material resources, and the debugging effect is not good. Summary of the invention
[0004] The embodiments of the present disclosure at least provide an application processing method, a terminal, a server, a device, and a storage medium.
[0005] The present disclosure provides an application processing method, the method comprising:
[0006] When the application is in an abnormal running state, obtaining multiple threads of the application and a heap memory of the application at the time when the abnormal running occurs;
[0007] Determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread;
[0008] Determine dirty memory existing in the heap memory and memory status information of the dirty memory;
[0009] Determine memory address information of a portion of memory used in other memories in the heap memory except the dirty memory;
[0010] The thread state information, the memory state information and the memory address information are sent to a server, so that the server can debug the application through the thread state information and the memory state information.
[0011] In an optional implementation, when the application is in an abnormal running state, obtaining multiple threads of the application at the time when the abnormal running occurs and the heap memory of the application includes:
[0012] When the application meets the abnormal data reporting conditions, upon detecting that the application has an abnormal operation, suspending multiple threads running in the application;
[0013] The multiple suspended threads and the heap memory of the application are obtained.
[0014] In an optional implementation manner, the determining at least one target thread that needs to be reported among the multiple threads and the thread state information of the target thread includes:
[0015] Based on pre-configured thread reporting information and / or the business scenario of the application when the abnormal operation occurs, determine at least one target thread that needs to be reported from the multiple threads;
[0016] Obtain thread state information of the target thread.
[0017] In an optional implementation manner, the obtaining the thread state information of the target thread includes:
[0018] Obtaining the thread structure and stack memory of the target thread;
[0019] Determining thread values located in a plurality of preset thread registers from the thread structure;
[0020] Determining allocated memory in use in the stack memory;
[0021] The determined multiple thread values and the allocated memory are used as thread state information of the target thread.
[0022] In an optional implementation, after determining the thread state information and the memory state information, the method includes:
[0023] The thread state information and the memory state information are stored in a stack memory of the application.
[0024] In an optional implementation manner, sending the thread state information, the memory state information, and the memory address information to the server includes:
[0025] Writing the thread state information and the memory state information into corresponding positions in a blank information dump file to obtain a first information dump file;
[0026] Writing the memory address information into an information file;
[0027] After the application runs abnormally, when the application runs again, the first information dump file and the information file are sent to the server.
[0028] The present disclosure provides an application processing method, the method comprising:
[0029] Receiving thread status information, memory status information, and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in the application collected by the terminal at the time when the application runs abnormally, the memory status information includes status information of dirty memory in the application at the time when the application runs abnormally, and the memory address information includes the start and end addresses of a portion of memory used in other memory in the heap memory of the application except the dirty memory;
[0030] generating a second information dump file of the application based on the thread state information, the memory state information, the memory address information, the running log of the application, and at least one application information;
[0031] The application is debugged through the second information dump file.
[0032] In an optional implementation, the generating a second information dump file of the application based on the thread state information, the memory state information, the memory address information, the running log of the application, and at least one application information includes:
[0033] Determine, based on the running log of the application and at least one kind of application information, the running information of the application at the time when the running abnormality occurs;
[0034] Based on the memory address information, the running information, the application thread state information and the memory state information are merged to obtain a second information dump file.
[0035] In an optional implementation manner, in the process of merging to obtain the second information dump file, the method includes:
[0036] If there are still empty positions in the second information dump file after filling in the information in the second information dump file, a preset placeholder is filled in the empty position.
[0037] The present disclosure also provides a terminal, the terminal comprising:
[0038] An acquisition module, used for acquiring, when the application is in an abnormal running state, a plurality of threads of the application at the time when the abnormal running occurs and a heap memory of the application;
[0039] A first determining module, configured to determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread;
[0040] A second determining module is used to determine dirty memory existing in the heap memory and memory status information of the dirty memory;
[0041] A third determining module is used to determine the memory address information of the used part of the memory in the heap memory except the dirty memory;
[0042] The sending module is used to send the thread state information, the memory state information and the memory address information to the server, so that the server can debug the application through the thread state information and the memory state information.
[0043] In an optional implementation manner, the acquisition module is specifically used to:
[0044] When the application meets the abnormal data reporting conditions, upon detecting that the application has an abnormal operation, suspending multiple threads running in the application;
[0045] The multiple suspended threads and the heap memory of the application are obtained.
[0046] In an optional implementation manner, the first determining module is specifically configured to:
[0047] Based on pre-configured thread reporting information and / or the business scenario of the application when the abnormal operation occurs, determine at least one target thread that needs to be reported from the multiple threads;
[0048] Obtain thread state information of the target thread.
[0049] In an optional implementation manner, when the first determination module is used to obtain the thread state information of the target thread, it is specifically used to:
[0050] Obtaining the thread structure and stack memory of the target thread;
[0051] Determining thread values located in a plurality of preset thread registers from the thread structure;
[0052] Determining allocated memory in use in the stack memory;
[0053] The determined multiple thread values and the allocated memory are used as thread state information of the target thread.
[0054] In an optional implementation manner, the terminal further includes a storage module, and the storage module is used to:
[0055] The thread state information and the memory state information are stored in a stack memory of the application.
[0056] In an optional implementation manner, the sending module is specifically used to:
[0057] Writing the thread state information and the memory state information into corresponding positions in a blank information dump file to obtain a first information dump file;
[0058] Writing the memory address information into an information file;
[0059] After the application runs abnormally, when the application runs again, the first information dump file and the information file are sent to the server.
[0060] The present disclosure also provides a server, the server comprising:
[0061] a receiving module, configured to receive thread status information, memory status information and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in an application collected by the terminal at the time when an abnormal operation of the application occurs, the memory status information includes status information of dirty memory existing in the application at the time when the abnormal operation of the application occurs, and the memory address information includes the start and end addresses of a portion of memory used in other memory in the heap memory of the application except the dirty memory;
[0062] A generating module, configured to generate a second information dump file of the application based on the thread state information, the memory state information and the memory address information, as well as an operation log of the application and at least one application information;
[0063] A debugging module is used to debug the application through the second information dump file.
[0064] In an optional implementation manner, the generating module is specifically used for:
[0065] Determine, based on the running log of the application and at least one kind of application information, the running information of the application at the time when the running abnormality occurs;
[0066] Based on the memory address information, the running information, the application thread state information and the memory state information are merged to obtain a second information dump file.
[0067] In an optional implementation manner, the generating module is used in the process of obtaining the second information dump file by fusion, and the generating module is further used to:
[0068] If there are still empty positions in the second information dump file after filling in the information in the second information dump file, a preset placeholder is filled in the empty position.
[0069] An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the above-mentioned application processing method steps are performed.
[0070] The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned application processing method are executed.
[0071] The application processing method, terminal, server, device and storage medium provided by the embodiments of the present disclosure can, when the application is in an abnormal running state, obtain the target thread at the time when the application runs abnormally and the thread state information of the target thread, the dirty memory existing in the heap memory and the memory state information of the dirty memory, and the memory address information of the part of the memory used in other memories in the heap memory except the dirty memory, and send the thread state information, the memory state information and the memory address information to the server. The server receives the thread state information, the memory state information and the memory address information sent by the terminal, and generates a second information dump file of the application based on the thread state information, the memory state information and the memory address information, as well as the running log of the application and at least one application information, and then debugs the application through the second information dump file.
[0072] In this way, by collecting the crash information of the application and sending the crash information to the server, the crash information is integrated with other application information into an information dump file that can be recognized by the debugger, and the information dump file is recognized and parsed, etc., to debug the application. By simulating or even restoring the application status at the time of the application crash through the collected information, the application debugging can be made more targeted, and the difficulty and complexity of application debugging can be greatly reduced, which is conducive to reducing debugging time, speeding up debugging progress, reducing debugging workload, and saving a lot of manpower and material resources.
[0073] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0075] Figure 1 A flowchart of an application processing method provided by an embodiment of the present disclosure is shown;
[0076] Figure 2 A flowchart showing another application processing method provided by an embodiment of the present disclosure is shown;
[0077] Figure 3 A flowchart showing another application processing method provided by an embodiment of the present disclosure is shown;
[0078] Figure 4 One of the schematic diagrams of a terminal provided by an embodiment of the present disclosure is shown;
[0079] Figure 5 A second schematic diagram of a terminal provided by an embodiment of the present disclosure is shown;
[0080] Figure 6 A schematic diagram of a server for application processing provided by an embodiment of the present disclosure is shown;
[0081] Figure 7 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0082] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0083] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0084] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0085] Research has found that when users use applications in smart devices to meet their daily needs, due to problems with the applications themselves, such as problems with the underlying code, or compatibility with the terminal, version issues, etc., the applications may have problems such as interface confusion, application freezes, flashbacks, or even crashes during use, so the applications need to be debugged. However, for application debugging, most applications need to be tested repeatedly by humans to simulate similar problems as much as possible in the test, so as to analyze the problems of the applications. However, this not only has a complicated process, a long debugging cycle, and slow debugging progress, but also requires a lot of manpower and material resources, and the debugging effect is not good.
[0086] Based on the above research, the present disclosure provides an application processing method, in which the terminal can obtain the target thread and the thread status information of the target thread, the dirty memory and the memory status information of the dirty memory, and the memory address information of the used part of other memory except the dirty memory when the application is abnormal, and send it to the server. The server receives the information sent by the terminal, and combines the operation log of the application and at least one application information to generate an information dump file of the application, and then debug the application through the information dump file.
[0087] In this way, by collecting information to simulate or even restore the application situation at the time of application crash, application debugging can be made more targeted, greatly reducing the difficulty and complexity of application debugging, which is conducive to reducing debugging time, speeding up debugging progress, reducing debugging workload, and saving a lot of manpower and material resources.
[0088] The defects existing in the above solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.
[0089] To facilitate understanding of this embodiment, an application processing method disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the application processing method provided in the embodiment of the present disclosure is generally an electronic device with certain computing capabilities, and the electronic device includes, for example, a terminal device or a server or other processing device. In some possible implementations, the application processing method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0090] The application processing method provided by the embodiment of the present disclosure is described below by taking the execution subject as a terminal as an example.
[0091] See also Figure 1 , Figure 1 A flowchart of an application processing method provided by an embodiment of the present disclosure, such as Figure 1 As shown in , the application processing method provided by the embodiment of the present disclosure includes:
[0092] S101: When an application is in an abnormal running state, a plurality of threads of the application and a heap memory of the application at a time when the abnormal running occurs are obtained.
[0093] In this step, the terminal can be detected in real time to detect the running status of the application in the terminal. When it is detected that the application is in an abnormal running state, that is, the application has an abnormal running, such as the application page is stuck or the application interface is disordered, or even the application crashes, etc. Accordingly, in order to facilitate the subsequent recovery and analysis of the application anomaly, multiple threads and the heap memory of the application at the time when the application has an abnormal running can be obtained.
[0094] In order to reduce the burden caused by the terminal collecting information when an application exception occurs, certain conditions can be set for the terminal, that is, the terminal (application) will only collect information when an application exception occurs when the terminal hits the corresponding conditions sent by the server. Specifically, the conditions sent by the server to the terminal may include one or more of the following conditions: the terminal needs to turn on the data collection function switch for application exceptions, the terminal's system version needs to be greater than or equal to the preset version number, and the terminal's data processing capability needs to be greater than a preset value, such as the terminal's central processing unit architecture needs to be no less than 64 bits.
[0095] Furthermore, since the terminal may cause changes in some internal data when collecting application exception data and other data, resulting in certain errors in the application data and status when an exception occurs, the collection of relevant data of multiple threads and the heap memory of the application can be carried out after an exception occurs in the application and the collection of the application's running log, that is, the crash log, is completed, and then the collection of relevant data of the threads and heap memory is carried out.
[0096] The heap memory is another memory area different from the stack area, the global data area and the code area, and is a memory space used to store some program running data generated when the application is running.
[0097] Accordingly, when an application exception occurs, it is mostly because one or part of the threads has a problem, but most of the threads without problems will continue to run normally. The normally running threads will still generate corresponding data, and there is data reading and writing, etc., which causes the data in the memory to change. Therefore, the data and other information in the application also change. Therefore, in order to ensure the accuracy of data collection and better reproduce the exceptions such as application crashes, so as to analyze the cause of the exception, it is necessary to stop the application before obtaining multiple threads and the heap memory of the application when the application runs abnormally.
[0098] Therefore, in some possible implementations, step S101 includes:
[0099] In the case where the application meets the abnormal data reporting conditions, when it is detected that the application has an abnormal operation, multiple threads running in the application are suspended; and the multiple suspended threads and the heap memory of the application are obtained.
[0100] Here, when the application meets the conditions for reporting abnormal data, that is, when the application meets the conditions for data collection issued by the server, if it is detected that the application crashes or other operating abnormalities occur, it can be considered that the application needs to be debugged. In order to accurately collect accurate information under abnormal circumstances, multiple threads running in the application can be suspended first to keep the application in the state at the time of the operating abnormality, and then obtain the multiple suspended threads and the heap memory of the application.
[0101] Among them, the application is in an abnormal running state. The errors may be caused by the inconsistency of internal mechanisms, such as the interface freezing when the user refreshes the application interface, garbled information when browsing the interface, improper use of graphical interface design documents, some abnormalities when processing files, insufficient storage space, frequent application saving of documents, caching of information or processing of relatively large data, attempts to access memory not allocated to itself, and attempts to write data to memory addresses without write permissions, etc., as well as application flashbacks or even crashes.
[0102] S102: Determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread.
[0103] In this step, after obtaining the multiple threads, in order to reduce the amount of reported data and reduce the data processing pressure of the terminal, only the data that needs to be reported can be reported. Therefore, at least one target thread that needs to be reported can be further determined from the multiple threads obtained, and then the thread status information of the target thread can be obtained.
[0104] The thread status information may be information that can indicate the operation and use of the target thread, such as data indicating changes in the target thread.
[0105] Among them, the at least one target thread that needs to be reported can refer to a thread that is of concern in the application, which can be multiple pre-set threads, that is, in the background server, maintenance personnel and other users can pre-set at least one thread as the target thread that needs to be reported based on development and debugging requirements, experience and historical problems of the application, so that the terminal can find the at least one set target thread according to the setting when an exception occurs in the application. It can also be dynamically determined according to the business situation when the exception occurs in the application. For example, the application includes multiple business scenarios, such as shopping, games, videos, etc., then according to which business scenario the application is in when the exception occurs, at least one thread in the corresponding business scenario can be dynamically used as the target thread.
[0106] Specifically, determining at least one target thread and thread state information of the target thread may include:
[0107] Based on pre-configured thread reporting information and / or the business scenario of the application when an abnormal operation occurs, at least one target thread that needs to be reported is determined from the multiple threads; and thread state information of the target thread is obtained.
[0108] Here, when it is detected that the application has an abnormal operation, before it is necessary to determine the at least one target thread and the thread status information of the target thread, the pre-configured thread reporting information pre-issued by the server or stored locally can be obtained, so that by parsing the thread reporting information, at least one target thread that needs to be reported can be known, or when it is detected that the application has an abnormal operation, the business scenario at the time when the application has an abnormal operation can be determined, that is, when the application has an abnormal operation, the function used by the user of the application, and the thread corresponding to the business scenario is used as the at least one target thread that needs to be reported; it can also be that the thread reporting information and the business scenario are combined, that is, only the set thread under the business scenario is used as the target thread, and then the thread status information of the target thread is obtained.
[0109] Correspondingly, after the at least one target thread is determined, threads other than the target thread from the acquired multiple threads may be pruned to obtain only the remaining target thread.
[0110] Furthermore, to obtain the thread status information of the target thread, the thread structure and stack memory of the target thread can be first obtained by reading underlying data, and then the thread structure can be parsed to determine the thread values located in a plurality of preset thread registers from the thread structure. Furthermore, the allocated memory in use in the stack memory can be determined by the usage of the stack memory, and the determined plurality of thread values and the allocated memory can be used as the thread status information of the target thread.
[0111] Exemplarily, taking the IOS system as an example, after obtaining the thread structure, since most thread structures are in the form of _STRUCT_MCONTEXT64 structure, the thread structure can be traversed and parsed by returning the thread function thread_get_state, etc., so as to determine the thread values located in the preset multiple thread registers from the thread structure, such as the values of thread registers X0-X28, fp, lr, sp, pc, and cpsr. For stack memory, its determination method is the same or similar to that of heap memory, and refer to the subsequent contents of heap memory.
[0112] S103: Determine dirty memory existing in the heap memory and memory status information of the dirty memory.
[0113] In this step, since not all memory is used when an exception occurs in the application, there is no data in the unused memory. Therefore, for the acquired heap memory, only the dirty memory and the memory status information of the dirty memory can be acquired.
[0114] The dirty memory may refer to invalid memory generated during the running of the application or memory fragments with extremely low utilization rate formed after the stack memory is repeatedly used.
[0115] Specifically, for determining the dirty memory and the memory status information of the dirty memory, since both the heap memory and the stack memory in the application are composed of virtual memory, each separate virtual memory can be called VMRegion. In view of this, by calling the vm_region_recurse / vm_region_recurse64 function in the mach kernel, all memories in the application, that is, the stack memory of the thread and the heap memory of the application, can be traversed. Taking the heap memory as an example, by parsing the structure of the heap memory, the address and size of each memory page in the virtual memory address space of the heap memory, the number of dirty memory and swapped memory pages in the heap memory, and the label of each virtual memory that can capture specific memory usage can be controlled by issuing configurations, and other information that can generate part of the dirty memory.
[0116] After traversing all the memory in the application by calling the vm_region_recurse / vm_region_recurse64 function in the mach kernel, the vm_map_page_query function can be used to check whether each memory page number in the virtual memory area is dirty memory, and then all non-dirty memory is not saved. Furthermore, based on all the detected dirty memory, it can be determined whether to trim part of the dirty memory based on pre-configured information and business scenarios. Taking stack memory as an example, if the stack memory allocated to a thread is dirty memory, it can also be determined how much stack memory the thread uses based on the information of the thread register sp of the thread, and then some invalid dirty memory can be trimmed.
[0117] S104: Determine memory address information of a portion of memory in use in other memories in the heap memory except the dirty memory.
[0118] In this step, since all used memory will store data when the application is running, in order to more accurately restore the application running scenario, it is necessary to determine the memory address information of the used part of the memory in the heap memory except the dirty memory, so as to determine which memory is used.
[0119] Specifically, through the vm_region_recurse / vm_region_recurse64 function of the mach kernel, we can traverse all the memory of a process, and then parse the acquired memory through the vm_region_submap_info_64 function to obtain the number of dirty memory and swapped memory pages that reflect the real memory usage in the memory area, so as to determine which memory is used, as well as the address and size of each memory page in the virtual memory address space, so as to obtain the memory address information of the used part of the memory.
[0120] Furthermore, the acquired memory address information of the used part of the memory other than the dirty memory is stored in the binary list of the application so as to be called when the application is subsequently restored.
[0121] The binary image list is a picture stored in a database in binary form to record the memory address information of the part of the memory used in other memories except the dirty memory.
[0122] S105: Send the thread status information, the memory status information, and the memory address information to a server, so that the server can debug the application through the thread status information and the memory status information.
[0123] In this step, after obtaining the thread status information, the memory status information and the memory address information, the thread status information, the memory status information and the memory address information need to be sent to the server so that they can form a debugger-recognizable file with other application information in the server to better debug the application.
[0124] When sending the thread status information, the memory status information and the memory address information to the server, the thread status information and the memory status information can be first written into corresponding positions in a blank information dump file to obtain a first information dump file; the memory address information is written into the information file; after the application runs abnormally, when it runs again, the compressed first information dump file and the information file are sent to the server.
[0125] Here, before the thread state information, the memory state information and the memory address information are sent to the server, due to too much reported content, a certain amount of traffic consumption will be generated, and the memory usage will increase, thereby generating a certain memory pressure on the application. Therefore, in order to save traffic consumption in the reporting process and reduce a certain amount of memory usage, the thread state information, the memory state information and the memory address information can be written into a first information dump file and an information file, and the first information dump file and the information file can be compressed to obtain the compressed file and upload it to the server. After the upload is successful, the compressed file is deleted. The files uploaded to the server include the first information dump file and the information file. During the upload process, there may be an upload failure process. If the upload fails for multiple consecutive times, such as three, four or five times, it can be considered that there is a problem with the data, and the first information dump file and the information file can be completely cleared to prevent the user's memory space from being continuously occupied if the upload continues after the upload fails, thereby continuing to cause new crashes.
[0126] The first information dump file may be a file in a coredump file format.
[0127] Furthermore, when uploading the first information dump file and the information file, the collected referenced operation log (crash log when the application is abnormal) may also be uploaded together.
[0128] The application processing method provided by the embodiment of the present disclosure obtains multiple threads of the application and the heap memory of the application at the time when the application is in an abnormal running state; determines at least one target thread that needs to be reported among the multiple threads and the thread state information of the target thread; determines the dirty memory existing in the heap memory and the memory state information of the dirty memory; determines the memory address information of the used part of the memory other than the dirty memory in the heap memory; sends the thread state information, the memory state information and the memory address information to the server, so that the server can debug the application through the thread state information and the memory state information, so as to simulate or even restore the application situation at the time of application crash through the collected information, so as to make application debugging more targeted, greatly reduce the difficulty and complexity of application debugging, and help to reduce debugging time, speed up debugging progress, reduce debugging workload, and save a lot of manpower and material resources.
[0129] Please also see Figure 2 , Figure 2 A flowchart of another application processing method provided by an embodiment of the present disclosure. Figure 2 As shown in , the application processing method provided by the embodiment of the present disclosure includes:
[0130] S201: When an application is in an abnormal running state, obtain multiple threads of the application and a heap memory of the application at the time when the abnormal running occurs.
[0131] S202: Determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread.
[0132] S203: Determine dirty memory existing in the heap memory and memory status information of the dirty memory.
[0133] S204: Determine memory address information of a portion of memory in use in other memories in the heap memory except the dirty memory.
[0134] S205: Storing the thread state information and the memory state information in the stack memory of the application.
[0135] In this step, after obtaining the thread status information and the memory status information, it is inconvenient to report immediately due to the operation abnormality of the application. It is best to upload the obtained thread status information and the memory status information to the server at a subsequent opportunity. Therefore, the thread status information and the memory status information can be stored in the stack memory of the application for temporary storage.
[0136] Specifically, when the thread state information and the memory state information need to be stored in the stack memory of the application, since the application itself uses heap memory, there may be problems in the storage process. In order to avoid problems that affect data and analysis, heap memory is not used in the storage process. For storage that requires heap memory, stack memory can be used instead of the heap memory area through the __builtin_alloca function.
[0137] Furthermore, if there is a large amount of uploaded data, in order to store the thread status information and the memory status information in the stack memory of the application faster and better, the thread status information and the memory status information can be serialized to obtain the first encoded data corresponding to the thread status information and the second encoded data corresponding to the memory status information, and then the first encoded data and the second encoded data are written into a memory mapping file.
[0138] The memory-mapped file is a mapping from a file to a block of memory, and an address space area can be reserved through the memory-mapped file.
[0139] S206: Send the thread state information, the memory state information, and the memory address information to a server, so that the server can debug the application through the thread state information and the memory state information.
[0140] Among them, the description of steps S201 to S204 and step S206 can refer to the description of steps S101 to S105, and can achieve the same technical effects and solve the same technical problems, which will not be repeated here.
[0141] The application processing method provided by the embodiment of the present disclosure obtains multiple threads of the application and the heap memory of the application at the time when the operation abnormality occurs when the application is in an abnormal operation state; determines at least one target thread that needs to be reported among the multiple threads and the thread state information of the target thread; determines the dirty memory existing in the heap memory and the memory state information of the dirty memory; determines the memory address information of the used part of the memory other than the dirty memory in the heap memory; stores the thread state information and the memory state information in the stack memory of the application; sends the thread state information, the memory state information and the memory address information to the server so that the server can debug the application through the thread state information and the memory state information, so as to simulate or even restore the application situation at the time of application crash through the collected information, so as to make the application debugging more targeted, greatly reduce the difficulty and complexity of application debugging, and help to reduce the debugging time, speed up the debugging progress, reduce the debugging workload, and save a lot of manpower and material resources.
[0142] Please also see Figure 3 , Figure 3 A flowchart of another application processing method provided by an embodiment of the present disclosure. Figure 3 As shown in , the application processing method provided by the embodiment of the present disclosure includes:
[0143] S301: Receive thread status information, memory status information and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in the application collected by the terminal when the application runs abnormally, the memory status information includes status information of dirty memory existing in the application when the application runs abnormally, and the memory address information includes the start and end addresses of a portion of memory used in other memories in the heap memory of the application except the dirty memory.
[0144] Among them, receiving the thread status information, memory status information and memory address information may be receiving a first information dump file sent by the terminal, and after decompression and decryption of the first information dump file, parsing the thread status information, memory status information and memory address information included in the first information dump file for storage.
[0145] S302: Generate a second information dump file of the application based on the thread state information, the memory state information, the memory address information, the running log of the application, and at least one application information.
[0146] In this step, when debugging an application, the debugger can be used to analyze and adjust the application, thereby obtaining analysis results of possible problems in the application. Since the debugger has certain requirements on the content to be processed, such as file format requirements for input files, the received thread state information and the memory state information, as well as the operation log of the application and at least one application information are integrated to generate a second information dump file identifiable by the debugger, so that the debugger can use the second information dump file for analysis.
[0147] Before using a debugger to analyze the second information dump file, multiple logs uploaded by the application can be obtained, and then the information received from the terminal, such as the exception information (crash information value, etc.) related to the application exception recorded in the first information dump file, is compared with each log to obtain the operation log containing the exception information collected after the application operation exception occurs. Then, the situation of the application when the operation exception occurs can be restored through the information recorded in the operation log, in combination with the application thread status information and the memory status information, and at least one application information, such as information found in a resource library or a character table that provides resources for the application, to generate the second information dump file, so as to facilitate subsequent debugging of the application.
[0148] In the process of generating the second information dump file, the running information of the application at the time when the running exception occurs can be determined based on the running log of the application and at least one application information, and then based on the memory address information, the running information, the application thread status information and the memory status information are merged to obtain the second information dump file.
[0149] The operation log may be a file saved in the application program when the application program crashes, recording the crash information of the application program, so as to facilitate subsequent debugging and positioning by developers.
[0150] Specifically, the second information dump file can be obtained by filling the pre-placed empty information dump file with thread commands generated based on the acquired thread status information, the acquired dirty memory, the memory address information of the used part of the memory other than the dirty memory in the heap memory, and at least one application information, or by directly adding the information to the first information dump file to obtain the second information dump file.
[0151] The at least one application information may include: one or more of: a symbol table of an application, a splicing script of an application, an application package, and a dynamic library corresponding to a system version of the application.
[0152] Further, if there are still empty positions in the second information dump file after filling in the information in the second information dump file, a preset placeholder is filled in the empty position.
[0153] The preset placeholder may be a binary 0 or 1 placeholder.
[0154] S303: Debug the application using the second information dump file.
[0155] The application processing method provided by the embodiment of the present disclosure can receive thread status information, memory status information and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in the application collected by the terminal at the time when the application runs abnormally, the memory status information includes status information of dirty memory existing in the application at the time when the application runs abnormally, and the memory address information includes the start and end addresses of the part of memory used in other memories in the heap memory of the application except the dirty memory; based on the thread status information, the memory status information and the memory address information, as well as the running log of the application and at least one application information, a second information dump file of the application is generated; and the application is debugged through the second information dump file, so that the application situation at the time of application crash can be simulated or even restored through the collected information, so that application debugging can be made more targeted, and the difficulty and complexity of application debugging can be greatly reduced, which is conducive to reducing debugging time, accelerating debugging progress, reducing debugging workload, and saving a lot of manpower and material resources.
[0156] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0157] Based on the same inventive concept, a terminal corresponding to the application processing method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the terminal in the embodiment of the present disclosure is similar to the above-mentioned application processing method in the embodiment of the present disclosure, the implementation of the terminal can refer to the implementation of the method, and the repeated parts will not be repeated.
[0158] See also Figure 4 and Figure 5 , Figure 4 This is one of the schematic diagrams of a terminal provided in an embodiment of the present disclosure, Figure 5 This is a second schematic diagram of a terminal provided by an embodiment of the present disclosure. Figure 4 As shown in , the terminal 400 provided in the embodiment of the present disclosure includes:
[0159] The acquisition module 410 is used to acquire, when the application is in an abnormal running state, multiple threads of the application and the heap memory of the application at the time when the abnormal running occurs.
[0160] The first determining module 420 is configured to determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread.
[0161] The second determining module 430 is used to determine the dirty memory existing in the heap memory and the memory status information of the dirty memory.
[0162] The third determining module 440 is used to determine the memory address information of the used part of the memory in the heap memory except the dirty memory.
[0163] The sending module 450 is used to send the thread state information, the memory state information and the memory address information to the server, so that the server can debug the application through the thread state information and the memory state information.
[0164] In an optional implementation manner, the acquisition module 410 is specifically used to:
[0165] When the application meets the abnormal data reporting conditions, upon detecting that the application has an abnormal operation, suspending multiple threads running in the application;
[0166] The multiple suspended threads and the heap memory of the application are obtained.
[0167] In an optional implementation manner, the first determining module 420 is specifically configured to:
[0168] Based on pre-configured thread reporting information and / or the business scenario of the application when the abnormal operation occurs, determine at least one target thread that needs to be reported from the multiple threads;
[0169] Obtain thread state information of the target thread.
[0170] In an optional implementation manner, the first determining module 420 is used to obtain the thread state information of the target thread, specifically to:
[0171] Obtaining the thread structure and stack memory of the target thread;
[0172] Determining thread values located in a plurality of preset thread registers from the thread structure;
[0173] Determining allocated memory in use in the stack memory;
[0174] The determined multiple thread values and the allocated memory are used as thread state information of the target thread.
[0175] In an optional implementation, Figure 5 As shown in , the terminal 400 further includes a storage module 460, and the storage module 460 is used to:
[0176] The thread state information and the memory state information are stored in a stack memory of the application.
[0177] In an optional implementation manner, the sending module 460 is specifically used to:
[0178] Writing the thread state information and the memory state information into corresponding positions in a blank information dump file to obtain a first information dump file;
[0179] Writing the memory address information into an information file;
[0180] After the application runs abnormally, when the application runs again, the first information dump file and the information file are sent to the server.
[0181] The terminal provided by the embodiment of the present disclosure obtains multiple threads of the application and the heap memory of the application at the time when the application is in an abnormal running state; determines at least one target thread that needs to be reported among the multiple threads and the thread state information of the target thread; determines the dirty memory existing in the heap memory and the memory state information of the dirty memory; determines the memory address information of the used part of the memory other than the dirty memory in the heap memory of the application; sends the thread state information, the memory state information and the memory address information to the server, so that the server can debug the application through the thread state information and the memory state information, so as to simulate or even restore the application situation at the time of application crash through the collected information, so as to make the application debugging more targeted, greatly reduce the difficulty and complexity of application debugging, and help to reduce the debugging time, speed up the debugging progress, reduce the debugging workload, and save a lot of manpower and material resources.
[0182] See also Figure 6 , Figure 6 A schematic diagram of a server provided in an embodiment of the present disclosure. Figure 6 As shown in , the server 600 provided in the embodiment of the present disclosure includes:
[0183] The receiving module 610 is used to receive thread status information, memory status information and memory address information sent by the terminal, wherein the thread status information includes status information of at least one target thread in the application collected by the terminal when the application runs abnormally, the memory status information includes status information of dirty memory existing in the application when the application runs abnormally, and the memory address information includes the start and end addresses of the used part of the memory in the heap memory of the application other than the dirty memory.
[0184] The generating module 620 is used to generate a second information dump file of the application based on the thread state information, the memory state information and the memory address information, as well as the running log of the application and at least one application information.
[0185] The debugging module 630 is used to debug the application through the second information dump file.
[0186] In an optional implementation manner, the generating module 620 is specifically used for:
[0187] Determine, based on the running log of the application and at least one kind of application information, the running information of the application when the running abnormality of the application occurs;
[0188] Based on the memory address information, the running information, the application thread state information and the memory state information are merged to obtain a second information dump file.
[0189] In an optional implementation manner, in an optional implementation manner, the generating module 620 is used in the process of obtaining the second information dump file by fusion, specifically for:
[0190] If there are still empty positions in the second information dump file after filling in the information in the second information dump file, a preset placeholder is filled in the empty position.
[0191] The server provided by the embodiment of the present disclosure can receive thread status information, memory status information and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in the application collected by the terminal at the time when the application runs abnormally, the memory status information includes status information of dirty memory existing in the application at the time when the application runs abnormally, and the memory address information includes the start and end addresses of the used part of the memory in other memory in the heap memory of the application except the dirty memory; based on the thread status information, the memory status information and the memory address information, as well as the running log of the application and at least one application information, a second information dump file of the application is generated; and the application is debugged through the second information dump file, so that the application situation at the time of application crash can be simulated or even restored through the collected information, so that the application debugging can be more targeted, the difficulty and complexity of application debugging can be greatly reduced, which is conducive to reducing the debugging time, accelerating the debugging progress, reducing the debugging workload, and saving a lot of manpower and material resources.
[0192] Corresponding to the above-mentioned application processing method, the embodiment of the present disclosure further provides an electronic device 700, such as Figure 7 FIG. 7 is a schematic diagram of the structure of an electronic device 700 provided in an embodiment of the present disclosure, including:
[0193] Processor 710, memory 720, and bus 730; memory 720 is used to store execution instructions, including internal memory 721 and external memory 722; the internal memory 721 here is also called internal memory, which is used to temporarily store the operation data in the processor 710, and the data exchanged with the external memory 722 such as the hard disk. The processor 710 exchanges data with the external memory 722 through the internal memory 721. When the electronic device 700 is running, the processor 710 and the memory 720 communicate through the bus 730, so that the processor 710 can execute the steps of the above-mentioned application processing method.
[0194] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the application processing method described in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0195] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the application processing method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0196] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0197] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0198] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on 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.
[0199] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0200] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0201] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. An application processing method, characterized in that: The method comprises: When the application is in an abnormal running state, obtaining multiple threads of the application and a heap memory of the application at the time when the abnormal running occurs; Determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread; Determine dirty memory existing in the heap memory and memory status information of the dirty memory; Determine memory address information of a portion of memory used in other memories in the heap memory except the dirty memory; The thread state information, the memory state information and the memory address information are sent to a server, so that the server can debug the application through the thread state information and the memory state information.
2. The method according to claim 1, characterized in that When the application is in an abnormal running state, obtaining multiple threads of the application at the time when the abnormal running occurs and the heap memory of the application includes: When the application meets the abnormal data reporting conditions, upon detecting that the application has an abnormal operation, suspending multiple threads running in the application; The multiple suspended threads and the heap memory of the application are obtained.
3. The method according to claim 1, characterized in that The determining at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread includes: Based on pre-configured thread reporting information and / or the business scenario of the application when the abnormal operation occurs, determine at least one target thread that needs to be reported from the multiple threads; Obtain thread state information of the target thread.
4. The method according to claim 3, characterized in that The obtaining of the thread state information of the target thread includes: Obtaining the thread structure and stack memory of the target thread; Determining thread values located in a plurality of preset thread registers from the thread structure; Determining allocated memory in use in the stack memory; The determined multiple thread values and the allocated memory are used as thread state information of the target thread.
5. The method according to claim 1, characterized in that After determining the thread state information and the memory state information, the method includes: The thread state information and the memory state information are stored in a stack memory of the application.
6. The method according to claim 1, characterized in that The sending the thread state information, the memory state information and the memory address information to the server includes: Writing the thread state information and the memory state information into corresponding positions in a blank information dump file to obtain a first information dump file; Writing the memory address information into an information file; After the application runs abnormally, when the application runs again, the first information dump file and the information file are sent to the server.
7. An application processing method, characterized in that: The method comprises: Receiving thread status information, memory status information, and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in the application collected by the terminal at the time when the application runs abnormally, the memory status information includes status information of dirty memory in the application at the time when the application runs abnormally, and the memory address information includes the start and end addresses of a portion of memory used in other memory in the heap memory of the application except the dirty memory; generating a second information dump file of the application based on the thread state information, the memory state information, the memory address information, the running log of the application, and at least one application information; The application is debugged through the second information dump file.
8. The method according to claim 7, characterized in that Generating a second information dump file of the application based on the thread state information, the memory state information, the memory address information, the running log of the application, and at least one application information, includes: Determine, based on the running log of the application and at least one kind of application information, the running information of the application at the time when the running abnormality occurs; Based on the memory address information, the running information, the application thread state information and the memory state information are merged to obtain a second information dump file.
9. The method according to claim 8, characterized in that In the process of merging to obtain the second information dump file, the method includes: If there are still empty positions in the second information dump file after filling in the information in the second information dump file, a preset placeholder is filled in the empty position.
10. A terminal, characterized in that: The terminal comprises: An acquisition module, used for acquiring, when the application is in an abnormal running state, a plurality of threads of the application at the time when the abnormal running occurs and a heap memory of the application; A first determining module, configured to determine at least one target thread that needs to be reported among the multiple threads and thread state information of the target thread; A second determining module is used to determine dirty memory existing in the heap memory and memory status information of the dirty memory; A third determining module is used to determine the memory address information of the used part of the memory in the heap memory except the dirty memory; The sending module is used to send the thread state information, the memory state information and the memory address information to the server, so that the server can debug the application through the thread state information and the memory state information.
11. A server, characterized in that: The server comprises: a receiving module, configured to receive thread status information, memory status information and memory address information sent by a terminal, wherein the thread status information includes status information of at least one target thread in an application collected by the terminal at the time when an abnormal operation of the application occurs, the memory status information includes status information of dirty memory existing in the application at the time when the abnormal operation of the application occurs, and the memory address information includes the start and end addresses of a portion of memory used in other memory in the heap memory of the application except the dirty memory; A generating module, configured to generate a second information dump file of the application based on the thread state information, the memory state information and the memory address information, as well as an operation log of the application and at least one application information; A debugging module is used to debug the application through the second information dump file.
12. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the application processing method as described in any one of claims 1 to 6 or claims 7 to 9 are performed.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the application processing method according to any one of claims 1 to 6 or claims 7 to 9 are executed.
Citation Information
Patent Citations
Debugging method for application program, debugging host and running host
CN104965786A
Fault tolerant memory synchronization method and system of virtual machine
CN105955837A