A method for implementing a microcontroller debugger based on CDB files and MI interface
Through the MCU debugger method based on CDB files and MI interface, the problem of difficult integration of 51 MCU debugger and IDE is solved, and efficient and flexible debugger and IDE integration is achieved, which supports multiple debugging commands and remote debugging, and improves debugging efficiency and user experience.
Patent Information
- Application Number
- CN202411446846.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-10-16
AI Technical Summary
There is a lack of 51 MCU debuggers with MI interfaces on the market, which makes it difficult to integrate the 51 MCU debugger with the integrated development environment (IDE) and inconvenience for learners to use.
A microcontroller debugger method based on CDB files and MI interface is provided. By reading CDB files and classifying and storing information, MI interface commands are implemented, a TCP communication port is created to interact with the microcontroller emulator, multiple debugging commands are supported, and the method communicates with the user interface through the MI interface.
It simplifies the integration of 51 MCU debugger and IDE, improves debugging efficiency and effect, enhances the flexibility and convenience of the debugger, supports remote debugging, and reduces the complexity and error rate of manual debugging.
Smart Images

Figure CN119440933B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of single-chip computer debugging, and in particular to a method for realizing a single-chip computer debugger based on a CDB file and an MI interface. Background Art
[0002] The 51 microcontroller, also known as the MCS-51 series, is an 8-bit microprocessor developed by Intel and widely used in embedded systems. Its simplicity, stability, and reliability have made it one of the most commonly used microcontrollers in embedded system development. It integrates multiple functional modules, including a central processing unit (CPU), memory, input / output (I / O), and timers / counters, enabling information acquisition, processing, and hardware device control. 51 microcontrollers are widely used in various fields, such as home appliances, automobiles, industrial measurement and control, and communications equipment. Unfortunately, no 51 microcontroller debugger with an MI debugging interface is currently available on the market.
[0003] A CDB file is a file format specifically designed for program debugging. It integrates rich debugging information and is crucial for developers during the debugging phase of the software lifecycle. This file records in detail the mapping between a program's source code and compiled machine code, allowing developers to directly view and edit the original code during debugging, thereby improving debugging efficiency. Furthermore, CDB files contain key information such as the type, scope, and memory address of each program variable, which is crucial for understanding the program's runtime status and tracing the source of problems. CDB files also record detailed information about functions, including their parameters, local variables, and the call relationships between them. This information helps developers quickly identify dependencies and interactions between functions, optimizing program structure and performance. Debug symbols are another key component of CDB files. They enable debuggers to identify and handle debugging operations such as breakpoints, single-stepping, and watch expressions within the program. Exception and error handling are an inevitable part of program development. The relevant exception and error handling information recorded in CDB files helps developers better understand and manage the program's abnormal flow. This information is crucial for building robust applications and improving user experience.
[0004] MI's primary advantage lies in its standardized protocol, which allows different development tools and environments to communicate with the debugger in a unified manner. This consistency significantly reduces the complexity of tool integration and improves development efficiency. MI's command set is extensive, covering a wide range of debugging operations, from setting breakpoints, single-stepping, to viewing variable values. This rich command set allows developers to manually enter commands in an interactive environment for real-time debugging. MI is a powerful aid for developers, helping them quickly identify and resolve problems, thereby improving software quality and development efficiency.
[0005] When learning about 51 single-chip microcomputers, using a debugger is crucial. It not only helps students understand the program execution flow, locate code errors, monitor variable status, and learn about the interaction between hardware and software, but also improves development efficiency, optimizes program performance, and deepens their understanding of the working principles of single-chip microcomputers, laying the foundation for more advanced programming and debugging techniques in the future. However, the current market lacks 51 single-chip microcomputer debuggers with machine interfaces (MIs). This makes it difficult to integrate these debuggers into integrated development environments (IDEs), and also brings inconvenience to learners using 51 single-chip microcomputer debuggers. Summary of the Invention
[0006] The purpose of the present invention is to provide a method for implementing a microcontroller debugger based on CDB files and MI interface, aiming to simplify the integration process of 51 debugger and IDE, reduce the difficulty of users using 51 microcontroller debugger, and improve the efficiency and effect of the debugging process.
[0007] The present invention achieves the above-mentioned purpose through the following technical solutions:
[0008] A method for implementing a single-chip computer debugger based on a CDB file and an MI interface comprises the following steps:
[0009] Read CDB files and classify the read content into different information records;
[0010] Parse the CDB file according to the various information records obtained, and store the various information required for debugging contained in the CDB file into various structure linked lists;
[0011] Implement the debugger's debug command function according to the simulator's debug command parameters, and encapsulate the debug command into a string format that the simulator can recognize;
[0012] Implement the MI interface command in the main program of the microcontroller debugger. This command is used for communication between the debugger and the user interface. Register the MI interface with the debugger so that it can receive user commands through the MI interface.
[0013] Create a TCP communication port in the MCU debugger to interact with the MCU emulator for debugging commands;
[0014] Set up a monitoring mechanism in the MCU debugger to wait for the user to input MI interface debugging commands;
[0015] Parse the MI interface debugging command input by the user, encapsulate the parsed debugging instruction into a string format that the emulator can recognize, send the encapsulated debugging instruction to the MCU emulator through the TCP protocol, receive the debugging result returned by the MCU emulator, and encapsulate the result into MI interface format data;
[0016] Return the encapsulated MI format data to the user through the MI interface;
[0017] Continue to wait for the user to input MI interface debugging commands to form a closed-loop debugging process.
[0018] According to a method for implementing a single-chip microcomputer debugger based on a CDB file and an MI interface provided by the present invention, the method of reading a CDB file and classifying the read content to form different information records includes:
[0019] In the main program of the microcontroller debugger, the CDB file is opened through the load_cdb function, and then the contents of the CDB file are read line by line and stored in the CDB file memory buffer of the main program. Then the main program classifies the read contents according to the first letter of each line in the CDB file memory buffer, namely symbol information record, structure information record, link address information record, function information record and source code file information record.
[0020] According to the present invention, a method for implementing a microcontroller debugger based on a CDB file and an MI interface is provided, wherein the CDB file contains various information required for debugging and is stored in various structure linked lists, including:
[0021] Get the file module information of the source file and store it in the file module structure of the system, get the function information of the source file and store it in the function structure of the system, get the variable information of the source file and store it in the variable structure of the system, get the symbol information of the source file and store it in the symbol structure of the system, get the symbol link information of the source file and store it in the link structure of the system.
[0022] According to a method for implementing a single-chip microcomputer debugger based on a CDB file and an MI interface provided by the present invention, the method of implementing an MI interface command in a main program of the single-chip microcomputer debugger includes:
[0023] Define a processing function for each MI interface command, which is used to parse command parameters, call the corresponding debugger internal command, and construct a response in MI format;
[0024] Create a command registry to associate MI interface commands with processing functions;
[0025] Parse the MI interface command entered by the user, search for the corresponding processing function in the command registry, call the processing function, and obtain the response generated by it;
[0026] The MI interface command parsing and dispatching functions are integrated into the loop of the debugger main program to implement the MI interface commands.
[0027] According to a method for implementing a microcontroller debugger based on a CDB file and an MI interface provided by the present invention, after completing the implementation of the TCP communication port and successfully establishing a connection with the emulator, the debugger main program will enter the commandLoop function, and the commandLoop function will wait for the MI interface debugging command input by the user.
[0028] According to a method for implementing a single-chip microcomputer debugger based on a CDB file and an MI interface provided by the present invention, after receiving an MI interface debugging command input by a user, the debugger main program parses the command by calling the prasecmd_mi function. The prasecmd_mi function identifies the type and parameters of the command and matches it with the MI interface commands registered in the system. If a match is found with an MI interface command previously registered in the system, the MI interface command is called, which further calls the corresponding regular debugging command to execute the debugging operation requested by the user.
[0029] Conventional debugging commands encapsulate debugging instructions into string data packets and send them to the MCU emulator through the TCP protocol and wait for the MCU emulator to respond to the debugging instructions. Once the response is received, the debugger main program will parse the response and convert it into a return result in MI format as needed.
[0030] According to a method for implementing a microcontroller debugger based on CDB files and MI interface provided by the present invention, after obtaining the return result of the microcontroller simulator executing a command, the return result is encapsulated into the data format of the MI interface specification through the decode_data_mi function.
[0031] According to a method for implementing a single-chip computer debugger based on a CDB file and an MI interface provided by the present invention, the following steps are further performed:
[0032] Use the asynchronous network communication library to communicate with the emulator, put the debugging commands into a task queue, use the asynchronous task scheduler to execute these tasks, and when the task is completed, process the results through the callback function.
[0033] According to a method for implementing a single-chip computer debugger based on a CDB file and an MI interface provided by the present invention, the following steps are further performed:
[0034] If the CDB file is large or frequently read, cache its contents in memory to reduce file I / O operations and improve reading speed.
[0035] According to a method for implementing a single-chip microcomputer debugger based on a CDB file and an MI interface, when a program is started or when a CDB file is first accessed, the contents of the file are read into a cache, the file contents are read line by line or block by block, the read contents are parsed into a data structure, and the data structure is stored in the cache;
[0036] When a program needs to access data in a CDB file, it first checks whether the data already exists in the cache. If so, it reads the data directly from the cache without accessing the file. If not, it reads the data from the file, adds it to the cache, and then returns it to the requester.
[0037] It can be seen that compared with the prior art, the method provided by the present invention has the following beneficial effects:
[0038] 1. The present invention can efficiently manage and utilize various information required for debugging by reading and classifying the contents of CDB files, and storing the information of CDB files in a structure linked list, which helps to quickly access and retrieve debugging information.
[0039] 2. The present invention can encapsulate debugging commands according to debugging command parameters of the emulator, thereby ensuring that the debugger can send commands that the emulator can recognize, allowing the debugger to support multiple debugging commands, and improving debugging flexibility.
[0040] 3. The present invention uses the MI interface for communication between the debugger and the user interface, which simplifies the interaction between the user and the debugger. The user can send debugging commands and receive debugging results through the MI interface without having to understand the underlying debugging details.
[0041] 4. The present invention creates a TCP communication port, and the debugger can interact with the single-chip computer simulator to perform remote debugging commands, which allows users to remotely debug the single-chip computer in different geographical locations, thereby improving the convenience of debugging.
[0042] 5. The present invention can receive the debugging results returned by the single-chip emulator in real time through the debugger, and encapsulate it into data in MI interface format and return it to the user, so that the user can understand the debugging progress and results in time, and thus quickly locate and solve the problem.
[0043] 6. The present invention forms a closed-loop debugging process by setting a monitoring mechanism and waiting for the user to input the MI interface debugging command. The user can continuously send debugging commands and receive feedback until the entire debugging process is completed.
[0044] 7. Since the present invention uses a structured method to process CDB files and debugging commands, it is easy to expand and maintain. Developers can easily add new debugging commands or modify existing debugging logic to meet different debugging requirements.
[0045] 8. The automated and standardized debugging process of the present invention reduces the complexity and error rate of manual debugging, and the debugger can quickly respond to and process debugging commands, thereby improving debugging efficiency.
[0046] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 The present invention is a flowchart of a method embodiment for realizing a single chip computer debugger based on CDB files and MI interface.
[0048] Figure 2 The present invention is a schematic diagram of the process principle of a method embodiment for realizing a single-chip computer debugger based on a CDB file and an MI interface. DETAILED DESCRIPTION
[0049] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0050] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0051] The MI (Machine Interface) is a text-based interface designed specifically for integrating debuggers into other systems (especially integrated development environments (IDEs)). It provides a standardized method for implementing debugging functions. The 51 MCU debugger-MI interface, based on the CDB (Code and Debug Information File) file format, provides a unified interface for integrating the 51 MCU debugger with the IDE. This interface allows the IDE to communicate with the 51 MCU debugger through a standardized command set, enabling debugging operations such as breakpoint setting, program execution control, variable observation, and memory viewing, thereby enhancing the functionality of the development environment and user programming convenience. Through this integration, developers can debug the 51 MCU emulator directly in the IDE, improving development efficiency and debugging flexibility.
[0052] This embodiment uses a 51-specific compiler (SDCC) with a debug compilation option. The 51-specific compiler (SDCC) generates debug information in a CDB file format. This debug information records the program's source code mapping, detailed information about variables and functions, and debug symbols. Based on this debug information, this embodiment provides a 51 debugger based on the CDB file format. However, this debugger lacks an MI interface, making it unsuitable for IDE integration. Therefore, a crucial question arises: how to develop a 51 debugger based on CDB files while also integrating it into an IDE in a way that is suitable for novice users. The method provided in this embodiment aims to address this issue.
[0053] While a vast number of users are currently learning and using 51 single-chip microcomputers, debuggers for these devices are unfortunately few and far between. A 51 single-chip microcomputer debugger with an MI interface suitable for IDE integration has yet to be found. This embodiment implements a powerful CDB file-based 51 single-chip microcomputer debugger with an MI interface. This debugger utilizes the universality of the MI interface and is easily integrated into IDEs, effectively reducing the difficulty for users to use a 51 single-chip microcomputer debugger and improving the efficiency and effectiveness of the debugging process.
[0054] See also Figure 1 and Figure 2 This embodiment provides a method for implementing a microcontroller debugger based on a CDB file and an MI interface, the method comprising the following steps:
[0055] Step S1, read the CDB file and classify the read content into different information records;
[0056] Step S2, parsing the CDB file according to the various information records obtained, and storing the various information required for debugging contained in the CDB file into various structure linked lists;
[0057] Step S3, implementing the debugger's debug command function according to the simulator's debug command parameters, and encapsulating the debug command into a character string format that the simulator can recognize;
[0058] Step S4, implementing the MI interface command in the main program of the MCU debugger, which is used for communication between the debugger and the user interface, registering the MI interface with the debugger so that it can receive user commands through the MI interface;
[0059] Step S5, creating a TCP communication port in the single-chip microcomputer debugger for interacting with the single-chip microcomputer emulator for debugging commands;
[0060] Step S6, setting a monitoring mechanism in the MCU debugger to wait for the user to input an MI interface debugging command;
[0061] Step S7, parsing the MI interface debugging command input by the user, encapsulating the parsed debugging instruction into a string format that the emulator can recognize, sending the encapsulated debugging instruction to the MCU emulator via the TCP protocol, and receiving the debugging result returned by the MCU emulator, and encapsulating the result into data in the MI interface format;
[0062] Step S8: Return the encapsulated MI format data to the user through the MI interface;
[0063] Step S9: Continue to wait for the user to input the MI interface debugging command, forming a closed-loop debugging process.
[0064] In the above step S1, the CDB file is read and the read content is classified into different information records, including:
[0065] In the main program of the microcontroller debugger, the CDB file is opened through the load_cdb function, and then the contents of the CDB file are read line by line and stored in the CDB file memory buffer of the main program. Then the main program classifies the read contents according to the first letter of each line in the CDB file memory buffer, namely symbol information record, structure information record, link address information record, function information record and source code file information record.
[0066] Specifically, the 51 MCU debugger's main program first opens the CDB file using the load_cdb function. It then reads the file's contents line by line and stores them in the main program's CDB file memory buffer. The main program then categorizes the read contents based on the first letter of each line in the CDB file's memory buffer. The letter S indicates a symbol information record, the letter T indicates a structure information record, the letter L indicates a link address information record, the letter F indicates a function information record, and the letter M indicates a source code file information record.
[0067] In the above step S2, the CDB file contains various information required for debugging and is stored in various structure lists, including:
[0068] Get the file module information of the source file and store it in the file module structure of the system, get the function information of the source file and store it in the function structure of the system, get the variable information of the source file and store it in the variable structure of the system, get the symbol information of the source file and store it in the symbol structure of the system, get the symbol link information of the source file and store it in the link structure of the system.
[0069] Specifically, the main program obtains the file module information of the 51 source file according to the various information records obtained in the above step S1 and stores it in the C51_file structure linked list in the system, obtains the function information of the 51 source file and stores it in the C51_function structure linked list in the system, obtains the variable information of the 51 source file and stores it in the C51_struct structure linked list in the system, obtains the symbol information of the 51 source file and stores it in the C51_symbol structure linked list in the system, and obtains the link information of the 51 source file and stores it in the C51_link structure linked list in the system.
[0070] In the above step S3, the 51 single-chip microcomputer debugger main program implements commonly used debugging commands in the debugger according to the debugging commands supported by the 51 single-chip microcomputer emulator, such as single-step operation (step_func / next_func), continuous operation (continue_func), pause operation (stop_func), set breakpoints (break_func), view breakpoints (break_list_func), delete breakpoints (break_delete_func), view registers (read_reg_func), write registers (write_reg_func), view memory (read_memory_func), write memory (write_memory_func), view variables (read_var_func), write variables (write_var_func) and other debugging commands. These debugging commands are closely related to the C51_file, C51_function, C51_struct, C51_symbol, and C51_link structures in the above step S2.
[0071] In the above step S4, MI interface commands such as "-break-insert", "-break-list", "-exec-continue", and "-data-read-memory-bytes" are implemented in the 51 MCU debugger main program and registered in the system. These MI interface commands are further encapsulations of the corresponding debugging commands in the above step S3.
[0072] In the above step S4, the MI interface command is implemented in the main program of the microcontroller debugger, specifically including:
[0073] Define a processing function for each MI interface command, which is used to parse command parameters, call the corresponding debugger internal command, and construct a response in MI format;
[0074] Create a command registry to associate MI interface commands with processing functions;
[0075] Parse the MI interface command entered by the user, search for the corresponding processing function in the command registry, call the processing function, and obtain the response generated by it;
[0076] The MI interface command parsing and dispatching functions are integrated into the loop of the debugger main program to implement the MI interface commands.
[0077] In the above step S6, after the TCP communication port is implemented and the connection with the emulator is successfully established, the debugger main program will enter the commandLoop function, and the commandLoop function will wait for the MI interface debugging command input by the user.
[0078] In the above step S7, after receiving the MI interface debugging command input by the user, the debugger main program parses it by calling the prasecmd_mi function. The prasecmd_mi function will identify the type and parameters of the command and match it with the MI interface command registered in the system. If it matches the MI interface command previously registered in the system, this MI interface command will be called, and the command will further call the corresponding regular debugging command to execute the debugging operation requested by the user.
[0079] Conventional debugging commands encapsulate debugging instructions into string data packets and send them to the MCU emulator through the TCP protocol and wait for the MCU emulator to respond to the debugging instructions. Once the response is received, the debugger main program will parse the response and convert it into a return result in MI format as needed.
[0080] In the above step S8, after obtaining the return result of the execution command of the single chip emulator, the return result is encapsulated into the data format of the MI interface specification through the decode_data_mi function.
[0081] In this embodiment, the following steps are also performed: using an asynchronous network communication library to communicate with the emulator, putting debugging commands into a task queue, using an asynchronous task scheduler to execute these tasks, and processing the results through a callback function when the tasks are completed.
[0082] In this embodiment, if the CDB file is large or frequently read, its content is cached in the memory to reduce file I / O operations and improve the reading speed.
[0083] Specifically, when a program starts or needs to access a CDB file for the first time, the file contents are read into the cache line by line or block by block, parsed into a data structure, and stored in the cache. When a program needs to access data in a CDB file, it first checks whether the data already exists in the cache. If so, it reads the data directly from the cache without accessing the file. If not, it reads the data from the file, adds it to the cache, and then returns it to the requester.
[0084] In practical applications, this embodiment first records the debugging information of the 51 MCU's executable program using a CDB file. This debugging information records the program's source code mapping, detailed information about variables and functions, and debugging symbols. By loading and parsing the CDB file, the 51 debugger main program can obtain detailed information about the 51 MCU's executable program, such as function addresses, variable addresses, variable types, and file modules. Debug commands such as single-step run, continuous run, pause, breakpoint, get variable value, get memory value, and get function stack are then integrated into the 51 debugger main program. The MI interface format for these debugging commands is then adapted within the 51 debugger main program. Finally, the 51 debugger main program loops, waiting to receive MI interface commands and encapsulating the command execution results in MI interface format for output. 51 MCU debuggers that adhere to the MI interface specification have a unified debugging interface, making them easily integrated into IDEs.
[0085] In summary, the present invention can efficiently manage and utilize various information required for debugging by reading and classifying the contents of CDB files, and storing the information of CDB files in a structure linked list, which helps to quickly access and retrieve debugging information. The present invention can encapsulate debugging commands according to the debugging command parameters of the emulator, thereby ensuring that the debugger can send commands that the emulator can recognize, allowing the debugger to support multiple debugging commands, and improving the flexibility of debugging. The present invention uses the MI interface for communication between the debugger and the user interface, which simplifies the interaction between the user and the debugger. The user can send debugging commands and receive debugging results through the MI interface without understanding the underlying debugging details. The present invention creates a TCP communication port, so that the debugger can interact with the single-chip microcomputer emulator for remote debugging commands, which allows the user to remotely debug the single-chip microcomputer in different geographical locations, improving the convenience of debugging. The present invention can receive the debugging results returned by the single-chip microcomputer emulator in real time through the debugger, and encapsulate it into data in the MI interface format and return it to the user, so that the user can promptly understand the debugging progress and results, thereby quickly locating and solving problems. The present invention establishes a closed-loop debugging process by setting up a monitoring mechanism and waiting for the user to input MI interface debugging commands. The user can continuously send debugging commands and receive feedback until the entire debugging process is completed. Because the present invention uses a structured method to process CDB files and debugging commands, it is easy to expand and maintain. Developers can easily add new debugging commands or modify existing debugging logic to accommodate different debugging needs. The present invention's automated and standardized debugging process reduces the complexity and error rate of manual debugging. The debugger can quickly respond to and process debugging commands, thereby improving debugging efficiency.
[0086] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0087] The above embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and replacements made by technicians in this field on the basis of the present invention fall within the scope of protection required by the present invention.
Claims
1. A method for implementing a microcontroller debugger based on a CDB file and an MI interface, characterized in that: The following steps are involved: Read CDB files and classify the read content into different information records; Parse the CDB file according to the various information records obtained, and store the various information required for debugging contained in the CDB file into various structure linked lists; Implement the debugger's debug command function according to the simulator's debug command parameters, and encapsulate the debug command into a string format that the simulator can recognize; Implement the MI interface command in the main program of the microcontroller debugger. This command is used for communication between the debugger and the user interface. Register the MI interface with the debugger so that it can receive user commands through the MI interface. Create a TCP communication port in the MCU debugger to interact with the MCU emulator for debugging commands; Set up a monitoring mechanism in the MCU debugger to wait for the user to input MI interface debugging commands; Parse the MI interface debugging command input by the user, encapsulate the parsed debugging instruction into a string format that the emulator can recognize, send the encapsulated debugging instruction to the MCU emulator through the TCP protocol, receive the debugging result returned by the MCU emulator, and encapsulate the result into MI interface format data; Return the encapsulated MI format data to the user through the MI interface; Continue to wait for the user to input MI interface debugging commands to form a closed-loop debugging process.
2. The method according to claim 1, characterized in that The CDB file is read and the read content is classified into different information records, including: In the main program of the microcontroller debugger, the CDB file is opened through the load_cdb function, and then the contents of the CDB file are read line by line and stored in the CDB file memory buffer of the main program. Then the main program classifies the read contents according to the first letter of each line in the CDB file memory buffer, namely symbol information record, structure information record, link address information record, function information record and source code file information record.
3. The method according to claim 1, characterized in that The CDB file contains various information required for debugging and is stored in various structure lists, including: Get the file module information of the source file and store it in the file module structure of the system, get the function information of the source file and store it in the function structure of the system, get the variable information of the source file and store it in the variable structure of the system, get the symbol information of the source file and store it in the symbol structure of the system, get the symbol link information of the source file and store it in the link structure of the system.
4. The method according to claim 1, wherein The implementation of the MI interface command in the main program of the single-chip debugger includes: Define a processing function for each MI interface command, which is used to parse command parameters, call the corresponding debugger internal command, and construct a response in MI format; Create a command registry to associate MI interface commands with processing functions; Parse the MI interface command entered by the user, search for the corresponding processing function in the command registry, call the processing function, and obtain the response generated by it; The MI interface command parsing and dispatching functions are integrated into the loop of the debugger main program to implement the MI interface commands.
5. The method according to claim 1, wherein: After completing the implementation of the TCP communication port and successfully establishing a connection with the emulator, the debugger main program will enter the commandLoop function, which will wait for the MI interface debugging command input by the user.
6. The method according to claim 1, wherein: After receiving the MI interface debugging command input by the user, the debugger main program parses it by calling the prasecmd_mi function. The prasecmd_mi function identifies the type and parameters of the command and matches it with the MI interface commands registered in the system. If a match is found with the MI interface command previously registered in the system, the MI interface command is called, which further calls the corresponding regular debugging command to perform the debugging operation requested by the user. Conventional debugging commands encapsulate debugging instructions into string data packets and send them to the MCU emulator through the TCP protocol and wait for the MCU emulator to respond to the debugging instructions. Once the response is received, the debugger main program will parse the response and convert it into a return result in MI format as needed.
7. The method according to claim 6, characterized in that: After obtaining the return result of the microcontroller simulator execution command, the return result is encapsulated into the data format of the MI interface specification through the decode_data_mi function.
8. The method according to any one of claims 1 to 7, characterized in that Also execute: Use the asynchronous network communication library to communicate with the emulator, put the debugging commands into a task queue, use the asynchronous task scheduler to execute these tasks, and when the task is completed, process the results through the callback function.
9. The method according to any one of claims 1 to 7, characterized in that Also execute: If the CDB file is large or frequently read, cache its contents in memory to reduce file I / O operations and improve reading speed.
10. The method according to claim 9, characterized in that: When the program starts or when a CDB file is accessed for the first time, the file contents are read into the cache line by line or block by block, the read contents are parsed into a data structure, and stored in the cache. When a program needs to access data in a CDB file, it first checks whether the data already exists in the cache. If so, it reads the data directly from the cache without accessing the file. If not, it reads the data from the file, adds it to the cache, and then returns it to the requester.
Citation Information
Patent Citations
Method and system for checking embedded software debugging parameter in real time
CN104503898A
Chip debugging method
CN115617589A