Method, device, electronic device, and storage medium for locating program downtime
By obtaining the globally unique identifier and instruction address register address when the BIOS crashes, and combining it with the mapping file to locate the crash function, the problem of difficulty in locating the BIOS crash location in Release mode is solved, and fast and accurate positioning is achieved.
Patent Information
- Application Number
- CN202111598148.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2041-12-27
AI Technical Summary
In Release mode, when the BIOS crashes, logs cannot be output through the serial port for debugging, making it difficult to locate the crash.
By obtaining the global unique identifier and entry physical address of the current program module at the time of the crash, combined with the physical address of the instruction address register, the offset address of the crash function is found using the mapping file and the crash location is output.
It can accurately locate the BIOS crash location without affecting the computer startup time, shortening the analysis cycle.
Smart Images

Figure CN114265779B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer systems, and in particular to a method, device, electronic device, and storage medium for locating a program downtime location. Background Art
[0002] The basic components of a modern computer system include SOC system-on-chip, memory, firmware, input and output devices, storage devices, etc.
[0003] Modern computer BIOS (Basic Input Output System) is implemented according to the UEFI (Unified Extensible Firmware Interface) specification, also known as UEFI BIOS. Its operating modes are divided into the following two modes:
[0004] 1. Debug mode: also known as debug mode. The BIOS in this mode can output boot logs and debug information through serial ports and other means.
[0005] 2. Release mode: Also known as release mode, the BIOS in this mode turns off the debugging information and logs output by the serial port, thereby improving the startup speed.
[0006] During the development of computer systems (chips, personal computers, workstations, servers, etc.), a Release-mode BIOS is often used for BIOS startup or reboot burn-in testing to shorten testing time and improve efficiency. During this process, system crashes are common, and some crashes occur only with a Release-mode BIOS, even though they would not occur with a Debug-mode BIOS in the same environment.
[0007] Release mode BIOS generally uses the post code (power-on self-test code) output to the motherboard's digital tube or other carriers through port 80 to determine the BIOS execution stage. When the Release mode BIOS crashes while the Debug mode BIOS does not crash under the same environment, it is impossible to rely on serial port debugging and other methods to locate the crash location. Summary of the Invention
[0008] The method, device, electronic device, and storage medium for locating a program downtime location provided by the present invention can locate the program downtime location.
[0009] In a first aspect, the present invention provides a method for locating a program downtime location, comprising:
[0010] When a system crash occurs during program execution, obtaining a globally unique identifier of a current program module running at the time of the crash and an entry physical address corresponding to the globally unique identifier of the current program module;
[0011] Reading the physical address of the instruction address register stored in the instruction address register in the system when the system is down;
[0012] Subtracting the entry physical address from the physical address of the instruction address register to obtain a first offset address;
[0013] Obtaining a first mapping file corresponding to the globally unique identifier of the current program module according to a correspondence between the globally unique identifier of the program module and the mapping file; the first mapping file records a correspondence between each function name and an offset address of the function in the program module;
[0014] Searching, according to the first mapping file, a first function name corresponding to the first offset address;
[0015] Searching, according to the first mapping file, for an offset address of a function corresponding to the first function name;
[0016] The offset address of the function corresponding to the first function name is used as the crash location and outputted.
[0017] Optionally, when a system crash occurs during program execution, before the step of obtaining a globally unique identifier of a current program module running at the time of the crash and an entry physical address corresponding to the globally unique identifier of the current program module, the method includes:
[0018] During the compiling phase of the program, a mapping file corresponding to each program module is generated. The mapping file records the correspondence between each function name and the offset address of the function in each program module.
[0019] Optionally, when a system crash occurs during program execution, before the step of obtaining a globally unique identifier of a current program module running at the time of the crash and an entry physical address corresponding to the globally unique identifier of the current program module, the method includes:
[0020] During the running of the program, the globally unique identifier corresponding to the current program module being executed and the corresponding entry physical address are stored in sequence as a record.
[0021] Optionally, during the running of the program, the step of sequentially storing the globally unique identifier and the corresponding entry physical address corresponding to the currently executed program module as a record includes:
[0022] Specify a storage area;
[0023] During the running of the program, the globally unique identifier of the current program module being executed and the corresponding entry physical address are sequentially stored in the storage area as a record.
[0024] Optionally, when the system crashes during program execution, the step of obtaining the globally unique identifier of the current program module running at the time of the crash and the entry physical address corresponding to the globally unique identifier of the current program module is specifically:
[0025] Obtain the globally unique identifier and entry physical address corresponding to the current program module that was last stored before the system crashed.
[0026] Optionally, the step of obtaining the globally unique identifier and entry physical address corresponding to the current program module last stored before the system crash occurs is specifically:
[0027] In the storage area, a globally unique identifier and an entry physical address corresponding to the program module stored last time before the computer crashes are obtained.
[0028] Optionally, the program is a basic input / output system BIOS; and / or
[0029] The storage area is a memory.
[0030] In a second aspect, the present invention further provides a device for locating a program downtime location, comprising:
[0031] A first acquiring unit is configured to acquire, when a system crash occurs during program execution, a globally unique identifier of a current program module running at the time of the crash and an entry physical address corresponding to the globally unique identifier of the current program module;
[0032] A reading unit, configured to read the physical address of the instruction address register stored in the instruction address register in the system when the system is down;
[0033] a calculation unit, configured to subtract the entry physical address from the physical address of the instruction address register to obtain a first offset address;
[0034] a second acquiring unit, configured to acquire, based on a correspondence between a globally unique identifier of the program module and a mapping file, a first mapping file corresponding to the globally unique identifier of the current program module; the first mapping file recording a correspondence between each function name and an offset address of the function in the program module;
[0035] a search unit, configured to search, according to the first mapping file, for a first function name corresponding to the first offset address; and search, according to the first mapping file, for an offset address of a function corresponding to the first function name;
[0036] The output unit is configured to use the offset address of the function corresponding to the first function name as the crash location and output it.
[0037] In a third aspect, the present invention further provides an electronic device comprising the above-mentioned device for locating a program downtime location.
[0038] In a fourth aspect, the present invention further provides a device for locating a program downtime location, comprising:
[0039] Memory;
[0040] and a processor coupled to the memory, wherein the processor is configured to execute the method for locating a program downtime location based on instructions stored in the memory.
[0041] In a fifth aspect, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for locating the location of a program crash is implemented.
[0042] The present invention provides a method, device, electronic device, and storage medium for locating a program crash location. When a system crash occurs during program execution, the method, device, electronic device, and storage medium are used to obtain the current program module running at the time of the crash and the entry physical address corresponding to the current program module; the physical address of the instruction address register stored in the instruction address register RIP in the system at the time of the crash is read; the physical address of the instruction address register is subtracted from the entry physical address to obtain a first offset address; based on the correspondence between the program module and the mapping file, the first mapping file corresponding to the current program module is obtained; the mapping file records each function in the program module and the corresponding offset address; according to the first mapping file, the function corresponding to the first offset address is searched; the offset address of the function corresponding to the function is used as the crash location and outputted, thereby being able to locate the function location of the program at the time of the crash. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A flowchart of a method for locating a program downtime location according to an embodiment of the present invention;
[0044] Figure 2 A flowchart of a method for locating a program downtime location according to another embodiment of the present invention;
[0045] Figure 3 A schematic diagram of the structure of a device for locating a program downtime location according to an embodiment of the present invention;
[0046] Figure 4 This is a schematic diagram of the structure of a device for locating a program downtime location according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0048] The embodiment of the present invention provides a method for locating the location of a program downtime, such as Figure 1 As shown, the method includes:
[0049] Step 11: When a system crash occurs during program execution, the globally unique identifier (GUID) of the current program module running at the time of the crash and the physical address of the entry corresponding to the GUID of the current program module are obtained. The program may be a BIOS or another program. Each program includes multiple program modules, which run at different stages of the program. Each program module includes at least one function.
[0050] Step 12: Read the physical address of the instruction address register stored in the instruction address register in the system when the system is down; wherein the instruction address register is used to store the physical address of the currently executed instruction.
[0051] Step 13, subtracting the entry physical address from the physical address of the instruction address register to obtain a first offset address;
[0052] Step 14: obtaining a first mapping file corresponding to the globally unique identifier of the current program module based on the corresponding relationship between the globally unique identifier of the program module and the mapping file; the first mapping file records the corresponding relationship between each function name and the offset address of the function in the program module;
[0053] Step 15: searching, according to the first mapping file, for a first function name corresponding to the first offset address; and searching, according to the first mapping file, for an offset address of a function corresponding to the first function name;
[0054] Step 16: Use the offset address of the function corresponding to the first function name as the crash location and output it.
[0055] In the above embodiment, when a system crash occurs during program execution, the current program module running at the time of the crash and the entry physical address corresponding to the current program module are obtained; the physical address of the instruction address register stored in the instruction address register RIP in the system at the time of the crash is read; the physical address of the instruction address register is subtracted from the entry physical address to obtain a first offset address; based on the correspondence between the program module and the mapping file, the first mapping file corresponding to the current program module is obtained; the mapping file records each function in the program module and the corresponding offset address; according to the first mapping file, the function corresponding to the first offset address is searched; the offset address of the function corresponding to the function is used as the crash location and output, thereby locating the function location of the program at the time of the crash. The present invention can also be used in the debugging scenario of Release mode BIOS or the debugging scenario of other programs.
[0056] The embodiment of the present invention also provides another method for locating the location of a program downtime, such as Figure 2 As shown, the method includes:
[0057] Step 11A: During the compilation phase of the program, a mapping file corresponding to each program module is generated. The mapping file records the correspondence between each function name and the function offset address in each program module. Each program includes multiple program modules, which run at different stages of the program. Each program module includes at least one function.
[0058] Step 11B, while the program is running, sequentially stores the globally unique identifier and the corresponding entry physical address of the currently executing program module as a record. This step specifically comprises: designating a storage area; and sequentially storing the globally unique identifier and the corresponding entry physical address of the currently executing program module as a record in the storage area while the program is running. The program is BIOS; and / or the storage area is memory.
[0059] Step 11: When a system crash occurs during program execution, the globally unique identifier of the current program module running at the time of the crash and the entry point physical address corresponding to the globally unique identifier of the current program module are obtained. This step specifically involves obtaining the globally unique identifier and entry point physical address corresponding to the current program module last stored before the system crash. Alternatively, this step involves obtaining the globally unique identifier and entry point physical address corresponding to the program module last stored before the crash from the storage area. The storage area may be a memory.
[0060] Step 12, reading the physical address of the instruction address register stored in the instruction address register RIP in the system when the system is down;
[0061] Step 13, subtracting the entry physical address from the physical address of the instruction address register to obtain a first offset address;
[0062] Step 14: obtaining a first mapping file corresponding to the globally unique identifier of the current program module based on the corresponding relationship between the globally unique identifier of the program module and the mapping file; the first mapping file records the corresponding relationship between each function name and the offset address of the function in the program module;
[0063] Step 15: searching, according to the first mapping file, for a first function name corresponding to the first offset address; and searching, according to the first mapping file, for an offset address of a function corresponding to the first function name;
[0064] Step 16: Use the offset address of the function corresponding to the first function name as the crash location and output it.
[0065] The embodiment of the present invention also provides a device for locating the location of a program downtime, such as Figure 3 As shown, the device includes:
[0066] The first acquisition unit 31 is configured to acquire, when a system crash occurs during program execution, a globally unique identifier of a current program module running at the time of the crash and an entry physical address corresponding to the globally unique identifier of the current program module;
[0067] The reading unit 32 is used to read the physical address of the instruction address register stored in the instruction address register in the system when the system is down;
[0068] a calculating unit 33, configured to subtract the entry physical address from the physical address of the instruction address register to obtain a first offset address;
[0069] A second acquiring unit 34 is configured to acquire a first mapping file corresponding to the globally unique identifier of the current program module based on the corresponding relationship between the globally unique identifier of the program module and the mapping file; the first mapping file records the corresponding relationship between each function name and the offset address of the function in the program module;
[0070] A search unit 35 is configured to search, according to the first mapping file, for a first function name corresponding to the first offset address; and search, according to the first mapping file, for an offset address of a function corresponding to the first function name;
[0071] The output unit 36 is configured to output the offset address of the function corresponding to the first function name as the crash location.
[0072] The device of this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0073] An embodiment of the present invention further provides an electronic device including the above-mentioned device for locating a program downtime location.
[0074] The embodiment of the present invention also provides a device for locating the location of a program downtime, such as Figure 4 As shown, the device includes:
[0075] Memory 42;
[0076] and a processor 41 coupled to the memory 42 , wherein the processor 41 is configured to execute the method for locating a program downtime location based on instructions stored in the memory 42 .
[0077] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for locating a program downtime location is implemented.
[0078] The following describes an application scenario of the present invention. This application scenario uses the BIOS as an example. In response to the existing situation in which Release mode BIOS crashes cannot be debugged by relying on serial port output logs, a method for precisely locating the crash location is proposed, effectively shortening the crash analysis cycle.
[0079] UEFI BIOS booting occurs in multiple stages, each consisting of multiple modules (e.g., .efi format files). Each module is associated with a unique globally unique identifier (GUI). During the initial BIOS boot process, a suitable memory address P is specified in the BIOS, and a memory area A is allocated based on this address. Later in the boot process, each program module's GUI and entry address (the physical address of the entry) are stored as a record in A, sequentially in the order in which it was executed.
[0080] When a crash occurs during BIOS operation, use hardware debugging equipment to obtain data in area A through address P. By viewing the last record in area A, you can find the globally unique identifier and entry address of the corresponding crash module.
[0081] During the compilation phase, BIOS generates .efi files and .map files (i.e. mapping files) for each module of the program in the same directory (the same module is in one directory). The .map file records all the function names and their offset addresses in the module.
[0082] The physical address of the RIP address (i.e., the physical address of the instruction address register) minus the Entry address (the entry physical address) results in an offset address B, which is the first offset address mentioned above.
[0083] Compare the offset address B with the addresses in the.map file to obtain the name of the function where the current crash occurs. For example: If the addresses of two adjacent functions F1 and F2 in the.map file are M1 and M2 respectively, and if B >= M1 and B < M2, then the function to be found is F1. Then, find the offset address of the function corresponding to F1 and output the offset address to locate the crash position of the program.
[0084] The present invention can record the BIOS execution process through the memory address space without affecting the computer startup time, and can quickly locate the BIOS crash position without affecting the computer startup time.
[0085] Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0086] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A method for locating a program downtime location, characterized in that: include: When the program is running, the globally unique identifier and the corresponding entry physical address corresponding to the current program module being executed are sequentially stored as a record. When the system crashes, the globally unique identifier of the current program module running at the time of the crash and the entry physical address corresponding to the globally unique identifier of the current program module are obtained, specifically: the globally unique identifier and the entry physical address corresponding to the current program module stored for the last time before the system crashes are obtained; Reading the physical address of the instruction address register stored in the instruction address register in the system when the system is down; Subtracting the entry physical address from the physical address of the instruction address register to obtain a first offset address; Obtaining a first mapping file corresponding to the globally unique identifier of the current program module according to a correspondence between the globally unique identifier of the program module and the mapping file; The first mapping file records the correspondence between each function name and the offset address of the function in the program module; Searching, according to the first mapping file, for a first function name corresponding to the first offset address; and searching, according to the first mapping file, for an offset address of a function corresponding to the first function name; The offset address of the function corresponding to the first function name is used as the crash location and outputted.
2. The method according to claim 1, characterized in that Before the step of obtaining the globally unique identifier of the current program module running at the time of the system downtime and the entry physical address corresponding to the globally unique identifier of the current program module when the system downtime occurs during program running, the method includes: During the compiling phase of the program, a mapping file corresponding to each program module is generated. The mapping file records the correspondence between each function name and the offset address of the function in each program module.
3. The method according to claim 1, characterized in that The step of sequentially storing the globally unique identifier and the corresponding entry physical address corresponding to the currently executed program module as a record during program execution includes: Specify a storage area; When the program is running, the globally unique identifier of the current program module being executed and the corresponding entry physical address are sequentially stored in the storage area as a record.
4. The method according to claim 3, characterized in that The step of obtaining the globally unique identifier and entry physical address corresponding to the current program module last stored before the system crashes is specifically as follows: In the storage area, a globally unique identifier and an entry physical address corresponding to the program module stored last time before the computer crashes are obtained.
5. The method according to claim 3, characterized in that The program is a basic input / output system BIOS; and / or The storage area is a memory.
6. A device for locating a program downtime location, characterized in that: include: a first acquisition unit, configured to acquire, when a system crash occurs during program execution, a globally unique identifier of a current program module running at the time of the crash and an entry physical address corresponding to the globally unique identifier of the current program module, specifically by acquiring the globally unique identifier and entry physical address corresponding to the current program module last stored before the system crash occurs, wherein, when the program is running, the globally unique identifier and the entry physical address corresponding to the current program module being executed are sequentially stored as a record; A reading unit, configured to read the physical address of the instruction address register stored in the instruction address register in the system when the system is down; a calculation unit, configured to subtract the entry physical address from the physical address of the instruction address register to obtain a first offset address; a second acquiring unit, configured to acquire, based on a correspondence between a globally unique identifier of the program module and a mapping file, a first mapping file corresponding to the globally unique identifier of the current program module; the first mapping file recording a correspondence between each function name and an offset address of the function in the program module; a search unit, configured to search, according to the first mapping file, for a first function name corresponding to the first offset address; and search, according to the first mapping file, for an offset address of a function corresponding to the first function name; The output unit is configured to use the offset address of the function corresponding to the first function name as the crash location and output it.
7. An electronic device, characterized in that: The electronic device includes the device for locating a program downtime position as claimed in claim 6.
8. A device for locating a program downtime location, comprising: Memory; and a processor coupled to the memory, wherein the processor is configured to execute the method for locating a program downtime position according to any one of claims 1 to 5 based on instructions stored in the memory.
9. A computer-readable storage medium, wherein: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for locating a program downtime position according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Microprocessor that translates conditional load / store instructions into variable number of microinstructions
CN103765401A
BIOS error positioning method and device, equipment and storage medium
CN112463431A