Embedded stack symbolization and source location method for crash and electronic device

By constructing a symbolic and path mapping method on computer devices, the problem of tracing back the file address to the local source code when an embedded device crashes is solved, achieving efficient and accurate crash analysis and improving the efficiency and accuracy of embedded software debugging.

CN123068261APending Publication Date: 2026-11-10BEIMI TECHNOLOGY (ZHUHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611314387.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-27
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

When an embedded device crashes, existing technologies struggle to efficiently and accurately locate the call stack address in the backtrace file to the corresponding line of code in the local source code on the developer's computer. Furthermore, existing tools rely on the Linux platform and lack integration with the code editor, resulting in inconsistent paths and difficulties in locating the problem.

Method used

This paper provides a method for symbolization and source code location of embedded crash stacks. By obtaining the storage paths of backtracking files, firmware image files and local source code root directories, symbolization tools are used to construct symbolic commands on the computer device, symbolic text is captured and parsed, structured entries are displayed, and the local source code path and line number are directly located through path mapping and editor command invocation.

Benefits of technology

It enables offline symbolization of crash stacks on the developer's computer device, automatically handles path inconsistency issues, improves crash analysis efficiency, reduces human error, and does not require switching operating systems. The symbolization results are intuitive and easy to view.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123068261A_ABST
    Figure CN123068261A_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of embedded software debugging, and discloses a method for symbolizing and source code positioning of an embedded crash stack and an electronic device. The method comprises: obtaining a backtracking file of an embedded device, a storage path of a firmware image file, and a local source code root directory; identifying a backtracking line from the backtracking file and extracting a call stack address; constructing a symbolization command and calling a symbolization tool to execute according to the same, and capturing symbolization text; parsing the symbolization text into entries containing an address, a function name, a source file path, and a line number, and displaying the entries in a list; converting the source file path from a compile-time path to a local source code path according to a preset path mapping rule; in response to a selected operation on an entry, generating and executing an editor call command containing a local source code path and a line number, and calling a code editor to position to a corresponding code line. The present disclosure can complete symbolization without switching operating systems, realize one-key positioning of a crash address to a source code line, and improve crash analysis efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of embedded software debugging technology, and in particular to the symbolization and source code location technology of embedded crash stacks. Background Technology

[0002] The descriptions in this section are intended to provide background information for the implementation of this disclosure and should not be construed as an admission or implication that they constitute prior art.

[0003] Embedded devices typically use ARM architecture processors, and their software is compiled into firmware image files carrying debugging information. When software crashes on the device due to null pointer access, stack overflow, or other issues, the system outputs backtrace information containing function call stack addresses and saves it as a backtrace file. Developers need to use the debugging information in the firmware image file to convert the addresses into function names, source file paths, and line numbers to analyze the cause of the crash. Currently, developers typically use command-line tools like addr2line in the Linux toolchain to perform symbolization in a Linux environment, viewing the output text line by line in the command-line window, and then searching for the corresponding files and line numbers in their local source code from memory or manually. This process relies on the Linux platform, which is disconnected from the desktop development environment of most embedded application developers; the command-line output is scattered and not intuitive; the firmware image file records the absolute path of the source code on the compiler, which is often inconsistent with the developer's local path, and the parsed path cannot be directly used to open the source code; there is also a lack of interaction between the symbolization result and the code editor. Existing online debugging plugins require the debugger to connect to the device in real time, targeting real-time debugging rather than offline parsing of the generated backtrace file. Summary of the Invention

[0004] This disclosure provides a method and electronic device for symbolizing and locating the source code of an embedded crash stack. One technical problem it can solve is how to efficiently and accurately locate the call stack address in the backtrace file generated when an embedded device crashes to the corresponding line of code in the local source code on the developer's computer device.

[0005] According to one aspect of this disclosure, a method for symbolization and source code location of an embedded crash stack is provided, applied to a computer device, the computer device having a symbolization tool and a code editor installed, the symbolization tool being used to convert program addresses into function names, source file paths, and line numbers based on debugging information, the method comprising: Obtain the backtrack file generated when the embedded device crashes, the storage path of the firmware image file containing the debugging information of the embedded device, and the configured local source code root directory; Identify backline lines containing call stack addresses from the backline file, and extract the call stack addresses from the backline lines; A symbolic command is constructed based on the storage path of the firmware image file and the call stack address; The symbolization tool is invoked on the computer device to execute the symbolization command, and the symbolized text output by the symbolization tool is captured; The symbolic text is parsed to obtain a structured entry containing the call stack address, the function name, the source file path, and the line number, and the structured entry is displayed in the result list; According to the preset path mapping rules, based on the local source code root directory, the source file path in the structured entry is converted from the compile-time path to the local source code path pointing to the local source code file on the computer device; In response to the selection of a target item in the result list, an editor invocation command is generated that includes the local source code path and the line number of the target item, and the editor invocation command is executed to invoke the code editor to open the local source code file corresponding to the local source code path and locate the line of code corresponding to the line number.

[0006] In a preferred embodiment, identifying the backtrack line containing the call stack address from the backtrack file includes: The backtracking file is scanned line by line. Lines that contain a preset backtracking keyword at the beginning or in the middle of the line are identified as backtracking lines, and the remaining lines are identified as non-backtracking lines. The backtracking rows and the non-backtracking rows are displayed separately, and the backtracking rows are marked in a way that is different from the display of the non-backtracking rows.

[0007] In a preferred embodiment, the step of invoking the symbolization tool on the computer device to execute the symbolization command and capturing the symbolized text output by the symbolization tool includes: Create an anonymous pipe and redirect the standard output and standard error of the subprocess used to run the symbolization tool to the anonymous pipe; The child process is created by hiding the command line window, and the symbolic command is executed by the child process. The symbolic text output by the child process is read from the anonymous pipe.

[0008] In a preferred embodiment, parsing the symbolic text includes: The symbolized text is divided into lines to be parsed; In the line to be parsed, the call stack address is obtained by segmenting according to the address separator, the function name is obtained by segmenting according to the preset linking key, and by reverse searching for the last line number separator in the line to be parsed, the part after the preset linking key and before the line number separator is segmented into the source file path, and the part after the line number separator is segmented into the line number; Remove additional debugging information following the line number from the line to be parsed.

[0009] In a preferred embodiment, the step of converting the source file path in the structured entry from a compile-time path to a local source code path pointing to the local source code file on the computer device based on the local source code root directory according to a preset path mapping rule includes: Locate the preset anchor directory in the source file path; Replace the part of the source file path before the anchor directory with the local source code root directory, and retain the part of the source file path starting from the anchor directory to obtain the local source code path.

[0010] In a preferred embodiment, generating the editor invocation command that includes the local source code path and the line number of the target entry includes: The local source code path and the line number are concatenated together using a preset location separator to form a location parameter; The positioning parameters are combined with the code editor's startup command as command-line arguments to obtain the editor invocation command.

[0011] In a preferred embodiment, the backtrack line includes a register record line that records the processor register values ​​when the embedded device crashes, the backtrack file also includes a stack dump line that records the stack memory contents when the crashes, the call stack address includes the program counter value and link register value extracted from the register record line, and the symbolization tool includes a debugger in the toolchain; The method further includes: Extract the set of registers, including the link register value, exception return value, main stack pointer and process stack pointer, from the register record line, and concatenate the stack dump line with consecutive words according to its starting address to form a memory image; When the link register value in the register set is an exception return value, the stack pointer and exception frame length used before the exception occurred are determined according to the preset bit of the exception return value. The register value pushed onto the stack by the hardware is read from the exception frame located at the determined stack pointer in the memory image to obtain the register set before the exception occurred. The above reading is repeated when the read link register value is still an exception return value to obtain multiple register sets corresponding to nested multi-level exceptions. The register set and the multiple register sets constitute a hierarchical list. A pseudo-debugging target is created on the computer device. In response to the debugger's register read request, the pseudo-debugging target returns the register group corresponding to the currently selected thread in the hierarchy list. In response to the debugger's memory read request, it returns bytes in the memory image when the requested address falls within the memory image, and reads bytes from the firmware image file according to the file offset of the loadable segment when the requested address falls within the loadable segment of the firmware image file. The step of constructing a symbolic command based on the storage path of the firmware image file and the call stack address includes: constructing the symbolic command containing a command to load the firmware image file, a command to connect the pseudo-debugging target, and a stack unwinding command, wherein the call stack address is contained in the register set and provided to the debugger via the pseudo-debugging target; the symbolic text is the frame information output by the debugger based on the register set and the memory image after executing the stack unwinding command; When the frame information indicates an early interruption of stack unpacking, each word in the memory image after the stack pointer of the last frame is verified as a candidate return address. The verification conditions include that the candidate return address falls within the executable segment of the firmware image file and that the instruction before the candidate return address is a calling instruction. The frame corresponding to the candidate return address that passes the verification is added to the structured entry as an inferred frame, and the inferred frame and the frame obtained from the frame information are distinguished and displayed in the result list with different source labels.

[0012] In a preferred embodiment, obtaining the storage path of the firmware image file containing the debugging information of the embedded device includes: extracting at least one build identifier of the firmware of the embedded device from the backtrace file; searching in the symbol repository for one or more firmware image files whose build identifier matches the extracted build identifier; and using the storage path of each found firmware image file as the storage path of the firmware image file; when the backtrace file does not contain the build identifier or no matching firmware image file is found, comparing the function names printed in the backtrace file with the function names obtained by symbolizing the candidate firmware image files frame by frame and calculating the consistency rate; selecting the candidate firmware image file with the highest consistency rate; and determining that the build identifier does not match when the consistency rate is lower than a preset threshold; wherein, the symbol repository stores at least one firmware image file and an image list, and the image list records the build identifier, link base address, executable segment address range, and source code submission identifier of each firmware image file; The step of constructing a symbolic command based on the storage path of the firmware image file and the call stack address includes: determining the firmware image file to which the call stack address belongs based on the executable segment address range; subtracting the address correction amount of the firmware image file from the call stack address to obtain the corrected address; and constructing the symbolic command based on the storage path of the firmware image file and the corrected address. The address correction amount is the difference between the running base address of the firmware on the embedded device and the link base address. The running base address is taken from the backtracking file; or, if the backtracking file does not record the running base address, the candidate correction amount that results in the highest proportion of instructions preceding the corrected call stack address being call instructions is selected from a preset set of candidate correction amounts as the address correction amount. The preset path mapping rule includes: based on the source code commit identifier in the image manifest, checking out the source code working tree consistent with the firmware compilation time in the version library corresponding to the local source code root directory, and converting the compilation time path into the local source code path pointing to the corresponding file in the source code working tree; or, the method further includes: based on the difference block between the source code file corresponding to the source code commit identifier and the local source code file, converting the line number in the structured entry into the corresponding line number in the local source code file; The method further includes: determining the credibility level of the structured entry based on whether the build identifier matches, whether the corrected address falls within the executable segment of the firmware image file to which it belongs, and whether the local source code file has been modified relative to the source code submission identifier; displaying the credibility level in the result list; and disabling the selection operation of the corresponding structured entry and displaying the failed verification steps in the result list when the credibility level is untrustworthy.

[0013] According to another aspect of this disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the embedded crash stack symbolization and source code location method described above.

[0014] According to another aspect of this disclosure, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the embedded crash stack symbolization and source code location method described above.

[0015] In the embodiments of this disclosure, by obtaining the storage paths of the backtrace file and firmware image file, and the local source code root directory, backtrace lines are identified from the backtrace file and call stack addresses are extracted. Based on this, symbolic commands are constructed and executed by a symbolic tool on a computer device. The symbolic text is captured, parsed into structured entries containing call stack addresses, function names, source file paths, and line numbers, and displayed in a result list. The source file path is converted from a compile-time path to a local source code path according to a preset path mapping rule. Then, in response to the selection of a target entry, an editor call command containing the local source code path and line number is generated and executed to invoke the code editor and locate the corresponding code. CodeLine can perform offline symbology of crash stacks directly on the computer devices developers use daily, without switching to other operating systems; it can convert originally scattered command-line text into structured list information, making it easier for developers to intuitively view the crash call stack; it can automatically eliminate the location obstacles caused by the inconsistency between the compile-time path in the firmware image file and the developer's local path; it can complete the jump from the crash address to the source code line with a single selection operation, saving the process of manually searching in the source code, thereby improving the efficiency of crash analysis and reducing human error. At the same time, since it is based on the existing interface implementation of the toolchain and code editor, there is no need to modify the underlying tools, making it easy to deploy.

[0016] Furthermore, by using the appearance of preset backtracking keywords at the beginning or middle of a line as a criterion to distinguish backtracking lines from non-backtracking lines, and by classifying and displaying the two and marking backtracking lines in a distinctive way, the crash call stack can be automatically and reliably extracted from backtracking files containing a large amount of irrelevant content, enabling developers to quickly locate the crash record.

[0017] Furthermore, by creating an anonymous pipe and redirecting the standard output and standard error of the child process running the symbolization tool to that pipe, the child process can be created in a way that hides the command line window and reads the symbolized text from the pipe. This allows symbolization to be completed silently without popping up the command line window, avoiding interruption of the user's graphical interface operation, and also capturing the alarm information of the symbolization tool.

[0018] Furthermore, by splitting the symbolized text line by line, and sequentially segmenting the call stack address, function name, source file path, and line number based on the address separator, the preset connection keyword, and the last line number separator obtained from the reverse lookup, and removing the additional debugging information after the line number, it can accurately parse each field even when the source file path itself contains separators or the output contains additional information, and is compatible with various output formats of symbolization tools.

[0019] Furthermore, by locating the anchor directory in the source file path, replacing the path portion before the anchor directory with the local source code root directory and retaining the path portion starting from the anchor directory, path mapping can be completed with only the configuration of a local source code root directory, and is not affected by changes in the working area position on the compiler. It is simple to configure and highly adaptable.

[0020] Furthermore, by concatenating the local source code path and line number with a preset positioning separator to obtain the positioning parameter, and then combining it with the code editor's startup command to obtain the editor invocation command, different code editors can be adapted simply by changing the positioning separator and the startup command, thus improving the versatility of the solution.

[0021] Furthermore, by extracting register sets from register record lines and stack dump lines and splicing memory images, and reading exception frames layer by layer according to preset bits of exception return values ​​to reconstruct multiple register groups before nested exceptions, a pseudo-debugging target is created on the computer device to provide the debugger with register groups, memory images, and firmware image file contents. Commands containing loading firmware image files and connecting pseudo-debugging targets with stack unrolling are used as symbolic commands for the debugger to output frame information. When stack unrolling is prematurely interrupted, candidate return addresses are verified based on conditions that they fall within the executable segment and the previous instruction is a call instruction. The inferred frames that pass the verification are supplemented and displayed with different source annotations. Even when the backtrace file only records registers and stack dumps and does not contain a complete call stack, a complete call chain can be recovered offline on the computer device. This distinguishes the exception handling chain from the interrupted task chain to avoid misjudging the root cause, and provides evidence-based and source-identifiable repair results when the stack content is corrupted, without increasing the recording burden on the embedded device.

[0022] Furthermore, by extracting build identifiers from backtracking files and searching for matching firmware image files in a symbol repository storing image lists, the firmware image file to which the call stack address belongs is determined based on the executable segment address range, and the call stack address is corrected using the difference between the run base address and the link base address or an address correction amount automatically selected according to the call instruction ratio. The source code working tree consistent with the compile time is detected based on the source code submission identifier, or the line number is converted based on the difference block. The credibility level is determined based on three verifications: matching the build identifier, the corrected address falling within the executable segment, and whether the local source code has been modified. When the code is untrusted, the selected operation is disabled and the failed verification step is displayed. This can avoid seemingly reasonable but incorrect symbolization results caused by firmware image file version mismatch, uncorrected load offset, or modified local source code. The originally silent error location is transformed into a clear prompt, reducing the analysis time spent by developers on the error location.

[0023] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Various aspects and embodiments of this disclosure can be combined in different ways. This part of the disclosure is not intended to identify key or essential features of the claimed subject matter, nor is it intended to aid in determining the scope of the claimed subject matter. Attached Figure Description

[0024] Figure 1 This is a flowchart illustrating the method for symbolizing and locating the embedded crash stack according to Embodiment 1 of this disclosure; Figure 2 This is a flowchart illustrating the offline call chain recovery method according to Embodiment 2 of this disclosure; Figure 3 This is a flowchart illustrating the method for verifying the credibility of symbolization results according to Embodiment 3 of this disclosure. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this disclosure clearer, the disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0026] Example 1 This embodiment provides a method for symbolic representation and source code location of embedded crash stacks, applied to a computer device. The computer device is equipped with a symbolic representation tool and a code editor. The symbolic representation tool is used to convert program addresses into function names, source file paths, and line numbers based on debugging information. This embodiment uses a personal computer running a desktop operating system as an example, which pre-installs an ARM embedded GNU toolchain. The addr2line program (arm-none-eabi-addr2line) in the toolchain serves as the symbolic representation tool, and a code editor that supports opening files by specified line numbers via command-line parameters is pre-installed. The directories containing the executable files of both are added to the operating system's PATH environment variable. The embedded device is exemplified by a smartwatch using an ARM Cortex-M architecture processor. Its software is written in C / C++ and compiled and linked into an ELF format firmware image file, which carries DWARF format debugging information. When software on an embedded device crashes due to null pointer access, stack overflow, or assertion failure, its fault handler prints the sequence of function call stack memory addresses at the moment of the crash as a log and saves it as a backtrack file. The backtrack file is then copied to the computer device via serial port, log export tool, or log return service. The overall process is as follows: Figure 1 As shown, the process mainly includes seven steps: input acquisition, backtracking line recognition and address extraction, symbolic command construction, symbolic command execution and text capture, symbolic text parsing and display, path mapping, and editor linkage. Each step will be explained in detail below.

[0027] Step 101: Obtain the backtrack file generated when the embedded device crashes, the storage path of the firmware image file containing debugging information, and the configured local source code root directory. The purpose of this step is to prepare three inputs for subsequent symbology and source code location. Specifically, the program provides three sets of file or directory selection controls on the computer device's graphical interface, forming a backtrack file import and display area, a firmware image file directory selection area, and a local source code root directory setting area. The backtrack file import and display area is used to select the backtrack file and display its contents; the firmware image file directory selection area is used to select the directory where the firmware image file is located; and the local source code root directory setting area is used to select the source code root directory checked out locally by the developer. After the user clicks the selection control, the program calls the operating system's file dialog box for the user to select the corresponding file or directory, reads the path returned by the dialog box and saves it in memory as a configuration object. Simultaneously, these three paths can be written to a configuration file for automatic refilling upon the next startup. The storage path for the firmware image file can be obtained by the user directly selecting the firmware image file itself, or by the user selecting a directory and the program enumerating files with the .elf extension within that directory and selecting one. This embodiment uses the latter as an example; for instance, if a firmware image file named m55c0.elf is selected, its storage path is the concatenation of the directory and the filename. The local source code root directory is the top-level directory where the developer stores the source code locally, such as D: / src. The input for this step is the user's selection operation, and the output consists of three configuration items: the traceback file, the storage path for the firmware image file, and the local source code root directory.

[0028] Step 102: Identify the backtrace lines containing call stack addresses from the backtrace file and extract the call stack addresses from these lines. The purpose of this step is to distinguish the lines in the backtrace file that actually record the crash call stack from other content in the log. The backtrace file is usually the runtime log of an embedded device, which contains a lot of irrelevant content such as startup information, status printing, and debug output in addition to the call stack. The lines containing the call stack have an identifiable form, such as containing fixed identifier text followed by one or more hexadecimal addresses starting with 0x. Specifically, the program reads the backtrace file line by line in text mode, and determines whether each line has the form of a call stack line. The determination method can be matching fixed identifier text (i.e., the preset backtrace keywords mentioned later), or matching the regular expression pattern "0x followed by several hexadecimal characters" with a minimum of one match. Lines that match the pattern are determined to be backtrace lines and added to the backtrace line set; the remaining lines are not processed as backtrace lines. The call stack addresses are then extracted from the backtrace line. The extraction method involves locating the content after the identifier text in the line, splitting it into several segments by spaces or commas, verifying each segment as a valid hexadecimal number, and then converting it to an address value. Taking the line "[12345.678] Backtrace: 0x2c4a6ab00x2c4a7120 0x2c4a80f4" in the backtrace file as an example, the extracted call stack addresses are 0x2c4a6ab0, 0x2c4a7120, and 0x2c4a80f4, respectively. The extraction can be performed immediately after identifying the backtrace line, extracting all addresses from it, or after the user selects a specific backtrace line from the list. This embodiment uses the latter as an example, allowing the user to analyze crash records of interest one by one. The input for this step is the backtrace file, and the output is the backtrace line and the extracted call stack addresses.

[0029] Step 103: Construct symbolic commands based on the storage path of the firmware image file and the call stack address. The purpose of this step is to assemble the parameters required by the symbolic tool into directly executable commands. Specifically, when using the addr2line program in the toolchain as the symbolic tool, the template for the symbolic command is "arm-none-eabi-addr2line -pfae <storage path of firmware image file> <call stack address>", where the -e option specifies the firmware image file as the source of debugging information, the -f option requires outputting function names, the -a option requires echoing the queried address in the output, and the -p option requires outputting in single-line readable form. The program fills the above template with the storage path of the firmware image file obtained in step 101 and the call stack address extracted in step 102, obtaining the symbolic command string, for example, "arm-none-eabi-addr2line -pfae D: / build / m55c0.elf 0x2c4a6ab0". When a backtrack line contains multiple call stack addresses, these addresses can be appended to the end of the same symbolic command in their original order for a single lookup, or a separate symbolic command can be constructed for each address. This embodiment uses the former as an example, in which case the symbolic tool will output the results line by line in address order. It should be noted that the symbolic tool is not limited to the addr2line program; the llvm-addr2line program can also be used, or a debugger from the toolchain can be used with "info line" as the command. Commands in the form of "<call stack address>" perform the same conversion. The template for the symbolic command changes accordingly, while the method of filling the template with the storage path and call stack address of the firmware image file remains unchanged. The inputs to this step are the storage path and call stack address of the firmware image file, and the output is the symbolic command.

[0030] Step 104: The symbolization tool is invoked on the computer device to execute the symbolization command, and the symbolic text output by the symbolization tool is captured. The purpose of this step is to complete the symbolization locally on the computer device without transferring the backtrace file and firmware image file to a machine running another operating system. Specifically, the program creates a child process on the computer device with the symbolization command as a parameter. The child process runs the symbolization tool, which reads the debugging information from the firmware image file, converts the call stack address into function names, source file paths, and line numbers, and writes this information to its standard output as text. The program waits for the child process to finish running and then reads all the content written to the standard output by the child process as a string; this string is the symbolic text. The standard output can be captured by redirecting the child process's output to an inter-process pipe and then reading it, or by redirecting the output to a temporary file and then reading that file; this step does not limit this approach. For the example command above, the captured symbolic text will look like "0x2c4a6ab0: ​​sensor_read at / vendor / project / src / main.c:128". The input for this step is the symbolization command, and the output is the symbolic text.

[0031] Step 105: Parse the symbolic text to obtain structured entries containing call stack addresses, function names, source file paths, and line numbers, and display these structured entries in the results list. The purpose of this step is to convert the plain text output by the symbolic tool into structured data that can be further processed by the program and is easy for the user to read. Specifically, each line in the symbolic text corresponds to a call stack address, the format of which is determined by the symbolic tool. For the addr2line program, a line is in the form of "address: function name at source file path: line number". The program extracts four fields—address, function name, source file path, and line number—from each line according to this format to form a structured entry. The address field is the original call stack address, the function name field is the function containing that address, the source file path field is the source file path recorded in the debugging information of the firmware image file, and the line number field is the source code line number corresponding to that address. Structured entries are appended to the results list (i.e., the symbolication results list area) on the graphical interface. The results list contains at least five columns: address, function, file, line number, and path. The file column displays the filename portion of the source file path for quick browsing, and the path column displays the complete path. When the symbolication tool outputs "??" or "?? at ??:0" due to missing debugging information, the function name and line number fields are filled with unknown markers to help the user identify the unsymbolized addresses. The input for this step is symbolized text, and the output is the structured entries displayed in the results list.

[0032] Step 106: According to the preset path mapping rules, convert the source file paths in the structured entries from compile-time paths to local source code paths pointing to local source code files on the computer device, based on the local source code root directory. The purpose of this step is to resolve the inconsistency between the source file paths recorded in the firmware image file and the developer's local paths. The source file paths in the firmware image file are absolute paths on the machine that compiled the firmware. For example, when the firmware is compiled in the / vendor / project directory of the compilation server, the path is / vendor / project / src / main.c. Such compile-time paths do not exist on the developer's computer device and cannot be directly used to open the file. The preset path mapping rules describe the correspondence between compile-time paths and local paths. A mapping table consisting of several "compile-time path prefix to local path prefix" mapping pairs can be used. The program searches the mapping table for a mapping pair that matches the prefix of the compile-time path and replaces the matching prefix with the corresponding local path prefix, where the local path prefix is ​​concatenated based on the local source code root directory. Alternatively, a prefix replacement method based on anchor directories can be used, that is, replacing the part of the compile-time path before a certain agreed directory with the local source code root directory. For example, the compile-time path ` / vendor / project / src / main.c` is mapped to the local source code path `D: / src / vendor / project / src / main.c`. This mapped local source code path is then filled into the path field of the structured entry. The program can also check if the file corresponding to this local source code path exists; if not, it is displayed as a prompt in the results list so the user can check the configuration of the local source code root directory. The inputs to this step are the source file paths from the structured entry and the local source code root directory; the output is the local source code path.

[0033] Step 107: In response to the selection of a target item in the results list, generate an editor invocation command containing the local source code path and line number of the target item, and execute the editor invocation command to open the local source code file corresponding to the local source code path and locate the code line corresponding to the line number in the code editor. The purpose of this step is to link the symbolic results with the code editor, so that the user does not have to manually search in the source code. Specifically, the selection operation can be double-clicking an item in the results list, pressing the Enter key after selecting the item, or selecting "Open Source" in the right-click menu. This embodiment uses double-clicking as an example. After receiving the selection operation event, the program reads the local source code path and line number of the selected target item, and generates an editor invocation command according to the command line format specified by the code editor. This command contains the executable program name of the code editor, the option to locate by line number, and the local source code path and line number. For example, for a code editor that uses "code" as the startup command and supports the -g option, the editor invocation command is "code -g D: / src / vendor / project / src / main.c:128". The program then executes the command through the operating system's process creation interface or shell execution interface. The code editor is launched (or reused if it is already running), opens the corresponding local source code file, and positions the cursor on line 128. The user can then directly view the code where the crash occurred. It should be noted that the code editor is not limited to any one type; any editor that supports opening files with specified line numbers via command-line arguments will suffice. For example, some editors accept parameters in the form of "+line number path" or "-line line number path," in which case the editor's command format will be adjusted accordingly. The input for this step is the selected operation and the local source code path and line number of the target item; the output is the local source code file opened in the code editor and positioned at the corresponding line.

[0034] Steps 101 to 107 constitute a complete technical solution. Its working principle is that the debugging information required for symbolization is entirely contained within the firmware image file, and the symbolization tool has versions that run on various desktop operating systems. Therefore, the symbolization process does not necessarily have to be performed on a specific operating system. This method calls the symbolization tool as a subprocess on the computer device and captures its output, parses the output into structured entries, rewrites the paths on the compiler to local paths via path mapping, and finally completes the location using the command-line interface of the code editor. This merges the series of scattered manual operations of "executing commands, reading text, and manually searching for source code" into a coherent process completed in a graphical interface. Using the method of this embodiment, developers can complete the symbolization of the crash stack without switching operating systems. The symbolization result is presented in the form of a structured list instead of scattered command-line text. The problem of inconsistent paths between the compiler and local paths is automatically handled by path mapping. The location from the crash address to the source code line is completed with a single selection operation, which helps improve the efficiency of crash analysis and reduce errors in manual searching. Furthermore, since this method is based on existing standard interfaces of toolchains and code editors and does not modify the underlying tools, it is easy to deploy.

[0035] The following describes several optional improvements to this embodiment.

[0036] In some optional implementations, the identification of backtrace lines in step 102 can be based on preset backtrace keywords. Specifically, backtrace keywords are preset; in this embodiment, "Backtrace:" is used as an example. The program scans the backtrace file line by line, identifying lines where the backtrace keyword appears at the beginning or in the middle of the line as backtrace lines, and the remaining lines as non-backtrace lines. The inclusion of backtrace keywords in the lines is for compatibility with log formats that include timestamps or task name prefixes; for example, lines with text like "] Backtrace:" appearing anywhere in the middle of the line are also identified as backtrace lines. Then, backtrace lines and non-backtrace lines are displayed separately. For example, backtrace lines can be grouped together at the top or in a separate list page in the backtrace file import and display area, and marked with a display method different from non-backtrace lines. In this embodiment, backtrace lines are highlighted in red, while non-backtrace lines are displayed in the default color. Other display methods such as bolding, icons, or background colors can also be used. The keyword-based detection method is simple and less prone to missing errors, making it particularly suitable when the firmware log format is fixed. Categorized display allows users to quickly find crash records among a large number of logs. It should be noted that the backtracking keywords can be configured by the user in the interface to adapt to different firmware log formats; when not using the backtracking keyword method, the backtracking lines can also be identified using the regular expression address pattern matching method in step 102, achieving the same technical objective.

[0037] As a preferred but not mandatory improvement, step 104, which involves calling the symbolization tool and capturing the symbolized text, can employ a combination of anonymous pipes and a hidden window. Specifically, the program first calls the operating system's pipe creation interface (e.g., CreatePipe) to create an anonymous pipe, obtaining the pipe's read and write handles, and setting the write handle to be inheritable by the child process. Then, it fills in the process startup information structure (e.g., STARTUPINFO), setting both the standard output and standard error handles to the pipe's write handle, thereby redirecting the standard output and standard error of the child process running the symbolization tool to the anonymous pipe. Simultaneously, it sets the window display flag to hidden and specifies in the process creation flags not to create a console window. Next, it calls the process creation interface (e.g., CreateProcess) to create a child process using the symbolization command as the command line and with the command line window hidden. The child process executes the symbolization command. After the child process is created, the program closes its own write handle and then loops through the anonymous pipe's read end until the end-of-file marker is reached. All the data read is the symbolized text output by the child process. Finally, the program waits for the child process to exit and closes the relevant handles. When using this method, the symbolization process is completed silently in the background without interrupting the user's operation by popping up a command-line window. Alarm messages from the symbolization tool that are output to standard error are also captured and displayed to the user. It should be noted that when not using anonymous pipes, the output of the symbolization command can also be redirected to a temporary file and read, thus obtaining the symbolized text in the same way.

[0038] In some optional implementations, the parsing of the symbolic text in step 105 can be performed as follows: First, the symbolic text is divided into several lines to be parsed based on newline characters, and blank lines and leading and trailing whitespace characters are removed. Then, for each line to be parsed, the call stack address is obtained by segmenting it according to the address separator, which is the first colon after the address. The part before the colon, after removing whitespace, is the call stack address. The function name is obtained by segmenting it according to the preset linker keyword, which is the "at" in the output of the addr2line program located between the function name and the source file path. The part after the address separator and before the preset linker keyword is the function name. Next, the source file path and line number are segmented by searching backwards for the last line number separator in the line to be parsed. The line number separator is a colon. Since the source file path itself may also contain colons (e.g., a colon after the drive letter), the last colon is searched backwards from the end of the line to be parsed. The part after the preset linker keyword and before the colon is the source file path, and the part after the colon is the line number. Finally, additional debugging information following the line number is removed from the line to be parsed. For example, when the addr2line program corresponds to multiple basic blocks on the same line of source code, it appends additional information such as "(discriminator 3)" after the line number. The program removes the content starting from the left parenthesis in the line number field and converts the remaining part to an integer. Taking the line to be parsed "0x2c4a6ab0: ​​sensor_read at / vendor / project / src / main.c:128 (discriminator 2)" as an example, the parsing yields the call stack address 0x2c4a6ab0, the function name sensor_read, the source file path / vendor / project / src / main.c, and the line number 128. Using the above delimiter and keyword-based segmentation method, multiple output formats with or without additional debugging information can be compatible without introducing complex syntax analysis. It should be noted that when the output format of the symbolization tool is different, such as when the function name and position information are output on two separate lines without the -p option enabled, the program can be split into two lines as a group. Those skilled in the art can adjust the delimiter and connection keyword according to the symbolization tool used.

[0039] As a preferred but not mandatory improvement, the preset path mapping rule in step 106 can adopt a prefix replacement method based on the anchor directory. Specifically, an anchor directory is preset. The anchor directory is a first-level directory that exists in both the compile-time path and the local path. In this embodiment, " / vendor" is used as an example. This directory is located in the root directory on the compile machine and in the local source code root directory on the developer's machine. The program locates the first occurrence of the anchor directory in the source file path, replaces the part of the path in the source file path before the anchor directory with the local source code root directory, and retains the part of the path in the source file path starting from the anchor directory. The two are then concatenated to obtain the local source code path. For example, if the source file path is ` / vendor / project / src / main.c` and the local source code root directory is `D: / src`, then the local source code path is `D: / src / vendor / project / src / main.c`. If the compilation path is ` / home / build / ws / vendor / project / src / main.c`, the local source code path will still be `D: / src / vendor / project / src / main.c` because the part before the anchor directory is completely replaced. The anchor directory can be configured by the user in the interface or automatically inferred by the program based on the first-level subdirectory name under the local source code root directory. This method only requires configuring a local source code root directory to complete the mapping, which is simple to configure and insensitive to changes in the location of the workspace on the compilation machine. It should be noted that when the compilation path does not contain the anchor directory, the program can fall back to the mapping table method or prompt the user to specify it manually; the preset path mapping rules can also be implemented based on the source file locations recorded in the compilation database (e.g., `compile_commands.json`).

[0040] Optionally, the generation of the editor invocation command in step 107 can be performed as follows. First, the local source code path and line number are concatenated using a preset positioning separator to form a positioning parameter. The preset positioning separator is a character agreed upon by the code editor to separate the path and line number. In this embodiment, a colon is used as an example. The concatenation results in a positioning parameter in the form of "D: / src / vendor / project / src / main.c:128". When the local source code path contains spaces, the positioning parameter is enclosed in quotation marks. Then, the positioning parameter is combined as a command-line parameter with the code editor's startup command. The startup command includes the executable program name of the code editor and an option to locate by line number. In this embodiment, "code -g" is used as an example. The combination results in the editor invocation command "code -g D: / src / vendor / project / src / main.c:128". By using positioning parameters, different code editors can be adapted simply by changing the preset positioning separator and the startup command. For example, some editors use "+128" as the line number parameter and place it before the path. In this case, the order of the preset positioning separator and the parameter is adjusted accordingly. It should be noted that when the code editor does not support positioning line numbers by command-line arguments, you can also open the file with the command line first, and then jump to the specified line through the automation interface provided by the editor. The technical purpose of this method can also be achieved.

[0041] Example 2 This embodiment, based on Embodiment 1, provides an offline method for restoring the call chain, addressing the scenario where the backtrace file does not contain a complete call stack address sequence but only records processor register values ​​and stack memory contents. When an ARM-based embedded device experiences a hardware failure, its fault handler is limited by code space, memory space, and exception context. Typically, it can only print the program counter, link register, stack pointer, and a hexadecimal portion of stack memory, and cannot run a stack unroller on the device to generate a complete call stack. In this case, the backtrace line includes register record lines recording processor register values ​​at the time of the embedded device crash, and the backtrace file also includes stack dump lines recording stack memory contents at the time of the crash. The call stack address includes the program counter value and link register value extracted from the register record lines. The symbolization tools, besides the addr2line program, also include a debugger in the toolchain. This embodiment uses the GNU debugger (arm-none-eabi-gdb) in the toolchain as an example. This embodiment utilizes register values ​​and stack memory contents from the backtrace file, as well as code and call frame information from the firmware image file, to construct a pseudo-debugging target accessible to the debugger on the computer device. The debugger performs stack unpacking and, if unpacking is prematurely interrupted, infers and repairs the call chain based on call instruction constraints. The overall process of the method is shown in Figure 2, mainly including six steps: context information extraction, hierarchical context reconstruction, pseudo-debugging target construction, debugger unpacking and parsing, unpacking anomaly detection and constraint repair, and source annotation and editor linkage. Input acquisition, path mapping, and editor linkage in Embodiment 1 are still executed in the original manner. The steps of this embodiment are described one by one below.

[0042] Step 201: Identify register record lines and stack dump lines, extract the register set, and assemble the memory image. The purpose of this step is to organize the register values ​​and stack memory contents recorded in text form in the backtrack file into a data structure that can be directly accessed in subsequent steps. Specifically, based on step 102 of Example 1, the program expands the scope of backtrack line identification, identifying lines containing register names and values ​​(e.g., lines starting with register names such as "r0", "pc", "lr", "sp", or containing identifier text such as "Registers:") as register record lines, and identifying lines consisting of a starting address, a separator, and several hexadecimal words as stack dump lines. The program uses configurable regular expressions to extract the values ​​of general-purpose registers r0 to r12, stack pointer sp, link register lr, program counter pc, program status register xPSR, exception return value EXC_RETURN, main stack pointer MSP, process stack pointer PSP, control register CONTROL, interrupt program status register IPSR, and the name or task control block address of the current task from the register record line, obtaining a register set. The register set includes at least the exception return value, main stack pointer, and process stack pointer. Among them, the program counter value and the link register value are the call stack address in this embodiment. They can be directly symbolized by the addr2line program as in Embodiment 1 as a quick indication of the crash location. For the stack dump line, the program expands the starting address of each line and the subsequent consecutive words into a byte sequence according to the byte order of the target processor (Cortex-M processors are usually little-endian), and merges all stack dump lines into a sparse memory image. The memory image stores the mapping from address ranges to byte arrays in the form of a range tree, and adjacent or overlapping ranges are merged. This embodiment uses the example of dumping several hundred bytes each from the fault handler's main stack pointer and the process stack pointer. The dump length is determined by the firmware, and this method does not limit it. The aforementioned register and stack dumps are already available outputs of most real-time operating system fault hooks, and this step does not require the embedded device to add new recording overhead. The input to this step is a backtrack file, and the output is a register set and a memory image.

[0043] Step 202: Reconstruct the crash scenario layer by layer according to the processor's exception stack pushing rules. The purpose of this step is to distinguish between the exception handling chain and the interrupted task chain, avoiding mistaking the exception handling function for the root cause. Specifically, the program first determines whether the link register value in the register set is an exception return value, based on the condition that bits 31 to 28 are all 1 (i.e., the value is in the form of 0xFxxxxxxx). When the link register value is an exception return value, the program determines the stack pointer and exception frame length used before the exception occurred based on the preset bits of the exception return value: the second bit of the exception return value is used to select the stack pointer used before the exception occurred; when this bit is 1, the process stack pointer is selected, and when it is 0, the main stack pointer is selected; the fourth bit is used to determine the type of exception frame and the exception frame length; when this bit is 0, it is an extended frame containing floating-point registers, and the exception frame length is 0x68 bytes; when this bit is 1, it is a basic frame, and the exception frame length is 0x20 bytes; the third bit is used to determine whether the exception returned in thread mode or processing mode. The program then reads the hardware-push register values ​​from the exception frame located at the determined stack pointer in the memory image. Specifically, it reads the eight words automatically pushed onto the stack by the hardware: r0, r1, r2, r3, r12, lr, pc, and xPSR. Based on the 9th bit of the pushed xPSR, it checks for the presence of four bytes of padding inserted to ensure 8-byte alignment. The program then calculates the stack pointer value before the exception occurred: the determined stack pointer plus the exception frame length, plus four bytes if padding is present. This yields the register set before the exception. If the read link register value is still an exception return value, it indicates a nested exception. The program repeats the above reading for that level until the read link register value is no longer an exception return value, or the number of levels reaches a preset upper limit. The upper limit can be set according to the firmware's allowed interrupt nesting depth; this embodiment does not limit it. This results in multiple register sets corresponding to nested, multi-level exceptions. These register sets form a hierarchical list of "outer interrupt, inner interrupt, interrupted task." Each level records its level number, exception number, register set, stack pointer, and the type of stack used. The exception number can be verified using the value of the interrupt status register or the lower-order field of the xPSR pushed onto the stack. The input to this step is a set of registers and a memory image, and the output is a hierarchical list consisting of multiple register sets.

[0044] Step 203: Create a pseudo-debugging target on the computer device. The purpose of this step is to provide the layered reconstructed register set and memory image in a way that the debugger can recognize, allowing the debugger to access them as if connecting to a real device. Specifically, the program creates a local transmission control protocol listening port on the computer device and implements a subset of the debugger's remote serial protocol on this port. The pseudo-debugging target processes protocol messages as follows: For capability query messages, it replies with the supported message length and characteristics; for target description query messages, it returns a target description file describing the register layout of the ARM M series processor, which lists the names, bit widths, and numbers of r0 to r12, sp, lr, pc, and xPSR in sequence; for stop reason query messages, it replies with an acknowledgment that the target has stopped due to a signal. For debugger register read requests, i.e., read all register messages and read a single register message, the pseudo-debugging target retrieves the corresponding register set from the layer list according to the currently selected thread and returns it in little-endian hexadecimal in the order specified in the target description file. For memory read requests from the debugger, the pseudo-debugging target first searches for the range containing the requested address in the memory image. If the requested address falls within the memory image, it returns the bytes in the memory image, i.e., the stack memory content recorded in the backtrack file. If a miss occurs, it queries the program header of the firmware image file. If the requested address falls within a loadable segment of the firmware image file, it reads the corresponding bytes from the firmware image file according to the file offset of that loadable segment and returns them. If the requested address falls within the memory range of the loadable segment but exceeds its file mapping range (i.e., the uninitialized data area), it returns zero bytes; otherwise, it returns an error code. For thread list query messages, the pseudo-debugging target assigns a thread number to each level in the hierarchy list and lists all of them. For thread switching messages, it records the currently selected thread, and subsequent register reads are for that thread. For messages such as write memory, write register, continue execution, single-step execution, and set breakpoints, it always replies with an error response or a null response to ensure that the pseudo-debugging target is read-only. The firmware image file used by the pseudo-debugging target is the firmware image file corresponding to the storage path obtained in step 101 of Example 1. The inputs for this step are a hierarchy list, a memory image, and a firmware image file. The output is a pseudo-debug target in listening mode and its port number.

[0045] Step 204: Construct symbolic commands, invoking the debugger to unpack the stack of the pseudo-debugging target and parse the frame information. In this embodiment, constructing symbolic commands refers to constructing symbolic commands that include commands to load the firmware image file, commands to connect the pseudo-debugging target, and stack unpacking commands. The symbolic text is the frame information output by the debugger based on the register set and memory image after executing the stack unpacking command. Specifically, the program follows the subprocess calling method in Embodiment 1, starts the debugger program in the toolchain in machine interface mode, and redirects the standard input and standard output of the subprocess to pipes so as to write commands to the debugger and read its responses; the command to load the firmware image file loads the firmware image file as a symbol file and an executable file (e.g., "-file-exec-and-symbols <storage path of firmware image file>", which can also be given as the debugger's startup parameters); the command to connect to the pseudo-debugging target uses the local loopback address and the port number in step 203 as the target address (e.g., "-target-select remote 127.0.0.1:<port number>"); the stack unpacking commands include commands to list threads, and commands to list stack frames, list parameters of each frame, and list local variables of each frame (e.g., "-stack-list-frames", "-stack-list-arguments", and "-stack-list-locals"). The program sequentially writes the above commands to the debugger via a pipe. The debugger, based on the call frame information in the firmware image file (stored in the debug frame segment or ARM exception index table segment) and the register set and stack memory read from the pseudo-debug target, calculates the caller's stack pointer and return address frame by frame, completing stack unwinding. Virtual frames formed by inline functions and tail call scenarios are processed by the debugger according to its existing logic. The program reads the machine interface result record returned by the debugger via the pipe, i.e., frame information, and parses out the hierarchy, address, function name, source file path, line number, and the names and values ​​of parameters and local variables for each frame. This information is then populated into the result list as structured entries. The result list adds a "hierarchy" column in addition to the original five columns: address, function, file, line number, and path, and displays parameters and local variables in a sub-panel. The input for this step is the pseudo-debug target and the firmware image file; the output is a frame sequence for each thread. Each frame in the frame sequence records its address, function name, source file path, line number, parameters, and local variables.

[0046] Step 205: Determine if stack unwinding was prematurely interrupted, and infer supplementary frames based on candidate return addresses when premature interruption occurs. The purpose of this step is to handle situations where premature unwinding is caused by factors such as omitted frame pointers in the firmware release or stack overflow corrupting return addresses. Specifically, for each thread's frame sequence, the program determines whether the frame information indicates premature stack unwinding based on the following criteria: the next return address of the last frame does not fall within any executable segment of the firmware image file; the stack pointer of the last frame exceeds the stack dump range of the stack used by the thread; or the frame sequence contains only one frame and the corresponding stack dump window still has a large amount of unconsumed content. When any criterion is met, the program verifies each word in the memory image after the stack pointer of the last frame as a candidate return address. Verification conditions include that the candidate return address falls within an executable segment of the firmware image file, and the instruction before the candidate return address is a call instruction. The verification for return addresses falling within executable segments requires that the candidate return address, after clearing its least significant bit, must be located within an executable segment of the firmware image file, and its least significant bit must be 1 to conform to the characteristics of a Thumb state return address. The verification for call instructions is based on the fact that the Cortex-M processor only supports the Thumb instruction set, and its call instructions are either four-byte BL instructions or two-byte BLX register-based instructions. Therefore, after clearing the least significant bit of the candidate return address and subtracting four bytes, a BL instruction must be disassembled, or after subtracting two bytes, a BLX instruction must be disassembled. Disassembly is performed by pipe-calling the object file disassembler in the toolchain (i.e., arm-none-eabi-objdump) and specifying the start and end addresses. When the disassembly result is a BL instruction, it can be further required that its jump target equals the entry address of the function containing the previously confirmed frame. The program uses the frame corresponding to the verified candidate return address as the inferred frame, and supplements the structured entry with the function name, source file path, and line number obtained by symbolization of its address, appending it to the end of the thread's frame sequence. To select a more reliable call chain when multiple candidate return addresses pass verification, the program can also introduce stack order constraints and call relationship constraints. Stack order constraints require that the addresses of the adopted candidate return addresses in the stack dump be strictly monotonically increasing. Call relationship constraints pre-compile and cache the firmware image file, extract the target addresses of all BL instructions, and construct a static call graph by combining the start and end ranges of each function in the symbol table. If there is a direct call edge between the functions to which adjacent candidate return addresses belong in the static call graph, a higher score is assigned; if they are reachable through function pointers or interrupt entries, a lower score is assigned; otherwise, no score is assigned. In this embodiment, a direct call edge is scored as two points and an indirect reachable edge as one point. The score setting is only an example. Then, the path with the highest total score and reasonable stack address order is selected from the candidate graph as the sequence of inference frames. When there are multiple paths with similar total scores, they are retained for the user to view.It should be noted that this step is executed only when the stack unwinding is prematurely interrupted; no inference is performed if the unwinding completes normally. The inputs to this step are the frame sequence, memory image, and firmware image file, and the output is the frame sequence supplemented with the inferred frames.

[0047] Step 206: Label the source of each frame, complete the path mapping, and link the code editor. In this step, the program labels the source of each frame in the frame sequence. The sources are divided into three types: "hardware stack push" (i.e., the frame directly read from the exception frame in step 202), "expanded" (i.e., the frame calculated by the debugger based on the call frame information in step 204), and "inferred repair" (i.e., the inferred frame obtained based on the verification in step 205). The inferred frame and the frame obtained from the frame information are distinguished and displayed in the result list with different source labels, such as different text labels and colors. The exception handling chain and the interrupted task chain are grouped and displayed according to the hierarchy obtained in step 202, and the exception handling function is not listed as the root cause frame. Subsequently, the program converts the source file path of each frame from the compile-time path to the local source code path according to the preset path mapping rules in step 106 of embodiment one. When the user selects any frame in the result list, the program generates and executes an editor call command containing the local source code path and line number in the manner described in step 107 of embodiment one, so as to open the corresponding local source code file and locate the line in the code editor. The input for this step is the frame sequence that supplements the inferred frames, and the output is a list of results with source annotations and completed path mapping.

[0048] Steps 201 to 206 above, together with the remaining steps in Embodiment 1, constitute a complete technical solution. Its working principle is that while embedded devices cannot run the stack unrolling program during exception handling, the printed registers and stack memory already contain the context data required for unrolling. Another part of the data required for unrolling (code and call frame information) exists in the firmware image file. This embodiment merges these two parts of data into a "static device" accessible to the debugger through a pseudo-debugging target, thereby entrusting the unrolling work to the debugger already present in the toolchain. Using the method of this embodiment, even for backtracking files that only record registers and stack dumps, a complete call chain can be recovered, and the parameters and local variable values ​​of each frame can be obtained. For crashes occurring in interrupts or nested interrupts, the exception handling chain and the interrupted task chain can be distinguished, avoiding mistaking the exception handling function as the root cause. In cases where the stack content is corrupted, a well-founded and traceable inference result can be given, rather than treating all values ​​resembling code addresses as call addresses.

[0049] The following describes several optional improvements to this embodiment.

[0050] In some optional implementations, step 202 can further reconstruct the context of each task. If the backtrace file also records the task control block summary of each task, including the task name, stack start and end addresses, and the stack pointer saved during task switching, the program saves the layout according to the context of the corresponding real-time operating system, reads r4 to r11 pushed by the software during task switching and the subsequent hardware exception frame from the stack pointer saved by each task, restores the register set of each task, and constructs a task list; different real-time operating systems save registers in different orders and positions during task switching, and the program can maintain a configuration describing the layout for each real-time operating system. Each task in the task list is also assigned a thread number in step 203 for the debugger to switch and view, and whether the stack pointer of the last frame in step 205 exceeds the start and end address range of the task stack can also be used as one of the criteria. The task control block summary can also be read directly from the memory image by the program based on the current task control block address in the backtrace file, instead of being printed by the firmware. It should be noted that the task list is not a necessary condition for implementing this method. Even if the backtrack file does not contain any task information, this method can still expand only the layers in the hierarchy list.

[0051] As a preferred but not mandatory improvement, the pseudo-debugging target in step 203 can include the floating-point registers s0 to s15 and the floating-point status control register stored in the extended frame in the target description file and make them available externally, enabling the debugger to display floating-point type parameters and local variable values. When the floating-point registers are not provided, the debugger can still complete the expansion involving integer registers and stack memory, but the values ​​of floating-point variables will not be available.

[0052] In a variation of this embodiment, communication between the pseudo-debugging target and the debugger can be achieved not only through the local transmission control protocol port, but also through named pipes or standard input / output redirection, as long as the debugger supports the corresponding remote connection method. Besides the GNU debugger in the toolchain, the debugger can also be replaced with other debuggers that support the same remote serial protocol, such as the LLDB debugger. If it is not desired to rely on an external debugger, the program can also parse the debug frame segment and ARM exception index table segment of the firmware image file itself and directly complete the expansion on the memory image. In this case, steps 203 and 204 are combined into one internal expansion step, while the remaining steps remain unchanged.

[0053] Optionally, in addition to using a static call graph, the candidate path scoring in step 205 can also introduce the stack frame size of each function recorded in the call frame information as an additional constraint. That is, the distance between the return addresses of two adjacent frames in the stack should match the stack frame size of the function in the previous frame. If they do not match, the score will be reduced.

[0054] To further enhance usability, step 206 can also generate a debug startup configuration file for the code editor, setting the remote debug target address to the local loopback address and the port number of the pseudo-debug target. After the user starts this debug configuration in the code editor, the code editor's built-in debug frontend connects to the pseudo-debug target and displays the crash history in its native call stack panel, variable panel, and disassembly panel. The user can also switch between viewing different interrupt layers and tasks in the thread list. This debug startup configuration file can also be automatically written to the source code project directory and directly trigger the code editor to start debugging when the user selects a list item. When not using the code editor attachment method, the user can still locate the source code through the results list and editor commands.

[0055] Example 3 This embodiment, based on Embodiment 1, provides an implementation method for verifying the credibility of symbolization results. In embedded development, field devices often have multiple firmware versions after over-the-air upgrades. The bootloader, main application, protocol stack, dynamically loaded module, and dual-partition image often coexist in the same address space. Code may also be moved to random access memory for execution, and local source code may continue to be modified after compilation. In these situations, symbolization tools often do not report errors, but instead provide seemingly reasonable but incorrect function and line numbers. This embodiment sequentially verifies whether the firmware image file used is consistent with the firmware that generated the backtrace file, whether the call stack address has been corrected according to the actual loading location, and whether the local source code file opened during the jump is consistent with the source code at compile time. The verification results are summarized into a credibility level to control whether jumps are allowed, thereby transforming these silent errors into detectable and demonstrable results. The overall process of the method is as follows: Figure 3 As shown, it mainly includes five steps: pre-embedding identity information during the construction period, identity verification of firmware image files, routing and correction of multiple image addresses, source code alignment, and credibility aggregation and gating. Steps 302, 303, and 304 are the specific implementation methods of obtaining the storage path of the firmware image file, the construction symbolization command, and the preset path mapping rules in Example 1, respectively. They will be explained one by one below.

[0056] Step 301: Pre-embed identity information and generate an image manifest during firmware build. The purpose of this step is to ensure that the backtrack file, firmware image file, and source code all carry machine-readable identity identifiers. Specifically, during linking, enable the linker option to generate a build identifier, causing the linker to generate a comment segment recording the build identifier in the firmware image file. This segment is then placed in the read-only storage area of ​​the firmware in the linker script, allowing the firmware to read and print the build identifier at runtime. After each build, the build script generates an image manifest for each image. The image manifest records the build identifier, link base address, executable segment address range, and source code commit identifier of the firmware image file. It can also further record whether the working area contains uncommitted modifications, the image number, the processor core it belongs to, the load address and length of each executable segment, the characteristic values ​​of several words at the beginning of the vector table, the toolchain version, and the storage path of the firmware image file. The image manifest and the firmware image file are stored together in a symbol repository. The symbol repository stores at least one firmware image file and the image manifest. The symbol repository can be a local directory, a network shared directory, or a Hypertext Transfer Protocol service that provides query and download based on the build identifier. The firmware prints the build identifier, current boot partition, vector table offset register value, and the name and load base address of dynamically loaded modules during startup or in the fault handler. The inputs to this step are the firmware source code and build script, and the outputs are a firmware image file with the build identifier, an image manifest, and firmware with runtime identification information.

[0057] Step 302: Verify the identity of the firmware image file and select the firmware image file. The purpose of this step is to ensure that the firmware image file used for symbolization is the same firmware image file corresponding to the firmware that generated the backtrace file. Specifically, the program extracts the build identifier of the embedded device's firmware from the backtrace file, scans all image lists in the user-specified symbol repository, establishes and caches an index from the build identifier to the path of the image list and firmware image file, and updates the cache incrementally according to the modification time of the image list file; it queries the index with the extracted build identifier to find the firmware image file in the symbol repository that matches the extracted build identifier. When a match is found, the firmware image file is automatically selected, and the storage path of the found firmware image file is used as the storage path of the firmware image file, thus replacing the operation of manually selecting the firmware image file directory by the user; when the corresponding firmware image file does not exist locally and the symbol repository is a network service, the program requests and downloads the firmware image file and image list from the symbol repository with the build identifier as a parameter. If the backtrace file does not contain a build identifier, the process can degenerate into version string matching. This involves extracting the firmware version string from the backtrace file and searching for the same string in the read-only data segment of the candidate firmware image file. If neither of these methods can determine the match, a reverse matching approach can be used. For each candidate firmware image file, the function names printed in the backtrace file are compared frame-by-frame with the function names obtained by symbolizing that firmware image file, and the consistency rate is calculated. Simultaneously, the content pointed to by the vector table offset register in the backtrace file is compared with the feature values ​​of the vector table in the candidate firmware image file. The candidate firmware image file with the highest consistency rate is selected. If the consistency rate is lower than a preset threshold, it is determined that the build identifier does not match. This threshold can be adjusted by the user according to the firmware's logging habits. The inputs to this step are the backtrace file and the symbol repository. The outputs are the storage path of one or more selected firmware image files, the corresponding image manifest, and the verification result of whether the build identifier matches.

[0058] Step 303 involves multi-image routing and correction of the call stack addresses, and the construction of symbolization commands according to the images. The purpose of this step is to ensure that call stack addresses belonging to different images and passing through different load offsets within the same backtrace file are sent to the correct firmware image file and symbolized according to the correct link address. Specifically, the program reads the program headers of each firmware image file selected in step 302, or directly uses the executable segment address ranges recorded in the image manifest to build an address range index for the executable segments of each image. The range index simultaneously registers the virtual address ranges and load address ranges of each segment to cover the scenario where the code is stored in read-only memory but runs in random access memory. For each call stack address, the least significant bit representing the Thumb state is first cleared, and then the firmware image file to which the call stack address belongs is searched in the range index according to the executable segment address range. The address correction amount is calculated for each image; the address correction amount is the difference between the firmware's running base address and link base address on the embedded device, i.e., ... in For the first Address correction amount for each mirror For the first The base address of the image on the embedded device is taken from the current boot partition, the value of the vector table offset register, or the load base address of the dynamically loaded module printed in the backtrack file. For the first The link base address of an image is taken from the image manifest or the virtual address of the first executable segment of the image's firmware image file. This is the mirror number, and its value is an integer not less than 1. When the backtrack file does not record the runtime base address, the program selects the candidate correction amount from a preset set of candidate correction amounts that maximizes the proportion of instructions preceding the corrected call stack address that are calling instructions. Specifically, the candidate correction amount set consists of the difference between the starting addresses of each partition in the user-configured partition table, the difference between the base addresses of the random access memory segment and the read-only memory segment in the image list, and zero values. For each candidate correction amount in the set, the program subtracts the candidate correction amount from each call stack address belonging to that image. The program then uses a pipe to call the object file disassembler in the toolchain to disassemble the four bytes before and two bytes before the corrected address. The program counts the number of call stack addresses that can be disassembled into BL or BLX instructions. The ratio of this number to the total number of call stack addresses is used as the hit rate. The program count does not include the first address in the call chain (i.e., the program counter value at the crash location). The candidate correction amount with the highest hit rate and not lower than a preset threshold is selected as the address correction amount. If the hit rate of all candidate correction amounts is lower than the threshold, the program prompts the user that it cannot automatically determine the load offset and requires manual input. The basis for this is that the instruction preceding the return address must be a call instruction. This constraint is independent of specific firmware and can be used as a criterion for whether the address correction is correct. The program then subtracts the address correction amount of the corresponding firmware image file from the call stack address to obtain the corrected address. Each corrected address must undergo two levels of verification: the first level is that the corrected address falls within an executable segment of the corresponding firmware image file; the second level is that the preceding instruction is indeed a call instruction. This second level of verification only applies to return addresses in the call chain except for the first address (i.e., the program counter value at the crash location). After correction, the program groups by image, constructs symbolic commands according to the storage path of the corresponding firmware image file and the corrected address, as in step 103 of Example 1, and executes them according to step 104. The symbolic results are then merged into a call chain according to the original order of each call stack address in the backtrack file. The result list adds a "image" column and a "correction amount" column in addition to the original columns. The inputs for this step are the call stack address, each firmware image file and image list, and the outputs are the corrected address, the symbolic commands grouped by image, and the verification result of whether the corrected address falls within the executable segment.

[0059] Step 304: Align the symbolized source file paths to the compiled source code. The purpose of this step is to ensure that the local source code file opened by the code editor is consistent with the source code used by the firmware that generated the backtrace file during compilation. The method in this step is the specific content of the preset path mapping rules in this embodiment. Specifically, the program reads the source code commit identifier from the image manifest. In the repository corresponding to the local source code root directory, it checks out a source code working tree consistent with the firmware compilation based on the source code commit identifier in the local cache directory. If the commit corresponding to the source code commit identifier does not exist in the local repository, it is obtained from the remote repository first. Then, the program points the target root directory of the path mapping to the source code working tree, and converts the compile-time path into a local source code path pointing to the corresponding file in the source code working tree. For example, the part before the anchor directory in Embodiment 1 is replaced with the root directory of the source code working tree. When a user chooses to open a file in the current working directory instead of the compile-time copy of the source code, the program converts the line numbers in the structured entries to the corresponding line numbers in the local source code file based on the difference blocks between the source code file corresponding to the source code commit identifier and the local source code file. Specifically, the program obtains the differences for that source file from the source code commit identifier to the current working directory. These differences are represented by several difference blocks. The header of each difference block records the starting line number and line number of the replaced interval in the original file, as well as the starting line number and line number of the corresponding interval in the new file. The method for converting the compile-time line numbers is as follows: in The compile-time line number obtained through symbolization. This refers to the corresponding line number in the converted local source code file. The entire replaced section in the original file is located at the th The set consisting of the sequence numbers of all the difference blocks preceding the line. This is the sequence number of the difference block. For the first The number of lines in the original file for each difference block. For the first The number of lines in the new file for each difference block. Represents a set Summing all the indices in the array. If the first... If a line falls within the replacement region of a certain difference block in the original file, then... The line number is taken as the starting line number of the difference block in the new file, and the line is marked as modified in the results list. Additionally, when the mirror manifest indicates that the working directory contains uncommitted changes during compilation, the program will indicate in the results list that the line number may be inaccurate. The inputs to this step are the symbolized source file path and line number, the mirror manifest, and the local repository. The output is the local source code path pointing to the source code working tree, or the local source code path and line number converted from the line number, and a verification result showing whether the local source code file has been modified relative to the source code commit marker.

[0060] Step 305: Summarize the trustworthiness levels and control the jump. In this step, the program determines the trustworthiness level of each structured entry in the result list based on whether the build identifier obtained in step 302 matches, whether the corrected address obtained in step 303 falls within the executable segment of the firmware image file, and whether the local source code file has been modified relative to the source code submission identifier obtained in step 304: "Trustworthy" when all three verifications pass; "Partially Trustworthy" when the firmware image file's build identifier matches, the corrected address falls within the executable segment of the firmware image file and passes the call instruction verification, but the local source code file has been modified or the image manifest has an unsubmitted modification mark; "Untrustworthy" when the build identifier does not match, or the corrected address does not fall within the executable segment of the firmware image file or fails the call instruction verification. The program displays the credibility level in a newly added column of the results list. When the credibility level is untrustworthy, selection of the corresponding structured entry is disabled in the results list; for example, the entry is grayed out and double-click events are ignored. The program also displays the failed verification steps and their reasons on the entry, such as "build identifier mismatch" or "corrected address not within executable segment." Structured entries that are "partially trustworthy" can be selected but are highlighted with a hint color. Structured entries that are "trustworthy" will redirect normally as described in step 107 of Example 1. The index established in step 302, the address correction amount solved in step 303, and the source code working tree detected in step 304 are all cached using the build identifier as the key, and subsequent backtracking files of the same firmware version are directly reused. The input to this step is the three verification results, and the output is a results list with credibility levels and controlled redirection behavior.

[0061] Steps 301 to 305 above, together with the remaining steps in Embodiment 1, constitute a complete technical solution. Its working principle is that the correctness of symbolization relies on three premises: the firmware image file and the firmware are from the same source; the call stack address and the link address are based on the same baseline; and the local source code and the compile-time version are the same. These three premises may not hold true under conditions of over-the-air upgrades, multiple images, code migration, and continuous modification in embedded development, and they will not be self-exposed when they fail. This embodiment pre-embeds machine-readable identities for these three premises during the build phase, verifies them one by one during the analysis phase, and uses call instructions to constrain this firmware-independent criterion for address correction, thereby transforming the originally silent error into a clear prompt. Using the method of this embodiment, error location can be avoided due to firmware image file version mismatch, uncorrected load offset, or modified source code, reducing the analysis time developers spend on error locations; at the same time, since the tools required for verification are all existing programs in the toolchain and version management system, the implementation cost is low.

[0062] The following describes several optional improvements to this embodiment.

[0063] In some optional implementations, step 304 can further utilize the source file digest values ​​recorded in the debug line table of the firmware image file for rapid comparison. That is, when the compiler writes the digest values ​​of each source file into the debug line table, the program directly calculates the digest value of the corresponding local file and compares it. If they match, it is directly determined that the local source code file has not been modified without checking the source code working tree. When the compiler does not write digest values, the source code working tree or difference block conversion method in step 304 is still used.

[0064] As a preferred but not mandatory improvement, the range index in step 303 can also register the address range of the read-only memory library provided by the chip manufacturer in the form of symbol files or linker mapping files, so that call stack addresses falling into this range can also be routed to the corresponding symbol source to complete function-level symbolization. It should be noted that without registering the read-only memory library, addresses falling into this range are only displayed as unresolved and do not affect the processing of other addresses.

[0065] In a variation of this embodiment, for a multi-core on-chip system, the processor cores identified by the prefixes of each line in the backtrack file can be mapped to the corresponding image sets of each core. Step 303 searches only within the image set of that core during routing to avoid misrouting caused by overlapping address ranges between different cores. The correspondence between processor cores and image sets can be configured by the user or automatically matched based on the core identifier in the firmware image filename. When the firmware runs on only a single core, the above distinction is unnecessary.

[0066] Optionally, the symbol repository in step 302 can be integrated with a continuous integration system, which can automatically register the image list and firmware image file with the symbol repository after each build, thus eliminating the need for manual maintenance; when not integrated with a continuous integration system, the build script can copy the build artifacts to the symbol repository directory, which can also achieve the same result.

[0067] Furthermore, this embodiment can be used in conjunction with Embodiment 2. In this case, the firmware image file selected in step 302 serves as the source of the code read by the pseudo-debugging target in Embodiment 2. The address correction amount calculated in step 303 is used by the pseudo-debugging target to convert the request address when processing memory read requests, that is, first subtract the address correction amount of the corresponding image from the request address before querying the firmware image file. Steps 304 and 305 perform source code alignment and confidence gating on each frame obtained from Embodiment 2. After the two are combined, the selection of the firmware image file, the correction of the call stack address, the restoration of the call chain, and the alignment of the source code are all verified or reconstructed along the entire chain from the backtrack file to the source code line. Those skilled in the art can also implement only one of them as needed.

[0068] Example 4 This embodiment provides an electronic device for executing the embedded crash stack symbolization and source code location method provided in any of the embodiments one to three above. This electronic device is the computer device in the foregoing embodiments, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above method. Specifically, the processor can be a central processing unit (CPU) or a processing unit including a CPU and a graphics processing unit (GPU). The processor is connected to the memory via a bus. The memory includes random access memory for running the program and non-volatile memory for persistently storing the program and data. The non-volatile memory can be a hard disk, solid-state drive (SSD), or flash memory. The electronic device may also include a display, keyboard, and mouse, etc., for presenting a graphical interface and receiving user selection operations, and a communication interface for receiving backtracking files, such as a serial port, a universal serial bus interface, or a network interface. In addition to the computer program, the memory also stores executable files for symbolization tools and code editors, as well as backtracking files, firmware image files, and a local source code root directory configured by the user through the graphical interface. This embodiment uses a desktop or laptop computer running the Windows desktop operating system as an example. It can also be a computer running other desktop operating systems such as Linux or macOS, as long as the corresponding toolchain and code editor can be installed on it.

[0069] The computer program can be functionally divided into a visual selection module, a backtracking parsing module, a command construction module, a command execution module, an output parsing module, a path mapping module, and an editor linkage module. The visual selection module implements step 101 and step 302 in Example 3; the backtracking parsing module implements step 102 and steps 201 and 202 in Example 2; the command construction module implements step 103 and step 303 in Example 3; the command execution module implements step 104 and steps 203 and 204 in Example 2; the output parsing module implements step 105 and steps 205 in Example 2 and step 305 in Example 3; the path mapping module implements step 106 and step 304 in Example 3; and the editor linkage module implements step 107 and step 206 in Example 2. The above module division is only one example; the modules can be merged or further split, or implemented as dynamic link libraries or plugins, as long as the overall implementation achieves the aforementioned method.

[0070] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the embedded crash stack symbolization and source code location method provided in any of the embodiments one to three above. The computer-readable storage medium can be a hard disk, solid-state drive, or flash memory inside an electronic device, or it can be a removable storage medium, such as a Universal Serial Bus flash drive, portable hard drive, memory card, or optical disc, or it can be storage space on a network server or cloud storage service. The computer program can be loaded from the above storage medium into the memory of the electronic device for execution by the processor, or it can be downloaded and installed via a network.

[0071] It should be noted that the terms "first," "second," etc., used in this specification are only used to distinguish similar objects, and the elements defined by them do not necessarily require or imply any actual relationship or order between these elements, nor are they used to describe a specific order or sequence.

[0072] The terms “comprising,” “including,” or any other variations thereof, as used herein, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase “comprising one…” does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0073] The phrase "execute according to a certain element" as used in this specification means at least according to that element, including both "execute only according to that element" and "execute according to that element and other elements".

[0074] Those skilled in the art will understand that variations of the method steps described above can be obtained based on the embodiments of this disclosure without any inventive effort. For example, the sequence numbers of the steps described in the method embodiments of this specification do not themselves constitute a limitation on the execution order of these steps. Unless there is an explicit specific limitation in the context, the steps may be executed in a different order than that shown in the embodiments (e.g., executing the steps with larger sequence numbers first, then the steps with smaller sequence numbers), or they may be executed in parallel. Furthermore, other steps may be inserted between multiple steps with consecutively numbered sequence numbers.

[0075] The specific embodiments described in this specification are merely illustrative examples of this disclosure. For instance, specific numerical values, parameters, protocols, network architectures, component models, drawing scales, and specific shapes shown in the drawings are only examples and do not constitute a limitation of this disclosure. Features of the various embodiments of this disclosure can be arbitrarily combined without contradicting each other, and the solutions formed by such combinations also fall within the protection scope of this disclosure.

[0076] All references to this disclosure are considered to be incorporated herein in their entirety so as to serve as a basis for modification where necessary. Furthermore, it should be understood that, upon reading this disclosure, those skilled in the art may make various alterations or modifications to it, and these equivalent forms also fall within the scope of protection claimed herein.

Claims

1. A method for symbolic representation and source code location of an embedded crash stack, applied to a computer device, wherein the computer device is equipped with a symbolic representation tool and a code editor, the symbolic representation tool being used to convert program addresses into function names, source file paths, and line numbers based on debugging information, characterized in that... The method includes: Obtain the backtrack file generated when the embedded device crashes, the storage path of the firmware image file containing the debugging information of the embedded device, and the configured local source code root directory; Identify backline lines containing call stack addresses from the backline file, and extract the call stack addresses from the backline lines; A symbolic command is constructed based on the storage path of the firmware image file and the call stack address; The symbolization tool is invoked on the computer device to execute the symbolization command, and the symbolized text output by the symbolization tool is captured; The symbolic text is parsed to obtain a structured entry containing the call stack address, the function name, the source file path, and the line number, and the structured entry is displayed in the result list; According to the preset path mapping rules, based on the local source code root directory, the source file path in the structured entry is converted from the compile-time path to the local source code path pointing to the local source code file on the computer device; In response to the selection of a target item in the result list, an editor invocation command is generated that includes the local source code path and the line number of the target item, and the editor invocation command is executed to invoke the code editor to open the local source code file corresponding to the local source code path and locate the line of code corresponding to the line number.

2. The method according to claim 1, characterized in that, The step of identifying the backtrack line containing the call stack address from the backtrack file includes: The backtracking file is scanned line by line. Lines that contain a preset backtracking keyword at the beginning or in the middle of the line are identified as backtracking lines, and the remaining lines are identified as non-backtracking lines. The backtracking rows and the non-backtracking rows are displayed separately, and the backtracking rows are marked in a way that is different from the display of the non-backtracking rows.

3. The method according to claim 1, characterized in that, The step of invoking the symbolization tool on the computer device to execute the symbolization command and capturing the symbolized text output by the symbolization tool includes: Create an anonymous pipe and redirect the standard output and standard error of the subprocess used to run the symbolization tool to the anonymous pipe; The child process is created by hiding the command line window, and the symbolic command is executed by the child process. The symbolic text output by the child process is read from the anonymous pipe.

4. The method according to claim 1, characterized in that, The parsing of the symbolized text includes: The symbolized text is divided into lines to be parsed; In the line to be parsed, the call stack address is obtained by segmenting according to the address separator, the function name is obtained by segmenting according to the preset linking key, and by reverse searching for the last line number separator in the line to be parsed, the part after the preset linking key and before the line number separator is segmented into the source file path, and the part after the line number separator is segmented into the line number; Remove additional debugging information following the line number from the line to be parsed.

5. The method according to claim 1, characterized in that, The step of converting the source file path in the structured entry from a compile-time path to a local source code path pointing to the local source code file on the computer device, based on the local source code root directory and according to a preset path mapping rule, includes: Locate the preset anchor directory in the source file path; Replace the part of the source file path before the anchor directory with the local source code root directory, and retain the part of the source file path starting from the anchor directory to obtain the local source code path.

6. The method according to claim 1, characterized in that, The editor invocation command that generates the local source code path and line number containing the target entry includes: The local source code path and the line number are concatenated together using a preset location separator to form a location parameter; The positioning parameters are combined with the code editor's startup command as command-line arguments to obtain the editor invocation command.

7. The method according to claim 1, characterized in that, The backtrack line includes a register record line that records the processor register values ​​when the embedded device crashes, the backtrack file also includes a stack dump line that records the stack memory contents when the crashes, the call stack address includes the program counter value and link register value extracted from the register record line, and the symbolization tool includes a debugger in the toolchain; The method further includes: Extract the set of registers, including the link register value, exception return value, main stack pointer and process stack pointer, from the register record line, and concatenate the stack dump line with consecutive words according to its starting address to form a memory image; When the link register value in the register set is an exception return value, the stack pointer and exception frame length used before the exception occurred are determined according to the preset bit of the exception return value. The register value pushed onto the stack by the hardware is read from the exception frame located at the determined stack pointer in the memory image to obtain the register set before the exception occurred. The above reading is repeated when the read link register value is still an exception return value to obtain multiple register sets corresponding to nested multi-level exceptions. The register set and the multiple register sets constitute a hierarchical list. A pseudo-debugging target is created on the computer device. In response to the debugger's register read request, the pseudo-debugging target returns the register group corresponding to the currently selected thread in the hierarchy list. In response to the debugger's memory read request, it returns bytes in the memory image when the requested address falls within the memory image, and reads bytes from the firmware image file according to the file offset of the loadable segment when the requested address falls within the loadable segment of the firmware image file. The step of constructing a symbolic command based on the storage path of the firmware image file and the call stack address includes: constructing the symbolic command containing a command to load the firmware image file, a command to connect the pseudo-debugging target, and a stack unwinding command, wherein the call stack address is contained in the register set and provided to the debugger via the pseudo-debugging target; the symbolic text is the frame information output by the debugger based on the register set and the memory image after executing the stack unwinding command; When the frame information indicates an early interruption of stack unpacking, each word in the memory image after the stack pointer of the last frame is verified as a candidate return address. The verification conditions include that the candidate return address falls within the executable segment of the firmware image file and that the instruction before the candidate return address is a calling instruction. The frame corresponding to the candidate return address that passes the verification is added to the structured entry as an inferred frame, and the inferred frame and the frame obtained from the frame information are distinguished and displayed in the result list with different source labels.

8. The method according to claim 1, characterized in that, The step of obtaining the storage path of the firmware image file containing the debugging information of the embedded device includes: extracting at least one build identifier of the firmware of the embedded device from the backtrace file; searching in the symbol repository for one or more firmware image files whose build identifier matches the extracted build identifier; and using the storage path of each found firmware image file as the storage path of the firmware image file; when the backtrace file does not contain the build identifier or no matching firmware image file is found, comparing the function names printed in the backtrace file with the function names obtained by symbolizing the candidate firmware image files frame by frame and calculating the consistency rate; selecting the candidate firmware image file with the highest consistency rate; and determining that the build identifier does not match when the consistency rate is lower than a preset threshold; wherein, the symbol repository stores at least one firmware image file and an image list, and the image list records the build identifier, link base address, executable segment address range, and source code submission identifier of each firmware image file; The step of constructing a symbolic command based on the storage path of the firmware image file and the call stack address includes: determining the firmware image file to which the call stack address belongs based on the executable segment address range; subtracting the address correction amount of the firmware image file from the call stack address to obtain the corrected address; and constructing the symbolic command based on the storage path of the firmware image file and the corrected address. The address correction amount is the difference between the running base address of the firmware on the embedded device and the link base address. The running base address is taken from the backtracking file; or, if the backtracking file does not record the running base address, the candidate correction amount that results in the highest proportion of instructions preceding the corrected call stack address being call instructions is selected from a preset set of candidate correction amounts as the address correction amount. The preset path mapping rule includes: based on the source code commit identifier in the image manifest, checking out the source code working tree consistent with the firmware compilation time in the version library corresponding to the local source code root directory, and converting the compilation time path into the local source code path pointing to the corresponding file in the source code working tree; or, the method further includes: based on the difference block between the source code file corresponding to the source code commit identifier and the local source code file, converting the line number in the structured entry into the corresponding line number in the local source code file; The method further includes: determining the credibility level of the structured entry based on whether the build identifier matches, whether the corrected address falls within the executable segment of the firmware image file to which it belongs, and whether the local source code file has been modified relative to the source code submission identifier; displaying the credibility level in the result list; and disabling the selection operation of the corresponding structured entry and displaying the failed verification steps in the result list when the credibility level is untrustworthy.

9. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the embedded crash stack symbolization and source code location method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the embedded crash stack symbolization and source code location method as described in any one of claims 1 to 8.