A debugging device and method for core dump of embedded system

By introducing a local debugging adapter in the embedded system to parse the core dump file and using the remote debugging mode, the problem of adapting different format files to the GDB debugger is solved, and the development cost and implementation complexity are reduced.

CN112667412BActive Publication Date: 2024-09-06BEIJING KEYIN JINGCHENG TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011360077.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-27
Publication Date
2024-09-06
Estimated Expiration
2040-11-27

AI Technical Summary

Technical Problem

In embedded operating systems, different formats of core dump files require modifications to the open source and complex GDB debugger, resulting in difficulties in core dump implementation and increased development costs.

Method used

By parsing the core dump file of the embedded system in the local debugging adapter, and using the remote debugging mode to feed the parsing results back to the debugger, it avoids making a lot of code modifications directly in the debugger to adapt to parsing in different formats.

Benefits of technology

It reduces the implementation difficulties and development costs of core dumps and simplifies the parsing process of dump files in different formats.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112667412B
    Figure CN112667412B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a debugging device and method for a core dump of an embedded system, comprising: a debugger and a local debugging adapter, wherein the debugger is used to send debugging instructions to the local debugging adapter and receive exception information sent by the local debugging adapter; and the local debugging adapter is used to parse the core dump file of the embedded system to obtain exception information, and send the exception information to the debugger according to the debugging instruction. By adding a local debugging adapter to parse the core dump file of the embedded system in advance to obtain exception information, the debugger only needs to use a remote debugging mode to obtain the exception information, thereby avoiding the need to directly use the debugger for debugging and parsing, and requiring a large amount of code modification to the debugger to adapt to the parsing of dump files in different formats, thereby increasing the difficulty and cost of adaptation. Therefore, the solution described in the embodiment of the present invention can reduce the difficulty of implementing core dumps and the development cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of communication technology, and in particular to a device and method for debugging a core dump of an embedded system. Background Art

[0002] A core dump is a file in which the operating system saves the memory information, register information, and error task information at the exception site in a certain format after encountering an exception. The core dump file is then analyzed by a debugger to determine the cause of the operating system error.

[0003] For embedded operating systems, the GDB (GNU Debugger) debugger is generally used to analyze the obtained core dump files and display the cause of the exception based on the analysis results. However, since different embedded operating systems correspond to core dump files in different formats, when analyzing core dump files in different formats, the open source, complex and code-intensive GDB debugger needs to be modified, which increases the difficulty and development cost of implementing core dumps. Summary of the Invention

[0004] The embodiment of the present invention provides an embedded system core dump debugging device and method, which can parse embedded system core dump files of different formats through a local debugging adapter, and feed back the parsing results to the debugger according to the debugging instructions of the debugger, so as to reduce the implementation difficulty and development cost of core dump.

[0005] In a first aspect, an embodiment of the present invention provides a debugging apparatus for a core dump of an embedded system, comprising: a debugger and a local debugging adapter, wherein the debugger is configured in a remote debugging mode to establish a communication connection with a local debugging adapter located locally via a remote communication method;

[0006] The debugger is used to send debugging instructions to the local debug adapter and receive exception information sent by the local debug adapter;

[0007] The local debugging adapter is used to parse the core dump file of the embedded system to obtain exception information, and send the exception information to the debugger according to the debugging instructions.

[0008] In a second aspect, an embodiment of the present invention provides a method for debugging a core dump of an embedded system, which is applied to a debugging device including a debugger and a local debug adapter, wherein the debugger is configured in a remote debugging mode to establish a communication connection with a local debug adapter via a remote communication method, comprising:

[0009] The debugger sends debugging instructions to the local debug adapter;

[0010] The local debug adapter parses the core dump file of the embedded system to obtain exception information, and sends the exception information to the debugger according to the debugging instructions;

[0011] The debugger receives exception information sent by the local debug adapter.

[0012] The technical solution of the embodiment of the present invention adds a local debugging adapter to parse the core dump file of the embedded system to obtain exception information. The debugger only needs to use the remote debugging mode to obtain the exception information, avoiding the problem of directly using the debugger for debugging and parsing, which requires a large amount of code modification to the debugger to adapt to the parsing of dump files in different formats, thereby increasing the difficulty and cost of adaptation. Therefore, the solution described in the embodiment of the present invention can reduce the implementation difficulty and development cost of core dump. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0014] Figure 1 This is a schematic structural diagram of a debugging device for core dump of an embedded system provided in a first embodiment of the present invention;

[0015] Figure 2 This is a schematic structural diagram of a debugging device for core dump of an embedded system provided by a second embodiment of the present invention;

[0016] Figure 3 This is a flowchart of a method for debugging a core dump of an embedded system provided in a third embodiment of the present invention. DETAILED DESCRIPTION

[0017] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.

[0018] It should also be noted that, for ease of description, only the part relevant to the present invention, rather than all of the content, is shown in the accompanying drawings. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the various operations (or steps) as sequential processes, many of the operations therein can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the various operations can be rearranged. When its operation is completed, the process can be terminated, but can also have additional steps not included in the accompanying drawings. The process can correspond to methods, software implementations, hardware implementations, etc.

[0019] The embodiments of the present invention are applicable to debugging embedded core dumps. Embedded operating systems generally use the GDB debugger to analyze acquired core dump files and display exception causes based on the analysis results. However, since different embedded operating systems correspond to core dump files of different formats, the open-source, complex, and code-intensive GDB debugger must be modified when analyzing core dump files of different formats, thereby increasing the difficulty and development cost of implementing core dumps. The technical solution of the embodiments of the present invention provides a device for debugging core dumps in embedded systems. The device includes a debugger and a local debug adapter. The debugger is configured in remote debugging mode to establish a communication connection with a local debug adapter located locally via remote communication. By adding the local debug adapter to parse the embedded system's core dump file to obtain exception information, the debugger only needs to use remote debugging mode to obtain the exception information, avoiding the need to directly use the debugger for debugging and parsing, which requires extensive code modifications to adapt to parsing dump files of different formats, thereby increasing the difficulty and cost of adaptation. Therefore, the solution described in the embodiments of the present invention can reduce the difficulty and development cost of implementing core dumps.

[0020] Example 1

[0021] Figure 1 The present invention provides an embedded system core dump debugging device, which is applicable to the case where embedded core dump files are parsed, such as Figure 1 As shown, the device specifically includes:

[0022] The debugger 11 and the local debug adapter 12 are configured to be in remote debugging mode, so as to establish a communication connection with the local debug adapter via remote communication.

[0023] The debugger 12 is used to send debugging instructions to the local debug adapter and receive exception information sent by the local debug adapter; the local debug adapter 11 is used to parse the core dump file of the embedded system to obtain exception information and send the exception information to the debugger 12 according to the debugging instructions.

[0024] Specifically, this embodiment is mainly targeted at embedded operating systems, where the types of embedded operating systems include: embedded Linux, Windows CE, Windows XP Embedded, Vxworks, Android, iOS, UNIX, etc., and this embodiment does not limit the specific type of embedded operating system. During the normal operation of the embedded operating system, if an application program terminates abnormally, core dump files of different formats will be generated for different embedded operating systems to save relevant data at the time of the abnormality. For example, the format of the core dump file generated for the embedded Linux operating system is .core dump, and the format of the core dump file generated for the UNIX operating system is .elf. Of course, this embodiment is only for illustration and does not limit the format of the core dump file generated by each embedded operating system.

[0025] Optionally, establishing a communication connection with a local debug adapter located locally via remote communication includes: the debugger establishing a communication connection with the local debug adapter by sending a connection command to the local debug adapter; wherein the connection command includes communication port information of the local debug adapter.

[0026] The host computer where the local debug adapter resides provides a Transmission Control Protocol (TCP) server. Therefore, before the debugger sends debugging instructions to the local debug adapter, it first establishes a communication connection with the local debug adapter via remote communication based on the TCP server. For example, the debugger sends a connection command "target remote127.0.0.1:2332" to the local debug adapter, where the connection command includes the local debug adapter's communication port information: communication port 2332. After receiving the connection command, the local debug adapter establishes a communication connection with the debugger by calling communication port 2332.

[0027] Among them, the exception information in this embodiment includes: register information, memory information and task process; and the debugging types corresponding to the debugging instructions specifically include: register debugging, memory debugging and task process debugging. Therefore, after determining the debugging type, the debugger in this embodiment sends the debugging instruction corresponding to the debugging type to the local debugging adapter. After the local debugging adapter parses the core dump file of the embedded system to obtain the exception information, it feeds back the corresponding type of exception information to the debugger according to the debugging instruction. Therefore, the debugger in this embodiment realizes the remote debugging function of the debugger through a remote communication connection with the local debugging adapter, that is, the core dump file is not parsed directly by the debugger itself, but the parsing work is transferred to the local debugging adapter. The debugging adapter only implements basic processing actions such as displaying the parsing results, so that the operation and maintenance personnel can determine the cause of the fault based on the display results of the exception information and troubleshoot the fault to ensure the normal operation of the embedded operating system.

[0028] The technical solution of the embodiment of the present invention adds a local debugging adapter to pre-parse the core dump file of the embedded system to obtain exception information. The debugger adopts the remote debugging mode to obtain the exception information without having to modify a large amount of debugger code to complete the parsing of the core dump file, thereby reducing the implementation difficulty and development cost of the core dump.

[0029] Example 2

[0030] Figure 2 This is a debugging device for core dump of an embedded system provided by an embodiment of the present invention. This embodiment is based on the above embodiment. In this embodiment, the structure of the local debugging adapter 11 is specifically described.

[0031] like Figure 2 As shown, the local debug adapter 11 includes a dump file parser 111, a protocol debugging module 112, and a local network communication service module. The dump file parser 111 is used to parse the embedded system's core dump file to obtain exception information; the protocol debugging module 112 is used to perform protocol adaptation processing on the exception information according to the protocol format supported by the debugger; and the local network communication service module 113 is used to establish a communication connection with the debugger and transmit the exception information after protocol adaptation processing to the debugger. Through the interaction of these three internal structures, the local debug adapter can parse core dump files of different formats and transmit the exception information obtained from the parsing to the debugger according to the protocol format supported by the debugger.

[0032] Among them, the debugger in this embodiment specifically includes the GNU Debugger (GDB), and the protocol format supported by the debugger includes the GDB standard remote communication protocol (Remote Serial Protocol, RSP), and the protocol debugging module and the local network communication service module communicate using the Modeling Interface (MI) protocol.

[0033] Optionally, the dump file parser supports parsing operations on core dump files in one or more formats; the dump file parser provides different types of exception information calling interfaces for the protocol debugging module according to the type of exception information.

[0034] Specifically, the core dump file parser in this embodiment is specifically used to obtain a core dump file generated by an embedded system and supports parsing operations for core dump files of one or more formats. For example, when determining that the core dump file obtained is generated by an embedded Linux operating system, the core dump file is identified and the format of the obtained core dump file is determined to be .coredump. Since different parsing methods correspond to core dump files of different format types, the dump file parser can specifically determine the parsing method based on the format type by querying a parsing list, wherein the parsing list specifically includes a correspondence between the format type of the dump file and the parsing method. Furthermore, in the parsing method, specifically for some unsupported format types, the specified content in the parsing program code included in the dump file parser can be modified to adapt to different formats. Of course, when the format type of the dump file is supported by the debugger, it is generally not necessary to modify the parsing program code.

[0035] It should be noted that although the embodiment of the present application involves modification of the parsing program code in the process of determining the parsing method, due to the single function of the dump file parser, the modification of the dump file parser is much simpler than the modification of a large and complex debugger, both in terms of modification method and modification content.

[0036] The dump file parser parses the obtained core dump file using a determined parsing method to obtain exception information. The exception information in this embodiment includes register information, memory information, task process information, and other information corresponding to the moment when the problem occurs in the embedded operating system. In addition, the dump file parser provides different types of exception information call interfaces for the protocol debugging module according to the type of exception information. For example, a read-write register call interface is provided for register information, a read-write memory call interface is provided for memory information, and a read-write task process call interface is provided for task process information, and each of the above interfaces supports the RSP protocol.

[0037] Optionally, the debugger is specifically used to determine the debugging type and send a debugging instruction corresponding to the debugging type to the local network communication service module of the local debugging adapter according to the debugging type; the local network communication service module is specifically used to call the protocol debugging module when receiving the debugging instruction, obtain the exception information corresponding to the debugging type, and send it to the debugger; the protocol debugging module is specifically used to call the exception information calling interface corresponding to the debugging type provided by the dump file parser according to the debugging type corresponding to the debugging instruction, obtain the corresponding type of exception information by calling the interface, and send it to the local network communication service module.

[0038] Specifically, since the debugging types include register debugging, memory debugging, and task process debugging, when the debugger specifically determines that the debugging type is register debugging, it will send a debugging instruction corresponding to the debugging type to the local network communication service module of the local debugging adapter according to the debugging type: request to read the register. When the local network communication service module receives the debugging instruction, it will call the protocol debugging module to obtain the exception information corresponding to the debugging type: register information and then send it to the debugger. Among them, when the protocol debugging module determines that it has received the debugging instruction, it will call the read and write register call interface provided by the dump file parser according to the debugging type corresponding to the debugging instruction, for example, register debugging in this example, and obtain the register exception information through the calling interface. Although the dump file parser can parse core dump files of different formats and obtain register exception data, if the register exception data is directly transmitted to the GDB debugger at this time, it may not be recognized, for example, there will be garbled characters. The protocol debugging module will perform RSP protocol adaptation on the parsed exception data to convert it into a data format that meets the RSP protocol transmission requirements, and then send it to the network communication service module, so that the GDB debugger can recognize the register exception information. Of course, this embodiment only uses register debugging as an example for explanation. For other debugging types, the debugging process is roughly the same as the above process, and will not be described in detail in this embodiment.

[0039] Example 3

[0040] Figure 3 This is a flow chart of a method for debugging a core dump of an embedded system provided by an embodiment of the present invention. This method can be executed by a debugging device for a core dump of an embedded system in an embodiment of the present invention. The debugging device for the core dump file includes a debugger and a local debug adapter. The debugger is configured in remote debugging mode to establish a communication connection with a local debug adapter via remote communication. Figure 3 As shown, the method specifically includes the following operations:

[0041] Step S101: The debugger sends a debugging instruction to the local debugging adapter.

[0042] Optionally, before the debugger sends the debugging instruction to the local debug adapter, the debugger may further send a connection command to the local debug adapter to establish a communication connection with the local debug adapter. The connection command may include communication port information of the local debug adapter.

[0043] The host computer where the local debug adapter resides provides a Transmission Control Protocol (TCP) server. Therefore, before the debugger sends debugging instructions to the local debug adapter, it first establishes a communication connection with the local debug adapter via remote communication based on the TCP server. For example, the debugger sends a connection command to the local debug adapter: target remote127.0.0.1:2332. The connection command includes the local debug adapter's communication port information: communication port 2332. After receiving the connection command, the local debug adapter establishes a communication connection with the debugger by calling communication port 2332.

[0044] The types of debugging instructions include register debugging, memory debugging, and task process debugging. The specific types of debugging instructions are not limited in this embodiment.

[0045] Step S102: The local debug adapter parses the core dump file of the embedded system to obtain exception information, and sends the exception information to the debugger according to the debugging instruction.

[0046] Optionally, the local debugging adapter parses the core dump file of the embedded system to obtain exception information, and sends the exception information to the debugger according to the debugging instructions, which may include: the local debugging adapter uses the dump file parser to parse the core dump file of the embedded system to obtain exception information; the local debugging adapter uses the protocol debugging module to perform protocol adaptation processing on the exception information according to the protocol format supported by the debugger; the local debugging adapter uses the local network communication service module to establish a communication connection with the debugger, and sends the exception information after protocol adaptation processing to the debugger.

[0047] Optionally, the dump file parser supports parsing operations on core dump files in one or more formats; the dump file parser provides different types of exception information calling interfaces for the protocol debugging module according to the type of exception information.

[0048] Specifically, the core dump file parser in this embodiment is specifically used to obtain a core dump file generated by an embedded system and supports parsing operations for core dump files of one or more formats. For example, when determining that the core dump file obtained is generated by an embedded Linux operating system, the core dump file is identified and the format of the obtained core dump file is determined to be .coredump. Since different parsing methods correspond to core dump files of different format types, the dump file parser can specifically determine the parsing method based on the format type by querying a parsing list, wherein the parsing list specifically includes a correspondence between the format type of the dump file and the parsing method. Furthermore, in the parsing method, specifically for some unsupported format types, the specified content in the parsing program code included in the dump file parser can be modified to adapt to different formats. Of course, when the format type of the dump file is supported by the debugger, it is generally not necessary to modify the parsing program code.

[0049] The dump file parser parses the obtained core dump file using a determined parsing method to obtain exception information. The exception information in this embodiment includes register information, memory information, task process information, and other information corresponding to the moment when the problem occurs in the embedded operating system. In addition, the dump file parser provides different types of exception information call interfaces for the protocol debugging module according to the type of exception information. For example, a read-write register call interface is provided for register information, a read-write memory call interface is provided for memory information, and a read-write task process call interface is provided for task process information, and each of the above interfaces supports the RSP protocol.

[0050] Optionally, the debugger is specifically used to determine the debugging type and send a debugging instruction corresponding to the debugging type to the local network communication service module of the local debugging adapter according to the debugging type; the local network communication service module is specifically used to call the protocol debugging module when receiving the debugging instruction, obtain the exception information corresponding to the debugging type, and send it to the debugger; the protocol debugging module is specifically used to call the exception information calling interface corresponding to the debugging type provided by the dump file parser according to the debugging type corresponding to the debugging instruction, obtain the corresponding type of exception information by calling the interface, and send it to the local network communication service module.

[0051] Among them, the debugger in this embodiment specifically includes the GNU Debugger (GDB), and the protocol format supported by the debugger includes the GDB standard remote communication protocol (Remote Serial Protocol, RSP), and the protocol debugging module and the local network communication service module communicate using the Modeling Interface (MI) protocol.

[0052] Step S103: The debugger receives the exception information sent by the local debug adapter.

[0053] In this embodiment, the debugger adopts a remote debugging mode and receives the abnormal information sent by the local debugging adapter based on a remote communication method.

[0054] It should be noted that, regarding the debugging method of the embedded system core dump, reference may be made to the specific functions of the modules disclosed in the above embodiments, which will not be described in detail in this embodiment.

[0055] The technical solution of the embodiment of the present invention adds a local debugging adapter to parse the core dump file of the embedded system to obtain exception information. The debugger only needs to use the remote debugging mode to obtain the exception information, avoiding the problem of directly using the debugger for debugging and parsing, which requires a large amount of code modification to the debugger to adapt to the parsing of dump files in different formats, thereby increasing the difficulty and cost of adaptation. Therefore, the solution described in the embodiment of the present invention can reduce the implementation difficulty and development cost of core dump.

[0056] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A debugging device for core dump of an embedded system, characterized in that: include: A debugger and a local debugging adapter, wherein the debugger is configured in a remote debugging mode to establish a communication connection with the local debugging adapter located locally via a remote communication method; The debugger is used to send a debugging instruction to the local debugging adapter and receive exception information sent by the local debugging adapter, wherein the exception information includes: register information, memory information and task process, and the debugging instruction includes a debugging type, and the debugging type includes: register debugging, memory debugging and task process debugging; The local debugging adapter is used to parse the core dump file of the embedded system to obtain exception information, and send the exception information to the debugger according to the debugging instruction.

2. The device according to claim 1, characterized in that The local debugging adapter includes: a dump file parser, a protocol debugging module and a local network communication service module; The dump file parser is used to parse the core dump file of the embedded system to obtain abnormal information; The protocol debugging module is used to perform protocol adaptation processing on the abnormal information according to the protocol format supported by the debugger; The local network communication service module is used to establish a communication connection with the debugger and send the exception information after protocol adaptation processing to the debugger.

3. The device according to claim 2, characterized in that The dump file parser supports parsing operations on core dump files in one or more formats; The dump file parser provides different types of exception information calling interfaces for the protocol debugging module according to the types of exception information.

4. The device according to claim 3, characterized in that The debugger is specifically used to determine a debugging type, and send a debugging instruction corresponding to the debugging type to the local network communication service module of the local debugging adapter according to the debugging type; The local network communication service module is specifically used to call the protocol debugging module upon receiving a debugging instruction, obtain the exception information corresponding to the debugging type, and send it to the debugger; The protocol debugging module is specifically used to call the exception information calling interface corresponding to the debugging type provided by the dump file parser according to the debugging type corresponding to the debugging instruction, obtain the corresponding type of exception information through the calling interface, and send it to the local network communication service module.

5. The device according to claim 1, characterized in that The step of establishing a communication connection with the local debugging adapter located locally by remote communication includes: The debugger establishes a communication connection with the local debug adapter by sending a connection command to the local debug adapter; wherein the connection command includes the communication port information of the local debug adapter.

6. The device according to claim 2, characterized in that The debugger includes a GDB debugger; The protocol format supported by the debugger includes the GDB RSP protocol; The protocol debugging module and the local network communication service module communicate with each other using the modeling interface MI protocol.

7. A method for debugging a core dump of an embedded system, applied in a debugging device including a debugger and a local debugging adapter, wherein: The debugger is configured in remote debugging mode to establish a communication connection with the local debugging adapter located locally through remote communication; The method comprises: The debugger sends a debugging instruction to the local debugging adapter, wherein the debugging instruction includes a debugging type, and the debugging type includes: register debugging, memory debugging, and task process debugging; The local debugging adapter parses the core dump file of the embedded system to obtain exception information, and sends the exception information to the debugger according to the debugging instruction, wherein the exception information includes: register information, memory information and task process; The debugger receives the exception information sent by the local debug adapter.

8. The method according to claim 7, characterized in that The local debugging adapter parses the core dump file of the embedded system to obtain exception information, and sends the exception information to the debugger according to the debugging instruction, including: The local debugging adapter uses a dump file parser to parse the core dump file of the embedded system to obtain abnormal information; The local debug adapter uses a protocol debugging module to perform protocol adaptation processing on the exception information according to a protocol format supported by the debugger; The local debugging adapter establishes a communication connection with the debugger using a local network communication service module, and sends the exception information after protocol adaptation processing to the debugger.

9. The method according to claim 7, characterized in that: Before the debugger sends the debugging instruction to the local debugging adapter, the method further includes: The debugger establishes a communication connection with the local debug adapter by sending a connection command to the local debug adapter; wherein the connection command includes the communication port information of the local debug adapter.