File naming method and electronic device

By parsing the process name and naming the crash report file by combining the current time and version number with the Crashpad processing terminal, the problem of difficulty in directly locating the crash process in the existing technology is solved, and the crash analysis is simplified and the efficiency is improved.

CN120429273BActive Publication Date: 2026-04-10HONOR DEVICE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing technologies, crash report files are named using a Universally Unique Identifier (UUID) for crash reports, making it difficult to directly locate the crashing process. Developers need to parse the file content to confirm the crashing process.

Method used

The Crashpad processor parses the command line of the target process, obtains the process name, and uses it as the naming string for the crash report file. Combined with the current time and version number, the Crashpad client dumps the crash report into a file named with the target string.

Benefits of technology

It simplifies the naming convention for crash report files, helps developers directly pinpoint the crashing process, and improves the efficiency and accuracy of crash analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120429273B_ABST
    Figure CN120429273B_ABST
Patent Text Reader

Abstract

The application discloses a file naming method and an electronic device, relates to the software field, and is used for helping to locate a crashed process by naming a crash report file as the name of the crashed process. The file naming method is applied to a Crashpad run by the electronic device, the Crashpad comprises a Crashpad processing end and a Crashpad client, and the method comprises the following steps: in response to a crash of a target process, the Crashpad processing end acquires a command line of the target process, the command line comprising the name of the target process; the Crashpad processing end analyzes the command line to obtain the name of the target process; the Crashpad processing end sends a target string to the Crashpad client; and the Crashpad client converts a crash report into a crash report file named by the target string, the target string comprising the name of the target process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software, and more particularly to a file naming method and an electronic device. Background Technology

[0002] Crashpad can store the state of a process at the time of a crash (crash metadata) as a dump file. However, the dump file is named using a universally unique identifier (UUID) from the crash report, such as e71ecaaf-1d6e-4228-9f68-226cb9da3e37.dmp. Developers need to parse the contents of the crash report file to locate the crashed process. Summary of the Invention

[0003] This application provides a file naming method and an electronic device for helping to locate a crashed process by naming a crash report file after the name of the crashed process.

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

[0005] Firstly, a file naming method is provided, applied to a Crashpad running on an electronic device. The Crashpad includes a Crashpad processor and a Crashpad client. The method includes: in response to a crash of a target process, the Crashpad processor obtains the command line of the target process, the command line including the name of the target process; the Crashpad processor parses the command line to obtain the name of the target process; the Crashpad processor sends a target string to the Crashpad client; and the Crashpad client dumps the crash report into a crash report file named with the target string, the target string including the name of the target process.

[0006] The file naming method provided in this application, in response to a target process crash, involves the Crashpad processor parsing the target process's command line to obtain the name of the crashed target process, and sending a target string, which includes the target process's name, to the Crashpad client. The Crashpad client then dumps the crash report into a crash report file named with the target string. In other words, naming the crash report file after the crashed process helps developers locate the crashed process.

[0007] In a possible implementation, the method further includes: the Crashpad processing end acquires the current time, and the target string further includes the current time. Since the software runs very fast, the time elapsed from the crash of the target process until the current time is acquired is short, in the order of milliseconds, and the current time is equivalent to the time of the crash of the target process. The current time included in the target string can help the developer analyze the cause of the crash of the target process.

[0008] In a possible implementation, the method further includes: the Crashpad processing end acquires the version number of the target process, and the target string further includes the version number of the target process. Since the target process has undergone multiple development iterations and can have different version numbers, the version number of the target process included in the target string can help the developer analyze which version of the target process crashes.

[0009] In a possible implementation, the parsing of the command line to obtain the name of the target process includes: searching for the position of the last “\\” in the command line from back to front as lastSlashPos; searching for the position of the last “.exe” in the command line from back to front as lastExePos; and extracting, from the command line, a string starting from the position lastSlashPos+1 and having a length of lastExePos-(lastSlashPos+1) to obtain the name of the target process. This implementation provides how to extract the name of the target process from the command line of the target process.

[0010] In a possible implementation, the Crashpad processing end includes a ProcessSnapshotWin module, a ProcessInfo module, and a CrashReportExceptionHandler module; the ProcessSnapshotWin module is configured to acquire a snapshot of the current state of the target process; the ProcessInfo module is configured to collect the command line of the target process; and the CrashReportExceptionHandler module is configured to dump a crash report when an exception occurs. The method further includes: the ProcessSnapshotWin module acquires the command line through the ProcessInfo module; after the ProcessSnapshotWin module obtains the name of the target process by parsing the command line, the ProcessSnapshotWin module sends the target string to the CrashReportExceptionHandler module; and the CrashReportExceptionHandler module is configured to send the target string to the Crashpad client. This implementation provides how the modules of the Crashpad processing end acquire the name of the target process and send the target string including the name of the target process to the Crashpad client.

[0011] In a possible implementation, the Crashpad client includes a CrashReportDatabaseWin module, a CrashReportDatabase module; the CrashReportDatabase module is configured to manage the crash report file and related metadata; the CrashReportDatabaseWin module inherits from the CrashReportDatabase module and is configured to implement the operation of the crash report file and related metadata; the method further includes: the CrashReportDatabaseWin module receives the target string from the CrashReportExceptionHandler module and sends the target string to the CrashReportDatabase module; and the CrashReportDatabase module dumps the crash report into a crash report file named by the target string. This implementation provides how the modules of the Crashpad client obtain the target string from the Crashpad processing end and dump the crash report into the crash report file.

[0012] In a second aspect, an electronic device is provided, including a processor and a memory, the memory storing instructions, when the processor executes the instructions, the electronic device performs the method in the first aspect and any implementation thereof.

[0013] In a third aspect, a computer-readable storage medium is provided, including instructions, when the instructions run on an electronic device, the electronic device performs the method in the first aspect and any implementation thereof.

[0014] In a fourth aspect, a computer program product is provided, including instructions, when the instructions run on the above-mentioned electronic device, the electronic device performs the method in the first aspect and any implementation thereof.

[0015] In a fifth aspect, a file naming apparatus is provided, including: a Crashpad processing end and a Crashpad client. The Crashpad processing end and the Crashpad client are configured to perform the operation related to processing in the first aspect and any implementation thereof.

[0016] The technical effects of the second aspect to the fifth aspect refer to the technical effects of the first aspect and any implementation thereof, which are not repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 A schematic diagram of a Crashpad provided by the embodiments of the present application;

[0018] Figure 2A flowchart of a file naming method provided by an embodiment of the present application is shown in FIG. 1.

[0019] Figure 3 A structural diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 2.

[0020] Figure 4 A flowchart of another file naming method provided by an embodiment of the present application is shown in FIG. 3.

[0021] Figure 5 A structural diagram of a file naming device provided by an embodiment of the present application is shown in FIG. 4. DETAILED DESCRIPTION

[0022] First, some concepts involved in the present application are described.

[0023] The terms "first", "second", and the like involved in the embodiments of the present application are only used for the purpose of distinguishing the same type of features, and cannot be understood as indicating relative importance, quantity, order, and the like.

[0024] The terms "exemplary" or "for example" and the like involved in the embodiments of the present application are used to represent an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the terms "exemplary" or "for example" are intended to present the relevant concept in a specific manner.

[0025] Crashpad is an open-source crash reporting system that is mainly used to collect the state of an application or process when it crashes, such as register information, stack information, memory information, etc. Developers can find bugs in the application or process when it runs, help developers diagnose and fix problems, and improve the stability of the application or process. Crashpad is widely used in various applications, especially in systems that require high reliability. By using Crashpad, developers can more effectively manage and solve the crash problems of the application, and improve the quality of the software and user experience. The main functions of Crashpad are as follows:

[0026] Crash reporting collection: Crashpad can collect detailed error information when an application crashes, including the call stack at the time of the crash, memory state, etc., to help developers quickly locate the problem.

[0027] Symbol resolution: Crashpad supports symbol resolution, which can convert machine code into readable function names and variable names, making the debugging process more intuitive.

[0028] Cross-platform support: Crashpad supports multiple operating systems, such as Windows Operating System and Operating System, so that Crashpad can be used on different platforms.

[0029] The use scenarios of Crashpad are as follows:

[0030] Game development: In game development, Crashpad can help collect crash information encountered by players in the game, helping developers optimize game performance and stability.

[0031] Enterprise application: In enterprise-level applications, Crashpad can detect the running state of the application and collect crash information in a timely manner to ensure business continuity.

[0032] Embedded system: In embedded systems, Crashpad can be used to collect application crash reports to help developers perform remote debugging and maintenance.

[0033] As shown in Figure 1 , Crashpad includes two independent processes: a handler process and a client process. The handler process and the client process communicate through inter-process communication (IPC). The client process belongs to the application program being detected for crashes, and the handler process runs independently of the application program. Therefore, Crashpad is not part of the Windows operating system itself, nor does it directly correspond to a layer in the software architecture or OSI model of the Windows operating system. The client in Crashpad is embedded as an external library in the application program to improve the stability and reliability of the application program, and helps developers discover and fix application problems in a timely manner by automatically capturing and reporting crash reports.

[0034] The handler process includes a Crashpad handler. The client process includes at least one client module, which includes a Crashpad client and a CrashpadInfo structure. The CrashpadInfo structure is used to store crash metadata (i.e., the state at the time of the crash). The processing procedures of the Crashpad client and the Crashpad handler are as follows:

[0035] Registration: The Crashpad client registers a CrashpadInfo structure with the Crashpad processor. The Crashpad client connects to a pipe with a pre-arranged name, writes a registration request to the pipe, and during the registration process, the Crashpad processor creates a set of events, copies the events to the registered Crashpad client, and then returns a handle to the crash handler process in the registration response.

[0036] Exception Handling: The Crashpad client also registers an Unhandled Exception Filter (UEF). When a target process crashes, the Crashpad client catches the exception, stores the exception information and the target process's identifier in an exception information structure, and then sends a signal to the Crashpad handler for processing. The Crashpad client stores crash metadata in a CrashpadInfo structure, enabling interaction between the client and the Crashpad handler to send crash metadata. Crash metadata includes the following: crash time (the specific time the target process crashed); target process version (the version information of the target process at the time of the crash); operating system information, including the operating system version; crash cause or error code; stack trace (register information, stack information, and memory information at the time of the crash, helping developers locate the problem); and operating system information, including the operating system version, the target process's command line, and environment variables.

[0037] Creating crash report files: The Crashpad processor can dump crash metadata in the form of a CrashpadInfo structure into crash report files, store them in the Crashpad database, and also upload crash report files to the server.

[0038] like Figure 2 As shown, the specific process by which Crashpad generates crash report files named with UUIDs includes S101-S112.

[0039] S101, Target process initialization crash report.

[0040] The target process refers to a process that is detected to crash, i.e., a client process in which the Crashpad client is embedded. The target process opens or creates a database of a crash report by calling an Initialize function of the CrashReportDatabase module. A path of the database can be input as a parameter into the Initialize function. The CrashReportDatabase module is used to manage a crash report file and related metadata.

[0041] It should be noted that the module involved in the embodiments of the present application can refer to a class in object-oriented programming software code.

[0042] S102, the CrashReportDatabase module initializes the crash report.

[0043] The CrashReportDatabase module initializes the crash report by calling an InitializeInternal function, and then calling an InitializeInternal function of the CrashReportDatabaseWin module. The CrashReportDatabaseWin module is inherited from the CrashReportDatabase module and is used in a window The operating system specifically implements operations of a crash report file and related metadata.

[0044] S103, the target process starts a Crashpad handler process.

[0045] The target process starts the Crashpad handler process by calling a StartHandler function of the CrashpadClient module. The CrashpadClient module is used to detect a crash of the target process. The StartHandler function is used to start the Crashpad handler process, and perform a necessary handshake process to configure the Crashpad handler process.

[0046] S104, the CrashpadClient module configures the Crashpad handler.

[0047] The CrashpadClient module calls a HandlerMain function in the handler_main file. The HandlerMain function has a command line of the target process as a parameter. The HandlerMain function parses the command line of the target process, thereby realizing configuration of the Crashpad handler.

[0048] The HandlerMain function is the main function of the Crashpad handler. The HandlerMain function is publicly accessible so that the Crashpad handler can be embedded in another piece of code, but the HandlerMain function can be called or used like a standalone executable.

[0049] In In an operating system, the command line of a target process is stored in a process environment block (PEB). The command line of a target process can include the address of the target process (the file path of the target process and the name of the target process), such as "C:\\Program Files(x86)\\ProcessName.exe", the first "\" in the string "\\\" is an escape character, indicating that the following "\" is escaped as a real backslash symbol "\". So the real address of the target process is C:\Program Files(x86)\ProcessName.exe, the file path of the target process is C:\Program Files(x86)\, and the name of the target process is ProcessName.

[0050] In S105, the HandlerMain function starts the exception handling server.

[0051] The HandlerMain function calls the InitializeWithInheritedDataForInitialClient function and the Run function of the ExceptionHandlerServer module in sequence, and the Run function further calls the ServiceClientConnection function of the ExceptionHandlerServer module.

[0052] The ExceptionHandlerServer module is used to run the main exception handling server in the Crashpad handler process. The InitializeWithInheritedDataForInitialClient function of the ExceptionHandlerServer module is used to set the pipe to be listened to by the client registered. The Run function of the ExceptionHandlerServer module is used to run the exception handling server. The ServiceClientConnection function of the ExceptionHandlerServer module is used for the management of the connection between the client and the server, including the registration, closing, Ping, and other functions of the connection.

[0053] S106. In response to a crash in the target process, the CrashPadClient module is triggered to handle the pointer to the exception information.

[0054] The pointer to the exception information, EXCEPTION_POINTERS, is... The platform's structure includes pointers to the exception record (EXCEPTION_RECORD) and the context record (CONTEXT). When the target process crashes due to an exception (such as accessing a null pointer, division by zero, etc.), The operating system generates a pointer to the exception information and passes it to the exception handling function—the DumpAndCrash function of the CrashPadClient module.

[0055] The `DumpAndCrash` function in the `CrashPadClient` module captures a pointer to an exception and then processes it. The `DumpAndCrash` function takes a pointer to the exception as its input. The `DumpAndCrash` function then calls the `UnhandledExceptionHandler` function, which handles pointers to unhandled exceptions. The `UnhandledExceptionHandler` function also takes a pointer to the exception as its input.

[0056] For example, after the main process of the SuperWorkbench program starts, it begins running the target process (such as sharing a camera or desktop). The target process initiates IPC (Inter-Process Communication) to communicate with the main process of the SuperWorkbench program. If the user forcibly exits the main process of the SuperWorkbench program, the main process may not have had time to reclaim the IPC resources. This could lead to a null pointer exception if the target process continues to access the IPC resources, resulting in an error message and the crash of the target process.

[0057] S107. The CrashPadClient module notifies the ExceptionHandlerServer module to capture exception information.

[0058] The UnhandledExceptionHandler function calls the SetEvent function. The SetEvent function is... A function in the application programming interface (API) for inter-thread communication and synchronization, used to signal a target process to crash, thus notifying threads waiting for the signal to handle it. In the embodiments of the present application, the SetEvent function is used to notify the OnCrashDumpEvent function of the ExceptionHandlerServer module to dump the crash report, and terminate the Crashpad client after completion. The input parameter of the SetEvent function is the signal of the exception information.

[0059] S108, the ExceptionHandlerServer module notifies the CrashReportExceptionHandler module to dump the crash report.

[0060] The OnCrashDumpEvent function of the ExceptionHandlerServer module converts the pointer of the exception information into the ClientData, and calls the ExceptionHandlerServerException function of the CrashReportExceptionHandler module. The CrashReportExceptionHandler module is used to dump the crash report when the exception occurs. The ExceptionHandlerServerException function is used to dump the crash report, and the input parameters of the ExceptionHandlerServerException function include the process identifier (PID) of the target process in the ClientData, the address of the crash exception information, and the like.

[0061] S109, the CrashReportExceptionHandler module notifies the CrashReportDatabaseWin module to create the crash report.

[0062] The ExceptionHandlerServerException function of the CrashReportExceptionHandler module suspends the process of the Crashpad client, and calls the Initialize function of the ProcessSnapshotWin module.

[0063] The ProcessSnapshotWin module is used to take a snapshot of the current state of a target process. The input parameter to the Initialize function of the ProcessSnapshotWin module includes the crash exception information address, and the Initialize function of the ProcessSnapshotWin module is used to read the exception information from memory based on the crash exception information address.

[0064] The ExceptionHandlerServerException function of the CrashReportExceptionHandler module calls the PrepareNewCrashReport function of the CrashReportDatabaseWin module to create a crash report. The ExceptionHandlerServerException function of the CrashReportExceptionHandler module calls the FinishedWritingCrashReport function of the CrashReportDatabase module to populate the crash report with content.

[0065] S110, the CrashReportDatabaseWin module notifies the CrashReportDatabase module to create a crash report.

[0066] The PrepareNewCrashReport function of the CrashReportDatabaseWin module calls the Initialize function of the NewReport submodule of the CrashReportDatabase module to create a crash report.

[0067] S111, the CrashReportDatabase module notifies the UUID module to assign a UUID to the crash report.

[0068] The Initialize function of the NewReport submodule of the CrashReportDatabase module calls the InitializeWithNew function of the UUID module to assign a UUID to the crash report. The UUID module is used to generate UUIDs, the InitializeWithNew function of the UUID module uses standard system tools to generate a UUID, and the InitializeWithNew function of the UUID module returns the UUID.

[0069] S112, the CrashReportDatabase module dumps the crash report to a crash report file named with the UUID.

[0070] The Initialize function of the NewReport submodule of the CrashReportDatabase module dumps the crash report as a crash report file named with a UUID, suffixed with.dmp. For example, the format of the UUID is %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x, where %08x represents 8-bit hexadecimal, %04x represents 4-bit hexadecimal, and %02x represents 2-bit hexadecimal. For example: 3f9d2d1f-a338-4f91-b9ba-1d8d655dcac7.dmp, e71ecaaf-1d6e-4228-9f68-226cb9da3e37.dmp. In combination with the crash report file of ProcessName.exe, the ProcessName.exe file, and the ProcessName.pdb file, the code location causing the crash can be located by parsing.

[0071] This naming method is difficult to read and understand, making it difficult to locate the process that crashed, and a developer needs to parse the crash report file to confirm the process that crashed. To this end, an embodiment of the present application provides a file naming method and an electronic device, which names the crash report file as the name of the process that crashed to help developers locate the process that crashed.

[0072] The electronic device can be a handheld device, a vehicle-mounted device, etc., such as a mobile phone, a tablet, a notebook computer, a palm computer, a mobile internet device (MID), a virtual reality (VR) device, an augmented reality (AR) device, a wireless device in industrial control, a wireless device in self driving, a wireless device in remote medical surgery, a wireless device in smart grid, a wireless device in transportation safety, a wireless device in smart city, a wireless device in smart home, a cellular phone, a cordless phone, a session initiation protocol (SIP) phone, a wireless local loop (WLL) station, a personal digital assistant (PDA), a handheld device with wireless communication function, a personal computer (PC), a computing device or other processing device connected to a wireless modem, a vehicle-mounted device, a wearable device, a terminal device in a 5G network, or a terminal device in a future evolved public land mobile network (PLMN), etc., and the embodiments of the present application are not limited thereto. The first electronic device and the second electronic device can also be wearable devices. For example, smart watches or smart glasses, etc., and only focus on a certain type of application function, which can be used in cooperation with other devices such as smart phones, such as various types of smart wristbands, smart jewelry, etc. The first electronic device and the second electronic device can also be terminal devices in an internet of things (IoT) system.

[0073] As Figure 3As shown, the electronic device 101 can include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headset interface 270D, a sensor module 280, a key 290, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, and the like.

[0074] It can be understood that the structure shown in the embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.

[0075] The processor 210 can include one or more processing units, for example: the processor 210 can include a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processing unit (CPU), a network processor (NP), a microcontroller unit (MCU), a programmable logic device (PLD), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), and the like. Among them, different processing units can be independent devices, or can be integrated in one or more processors.

[0076] The charging management module 240 is configured to receive charging input from a charger. The charger can be a wireless charger or a wired charger. The charging management module 240 charges the battery 242 and also supplies power to the electronic device through the power management module 241.

[0077] The power management module 241 is configured to connect the battery 242 and the charging management module 240. The power management module 241 receives input from the battery 242 and / or the charging management module 240, and supplies power to the processor 210, the internal memory 221, the external memory, the display screen 294, the camera 293, the wireless communication module 260, and the like. The power management module 241 can also be configured to detect parameters such as battery capacity, battery cycle count, battery health status (leakage, impedance), and the like.

[0078] The electronic device can realize the display function through the GPU, the display screen 294, and the application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display screen 294 and the application processor. The GPU is configured to perform mathematical and geometric calculations for graphics rendering. The processor 210 can include one or more GPUs that execute program instructions to generate or change display information.

[0079] The electronic device can realize the photographing function through the ISP, the camera 293, the video codec, the GPU, the display screen 294, and the application processor, and the like.

[0080] The external memory interface 220 can be configured to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 210 through the external memory interface 220 to realize data storage functions. For example, music, video, and the like are stored in the external memory card.

[0081] The internal memory 221 can be configured to store computer executable program codes including instructions. The processor 210 executes various function applications and data processing of the electronic device by running the computer instructions stored in the internal memory 221, such as the file naming method of the embodiments of the present application. The internal memory 221 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, and the like), and the like. The data storage area can store data created during use of the electronic device (such as audio data, a phonebook, and the like), and the like. In addition, the internal memory 221 can include a high-speed random access memory, and can also include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.

[0082] The memory to which embodiments of the present application are directed can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example and not limitation, many forms of RAM can be used, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct Rambus RAM (DR RAM). It should be noted that the memory of the system and method described herein is intended to include, but not be limited to, these and any other suitable types of memory.

[0083] The electronic device can implement an audio function through the audio module 270, the speaker 270A, the receiver 270B, the microphone 270C, the earphone interface 270D, and the application processor, etc. For example, music play, recording, etc.

[0084] The key 290 includes a power on key, a volume key, a keyboard, etc. The key 290 can be a mechanical key. It can also be a touch type key. The electronic device can receive a key input, generate a key signal input related to user settings and function control of the electronic device.

[0085] The indicator 292 can be an indicator light, which can be used to indicate a charging state, a power change, and can also be used to indicate a message, a missed call, a notification, etc.

[0086] The SIM card interface 295 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 295 to achieve contact and separation with the electronic device. The electronic device can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 295 can support Nano SIM cards, Micro SIM cards, and other SIM cards.

[0087] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor. Mobile communication module 250 can perform 2G / 3G / 4G / 5G mobile communication. Wireless communication module 260 can perform Bluetooth (BT), wireless local area network (WLAN), global navigation satellite system (GNSS), near field communication (NFC), infrared (IR), and frequency modulation (FM) technologies.

[0088] like Figure 4 As shown, this application embodiment provides a file naming method, including: S201-S215. Wherein, steps S201-S208 refer to... Figure 2 S101-S108 shown will not be described again here.

[0089] S201, Target process initialization crash report.

[0090] S202, CrashReportDatabase module initialization crash report.

[0091] S203, The target process starts the Crashpad processing end process.

[0092] S204, CrashpadClient module configures the Crashpad processing end.

[0093] S205, the HandlerMain function starts the exception handling server.

[0094] S206. In response to a crash in the target process, the CrashPadClient module is triggered to handle the pointer to the exception information.

[0095] S207, the CrashPadClient module notifies the ExceptionHandlerServer module to capture exception information.

[0096] S208, the ExceptionHandlerServer module notifies the CrashReportExceptionHandler module to dump a crash report.

[0097] S209, the CrashReportExceptionHandler module obtains a target string from the ProcessSnapshotWin module.

[0098] The ExceptionHandlerServerException function of the CrashReportExceptionHandler module calls the GetProcessName function of the ProcessSnapshotWin module.

[0099] S210, the ProcessSnapshotWin module obtains a command line of the target process from the ProcessInfo module.

[0100] The GetProcessName function of the ProcessSnapshotWin module calls the GetCommandLine function of the ProcessInfo module, the GetCommandLine function is a custom function, the input parameter of the GetCommandLine function is empty, and the parameter returned by the GetCommandLine function is a command line of the target process in the form of a string. The ProcessInfo module is used to collect information of the target process, mainly including information stored in the PEB, such as a command line of the target process.

[0101] The content of the command line of the target process is referred to S104, and will not be described here.

[0102] S211, the ProcessSnapshotWin module parses the command line of the target process to obtain the name of the target process.

[0103] The command line of the target process can include the address of the target process, such as "C:\\Program Files(x86)\\ProcessName.exe". The GetProcessName function of the ProcessSnapshotWin module can find the position of the last "\" in the command line from back to front by calling the std::wstring::rfind function, and can also find the position of the last ".exe" in the command line from back to front by calling the std::wstring::rfind function. The first "\" in the string "\." is also an escape character, indicating that the following character "." is escaped to the real separator character ".". Then the GetProcessName function of the ProcessSnapshotWin module can obtain the name of the target process ProcessName by calling the std::wstring::substr function to cut the string in the command line from the position lastSlashPos+1 to the length of lastExePos-(lastSlashPos+1).

[0104] The parameter returned by the GetProcessName function of the ProcessSnapshotWin module to the ExceptionHandlerServerException function of the CrashReportExceptionHandler module is a target string in the form of a string, and the target string includes the name of the target process.

[0105] In S212, the ProcessSnapshotWin module further obtains the current time and / or the version number of the target process.

[0106] S212 is optional. The GetProcessName function of the ProcessSnapshotWin module can obtain the current time and the version number of the target process by calling the API.

[0107] The target string returned by the GetProcessName function of the ProcessSnapshotWin module to the ExceptionHandlerServerException function of the CrashReportExceptionHandler module, in addition to including the name of the target process obtained through S211, optionally includes the current time and / or the version number of the target process obtained through S212.

[0108] ​If the GetProcessName function of the ProcessSnapshotWin module acquires the current time, the GetProcessName function of the ProcessSnapshotWin module string-splices the name of the target process and the current time, the name of the target process and the current time can be separated by an underscore “_”, the target string can be in the form of the name of the target process _ the current time. For example, if the name of the target process is ProcessName and the current time is Time, the target string is ProcessName_Time.

[0109] If the GetProcessName function of the ProcessSnapshotWin module acquires the version number of the target process, the GetProcessName function of the ProcessSnapshotWin module string-splices the name of the target process and the version number of the target process, the name of the target process and the version number of the target process can be separated by an underscore “_”, the target string can be in the form of the name of the target process _ the version number of the target process. For example, if the name of the target process is ProcessName and the version number of the target process is Version, the target string is ProcessName_Version.

[0110] If the GetProcessName function of the ProcessSnapshotWin module acquires the current time and the version number of the target process, the GetProcessName function of the ProcessSnapshotWin module string-splices the name of the target process, the current time, and the version number of the target process, the name of the target process, the current time, and the version number of the target process can be separated by an underscore “_”, the target string can be in the form of the name of the target process _ the current time _ the version number of the target process. For example, if the name of the target process is ProcessName, the current time is Time, and the version number of the target process is Version, the target string is ProcessName_Time_Version.

[0111] It should be noted that the embodiments of the present application do not limit the format of the current time Time, and the format of the current time Time can be year-month-day-hour-minute-second-millisecond, for example, 20240710194420861 represents 19:44:20:861 milliseconds on July 10, 2024. The current time Time can also be in other formats, for example, hour-minute-second-millisecond. The embodiments of the present application do not limit the format of the version number Version, for example, the format of the version number Version can be A.B…, and the length of the version number Version and the number of separator symbols "." are not limited, for example, 19.0.0.3. The embodiments of the present application do not limit the order of the name of the target process, the current time, and the version number of the target process, for example, the name of the target process_current time_version number of the target process, the current time_version number of the target process_name of the target process, or the version number of the target process_name of the target process_current time.

[0112] Since the software runs very fast, from the crash of the target process to the running of the current time, the time elapsed is short, which is in milliseconds, and the current time is equivalent to the time of the crash of the target process. The target string includes the current time, which can help the developer analyze the cause of the crash of the target process.

[0113] Since the target process has undergone multiple development iterations, there can be different version numbers, and the target string includes the version number of the target process, which can help the developer analyze which version of the target process crashes.

[0114] In S213, the CrashReportExceptionHandler module notifies the CrashReportDatabaseWin module to create a crash report, and sends the target string.

[0115] The ExceptionHandlerServerException function of the CrashReportExceptionHandler module suspends the process of the Crashpad client, calls the Initialize function of the ProcessSnapshotWin module, the input parameter of the Initialize function of the ProcessSnapshotWin module includes the crash exception information address, and the Initialize function of the ProcessSnapshotWin module reads the exception information from the memory according to the crash exception information address.

[0116] The ExceptionHandlerServerException function of the CrashReportExceptionHandler module calls the PrepareNewCrashReport function of the CrashReportDatabaseWin module to create a crash report. The input parameter of the PrepareNewCrashReport function of the CrashReportDatabaseWin module includes a target string.

[0117] S214, the CrashReportDatabaseWin module notifies the CrashReportDatabase module to create a crash report, and sends the target string.

[0118] The PrepareNewCrashReport function of the CrashReportDatabaseWin module calls the Initialize function of the NewReport submodule of the CrashReportDatabase module to create a crash report. The input parameter of the Initialize function of the NewReport submodule of the CrashReportDatabase module includes a target string.

[0119] S215, the CrashReportDatabase module dumps a crash report as a crash report file named by a target string.

[0120] For example, the name of a target process is ProcessName, the current time is Time, the version number of the target process is Version, and the target string is ProcessName_Time_Version, then the crash report file is ProcessName_Time_Version.dmp, for example, ProcessName_20240710194420861_19.0.0.3.dmp.

[0121] It should be noted that the embodiments of the present application do not limit the suffix of the crash report file to.dmp, but can also be other suffixes.

[0122] The file naming method and the electronic device provided by the embodiments of the present application, in response to the target process crashing, the Crashpad processing end in the Crashpad analyzes the command line of the target process, obtains the name of the target process crashing, sends the target string to the Crashpad client, and the target string includes the name of the target process. The Crashpad client dumps the crash report into a crash report file named by the target string. That is, by naming the crash report file as the name of the process crashing, the developer is helped to locate the process crashing.

[0123] The embodiments of the present application also provide a file naming device for performing the functions of the electronic device in Figure 2 、 Figure 4 . As shown in Figure 5 , the file naming device 50 includes a Crashpad processing end 501 and a Crashpad client 502.

[0124] In some embodiments, in response to the target process crashing, the Crashpad processing end 501 obtains the command line of the target process, and the command line includes the name of the target process.

[0125] The Crashpad processing end 501 analyzes the command line to obtain the name of the target process.

[0126] The Crashpad processing end 501 sends the target string to the Crashpad client 502.

[0127] The Crashpad client 502 dumps the crash report into a crash report file named by the target string, and the target string includes the name of the target process.

[0128] In some embodiments, the Crashpad processing end 501 obtains the current time, and the target string further includes the current time.

[0129] In some embodiments, the Crashpad processing end 501 obtains the version number of the target process, and the target string further includes the version number of the target process.

[0130] In some embodiments, the Crashpad processing end 501 finds the position lastSlashPos of the last "\" in the command line from back to front; finds the position lastExePos of the last ".exe" in the command line from back to front; and obtains the name of the target process by intercepting the string in the command line, starting from the position lastSlashPos+1 and having a length of lastExePos-(lastSlashPos+1).

[0131] In some embodiments, as shown in Figure 5As shown, the Crashpad handling end 501 includes a ProcessSnapshotWin module 5011, a ProcessInfo module 5012, and a CrashReportExceptionHandler module 5013. The ProcessSnapshotWin module 5011 is configured to obtain a snapshot of the current state of the target process. The ProcessInfo module 5012 is configured to collect the command line of the target process. The CrashReportExceptionHandler module 5013 is configured to dump a crash report when an exception occurs.

[0132] The ProcessSnapshotWin module 5011 obtains the command line via the ProcessInfo module 5012.

[0133] After the ProcessSnapshotWin module 5011 parses the command line to obtain the name of the target process, the ProcessSnapshotWin module 5011 sends the target string to the CrashReportExceptionHandler module 5013.

[0134] The CrashReportExceptionHandler module 5013 sends the target string to the Crashpad client 502.

[0135] In some embodiments, as shown, the Crashpad client 502 includes a CrashReportDatabaseWin module 5021 and a CrashReportDatabase module 5022. The CrashReportDatabase module 5022 is configured to manage crash report files and related metadata. The CrashReportDatabaseWin module 5021 inherits from the CrashReportDatabase module 5022 and is configured to implement operations on the crash report files and related metadata. Figure 5

[0136] The CrashReportDatabaseWin module 5021 receives the target string from the CrashReportExceptionHandler module 5013 and sends the target string to the CrashReportDatabase module 5022.

[0137] The CrashReportDatabase module 5022 dumps a crash report as a crash report file named with the target string.

[0138] ​The embodiment of the present application further provides a computer readable storage medium comprising instructions, which, when executed on the electronic device, cause the electronic device to perform each step in the above method embodiment, for example, the method shown in Figure 2 , Figure 4 .

[0139] The embodiment of the present application further provides a computer program product comprising instructions, which, when executed on the electronic device, cause the electronic device to perform each step in the above method embodiment, for example, the method shown in Figure 2 , Figure 4 .

[0140] The technical effects of the computer readable storage medium and the computer program product refer to the technical effects of the above method embodiments.

[0141] It should be understood that, in various embodiments of the present application, the size of the sequence number of each process described above does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0142] Those skilled in the art can realize that the modules and algorithm steps of each example described in connection with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0143] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the above-described system, device and module can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0144] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules or components can be combined or integrated into another device, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed each other can be indirect coupling or communication connection through some interfaces, devices or modules, and can be electrical, mechanical or other forms.

[0145] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, i.e., can be located in one device, or can be distributed to multiple devices. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments.

[0146] In addition, each functional module in each embodiment of the present application can be integrated in one device, or each module can exist physically alone, or two or more modules can be integrated in one device.

[0147] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method of naming a file, characterized by, The method is applied to a Crashpad running on an electronic device, the Crashpad comprising a Crashpad processing end and a Crashpad client, and the method comprises: In response to a crash of a target process, the Crashpad processing end acquires a command line of the target process, the command line comprising a name of the target process; The Crashpad processing end finds a position lastSlashPos of a last "\" in the command line from back to front, finds a position lastExePos of a last "\.exe" in the command line from back to front, and obtains the name of the target process by intercepting a string in the command line, starting from the position lastSlashPos+1 and having a length of lastExePos-(lastSlashPos+1); The Crashpad processing end sends a target string to the Crashpad client, the target string comprising the name of the target process; The Crashpad client dumps a crash report into a crash report file named by the target string.

2. The method of claim 1, wherein, The method further comprises: The Crashpad processing end acquires a current time, and the target string further comprises the current time.

3. The method according to claim 1 or 2, characterized in that, The method further comprises: The Crashpad processing end acquires a version number of the target process, and the target string further comprises the version number of the target process.

4. The method according to claim 1 or 2, characterized in that, The Crashpad processing end comprises a ProcessSnapshotWin module, a ProcessInfo module and a CrashReportExceptionHandler module; the ProcessSnapshotWin module is used to acquire a snapshot of a current state of the target process; the ProcessInfo module is used to collect the command line of the target process; the CrashReportExceptionHandler module is used to dump a crash report when an exception occurs; and the method further comprises: The ProcessSnapshotWin module acquires the command line through the ProcessInfo module; After the ProcessSnapshotWin module obtains the name of the target process by parsing the command line, the ProcessSnapshotWin module sends the target string to the CrashReportExceptionHandler module; The CrashReportExceptionHandler module is used to send the target string to the Crashpad client.

5. The method of claim 4, wherein, The Crashpad client includes a CrashReportDatabaseWin module, a CrashReportDatabase module; the CrashReportDatabase module is used to manage crash report files and related metadata; the CrashReportDatabaseWin module inherits from the CrashReportDatabase module and is used to specifically implement operations on crash report files and related metadata; the method further includes: The CrashReportDatabaseWin module receives the target string from the CrashReportExceptionHandler module and sends the target string to the CrashReportDatabase module; The CrashReportDatabase module converts a crash report into a crash report file named with the target string.

6. An electronic device, comprising: An electronic device including a processor and a memory, the memory storing instructions that, when executed by the processor, cause the electronic device to perform the method of any of claims 1-5.

7. A computer readable storage medium characterized in that, An electronic device including instructions that, when executed on the electronic device, cause the electronic device to perform the method of any of claims 1-5.

8. A computer program product comprising instructions, characterized in that, An electronic device including instructions that, when executed on the electronic device, cause the electronic device to perform the method of any of claims 1-5.

Citation Information

Patent Citations

  • Client crash notification method, device and equipment

    CN112380110A

  • Process name acquisition method, terminal equipment and storage medium

    CN116662045A

  • Data processing method and device

    CN118445103A