CN108319555B - Real-time debugging method based on embedded real-time system - Google Patents
Real-time debugging method based on embedded real-time system Download PDFInfo
- Publication number
- CN108319555B CN108319555B CN201810221411.1A CN201810221411A CN108319555B CN 108319555 B CN108319555 B CN 108319555B CN 201810221411 A CN201810221411 A CN 201810221411A CN 108319555 B CN108319555 B CN 108319555B
- Authority
- CN
- China
- Prior art keywords
- program
- real
- context information
- embedded
- debugging
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/3636—Software debugging by tracing the execution of the program
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a real-time debugging method based on an embedded real-time system, which comprises the following steps: installing a GUI program and a GDB debugging program on a PC, installing a multithreading server program and an interrupt service program on embedded equipment, and connecting the PC with the embedded equipment; setting breakpoints for code lines in an original program in a GUI program to obtain an instruction address, and sending the instruction address to embedded equipment; the multithreading server program replaces the instruction in the instruction address with an interrupt triggering instruction and runs an interrupt service program; the interrupt service program captures context information and sends the context information to the GDB debugging program; and the GDB debugger analyzes the context information and outputs the context information. The invention combines the log debugging method and the breakpoint debugging method simultaneously, so that the information of the context of the specified code can be checked at will during the real-time system debugging, the program execution flow is not suspended, the execution time sequence of the program is not influenced, the execution efficiency is high, and the context information is output in the GDB debugging program, so that the reason is easy to analyze and the maintenance is easy.
Description
Technical Field
The invention relates to the technical field of embedded real-time system time sequence control, in particular to a real-time debugging method based on an embedded real-time system.
Background
Today, with the rapid development of digital information technology and network technology, embedded systems have been widely penetrated in various aspects such as people's daily lives. As the complexity of real-time embedded systems continues to increase, the cost of inefficient debugging methods is increasing. Given the continuing trend of increasing complexity of current embedded applications, debugging of these systems will become a key factor in speeding up product marketing and providing robust end products. With the use of multithreading and interrupt nesting by applications, most of the developer's time is currently spent debugging. The real-time nature of the application makes it more difficult to isolate the problem of failure with multiple events occurring simultaneously. The embedded real-time system has very strict requirements on the sequence, even the execution of each thread has relatively strict time requirements, that is, the execution flow of the thread cannot be interrupted, which is a pain point in the development of the embedded real-time system: breakpoint debugging cannot be used in embedded real-time systems. The conventional solution is a log debugging method, and the implementation method is to write some information of the program during running into a log file. The log file is a file of a plain text, and information can be written in by using a C standard text file read-write function, but the method has the problems of difficulty in maintenance, influence on efficiency, difficulty in analysis and the like.
Disclosure of Invention
The invention aims to provide a real-time debugging method based on an embedded real-time system, which is used for solving the problems that the embedded system is difficult to maintain, the efficiency is influenced and the analysis is difficult when a log debugging method is adopted to debug the embedded system in the prior art.
In order to achieve the purpose, the invention is realized by the following technical scheme:
a real-time debugging method based on an embedded real-time system comprises the following steps:
step S100: installing a GUI program and a GDB debugging program on a PC, installing a multithreading server program and an interrupt service routine ISR on embedded equipment, and connecting the PC with the embedded equipment through a TCP/IP protocol;
step S200: setting a breakpoint in a code line in an original program in the GUI program, analyzing an intermediate file generated by a gcc compiler to obtain an instruction address corresponding to the code line where the breakpoint is located, and then sending the instruction address to the embedded equipment;
step S300: a multithreading server program installed on the embedded equipment receives the instruction address and replaces an instruction in the instruction address with an interrupt triggering instruction;
step S400: running an interrupt service routine ISR;
step S500: the ISR captures context information and copies the context information to a target memory;
step S600: the multithreading server program of the embedded equipment sends the context information in the target memory to the PC through a TCP/IP protocol;
step S700: and the GDB debugging program on the PC analyzes the context information and outputs the context information.
The working principle is as follows:
firstly, a PC and an embedded device are connected through a TCP/IP protocol, a GUI program and a GDB debugging program are installed on the PC, the GUI program is used for inputting an original program by a user, the GCC compiling program is used for compiling the original program, the GDB debugging program is used for debugging the original program, a multithreading server program and an interrupt service program ISR are installed on the embedded device, the multithreading server program is used for processing concurrent requests, the interrupt service program ISR runs in a core state and is different from the multithreading server program running in a user state, therefore, the interrupt service program ISR can modify the attribute of code segments through system call to enable the code segments to be readable and writable, and therefore the content of the interrupt service program ISR can be changed. And performing breakpoint setting on the original program in the GUI program, and analyzing an intermediate file generated by the gcc compiler to obtain an instruction address of a code line where the breakpoint is located. The PC sends the instruction address to a multithread server program on the embedded device, the multithread server program receives the instruction address and replaces the instruction in the instruction address with an interrupt trigger instruction, the executable program executes the interrupt trigger instruction, and firstly enters an interrupt vector table, and the table stores the entry address of the interrupt service program. When the executable program is executed to the code line where the breakpoint is located, the instruction corresponding to the code line is replaced by the interrupt triggering instruction, so that the interrupt is caused, and the interrupt service program is run. The interrupt service program is operated for capturing the context information of the code line where the breakpoint is located, the interrupt service program is short, the captured context information comprises a global variable, a local variable and a function call stack, the number of bytes is small, and after the context information is captured, the context information is copied into a user-defined target memory. After the interrupt service program is executed, the breakpoint of the original program is immediately returned to and the next instruction is continuously executed. Because the running time of the interrupt service program is short, the amount of captured information is very small, and the running time can be ignored compared with the running of the original program, the real-time execution of the original program is not influenced at all. And the multithreading server program of the embedded equipment sends the context information stored in the target memory to the PC, and the GDB debugging program on the PC analyzes the context information. Meanwhile, by combining a log debugging method and a breakpoint debugging method, the information of the context of the specified code can be checked at will during real-time system debugging, printing statements are not added, program execution flow is not suspended, and the execution time sequence of the program is not influenced, so that the execution efficiency is high, the context information captured by the interrupt service program is debugged and output in a GDB debugging program at a PC end, the reason is easy to analyze, and the maintenance is easy.
Further, the step S200 specifically includes:
step S210: setting in a GUI program, and setting a breakpoint on a certain code line of an original program by clicking the left side of the code line with a mouse;
step S220: the gcc compiler compiles and links the original program to obtain an executable file containing debugging information, and then analyzes the executable file by using a nm command to obtain an instruction address corresponding to a code line where the breakpoint is located;
step S230: and the PC sends the instruction address to the embedded equipment.
The working principle is as follows:
the embedded real-time system is debugged by manually setting breakpoints, after a mouse is clicked in an original program to set the breakpoints, the original program is compiled in a compiler to obtain an executable file, the executable file is analyzed by a nm command, and the instruction address of a code line where the breakpoints are located is read. The PC sends this instruction address to the embedded device.
Further, the step S300 specifically includes:
step S310: finding out a corresponding storage unit according to an instruction address in the original code;
step S320: and writing an interrupt triggering instruction into the storage unit.
The working principle is as follows:
and receiving the instruction address by the multithread server program installed on the embedded equipment, finding the corresponding storage unit, and replacing the content in the storage unit with an interrupt triggering instruction, so that when the program runs to a code line where the breakpoint is located, the interrupt triggering instruction is run, and the interrupt is triggered.
Further, the context information in step S500 includes a global variable, a local variable, and a function call stack.
The context information comprises global variables, local variables and function call stacks, the content contained in the context information is as little as possible, the requirement is met, and the running time of the interrupt service program is reduced.
Further, the context information does not exceed 256 bytes.
The information amount of the context information is small, so the running time of the interrupt service program is negligible relative to the running time of the original program.
Further, the PC is based on a Linux operating system, and the embedded device is based on an ARM.
The PC based on the Linux operating system and the embedded equipment based on the ARM form cross debugging of the embedded system, and the debugging is carried out between the PC and the embedded equipment in an online interactive mode.
Compared with the prior art, the invention has the following advantages and beneficial effects:
the invention combines the log debugging method and the breakpoint debugging method simultaneously, so that the information of the context of the specified code can be checked at will when the real-time system is debugged, the printing statement is not added, the program execution flow is not suspended, and the execution time sequence of the program is not influenced, therefore, the execution efficiency is high, the context information captured by the interrupt service program is debugged and output in the GDB debugging program at the PC end, the reason is easy to analyze, and the maintenance is easy.
Drawings
Fig. 1 is a schematic diagram of the present invention.
Detailed Description
ISR: interrupt service routine (interrupt service routine).
The present invention will be described in further detail with reference to examples, but the embodiments of the present invention are not limited thereto.
Example 1:
referring to fig. 1, a real-time debugging method based on an embedded real-time system includes:
step S100: installing a GUI program and a GDB debugging program on a PC, installing a multithreading server program and an interrupt service routine ISR on embedded equipment, and connecting the PC with the embedded equipment through a TCP/IP protocol;
step S200: setting a breakpoint in a code line in an original program in the GUI program, analyzing an intermediate file generated by a gcc compiler to obtain an instruction address corresponding to the code line where the breakpoint is located, and then sending the instruction address to the embedded equipment;
step S300: a multithreading server program installed on the embedded equipment receives the instruction address and replaces an instruction in the instruction address with an interrupt triggering instruction;
step S400: running an interrupt service routine ISR;
step S500: the ISR captures context information and copies the context information to a target memory;
step S600: the multithreading server program of the embedded equipment sends the context information in the target memory to the PC through a TCP/IP protocol;
step S700: and the GDB debugging program on the PC analyzes the context information and outputs the context information.
The working principle is as follows:
firstly, a PC and an embedded device are connected through a TCP/IP protocol, a GUI program and a GDB debugging program are installed on the PC, the GUI program is used for inputting an original program by a user, the GCC compiling program is used for compiling the original program, the GDB debugging program is used for debugging the original program, a multithreading server program and an interrupt service program ISR are installed on the embedded device, the multithreading server program is used for processing concurrent requests, the interrupt service program ISR runs in a core state and is different from the multithreading server program running in a user state, therefore, the interrupt service program ISR can modify the attribute of code segments through system call to enable the code segments to be readable and writable, and therefore the content of the interrupt service program ISR can be changed. And performing breakpoint setting on the original program in the GUI program, and analyzing an intermediate file generated by the gcc compiler to obtain an instruction address of a code line where the breakpoint is located. The PC sends the instruction address to a multithread server program on the embedded device, the multithread server program receives the instruction address and replaces the instruction in the instruction address with an interrupt trigger instruction, the executable program executes the interrupt trigger instruction, and firstly enters an interrupt vector table, and the table stores the entry address of the interrupt service program. When the executable program is executed to the code line where the breakpoint is located, the instruction corresponding to the code line is replaced by the interrupt triggering instruction, so that the interrupt is caused, and the interrupt service program is run. The interrupt service program is operated for capturing the context information of the code line where the breakpoint is located, the interrupt service program is short, the captured context information comprises a global variable, a local variable and a function call stack, the number of bytes is small, and after the context information is captured, the context information is copied into a user-defined target memory. After the interrupt service program is executed, the breakpoint of the original program is immediately returned to and the next instruction is continuously executed. Because the running time of the interrupt service program is short, the amount of captured information is very small, and the running time can be ignored compared with the running of the original program, the real-time execution of the original program is not influenced at all. And the multithreading server program of the embedded equipment sends the context information stored in the target memory to the PC, and the GDB debugging program on the PC analyzes the context information. Meanwhile, by combining a log debugging method and a breakpoint debugging method, the information of the context of the specified code can be checked at will during real-time system debugging, printing statements are not added, program execution flow is not suspended, and the execution time sequence of the program is not influenced, so that the execution efficiency is high, the context information captured by the interrupt service program is debugged and output in a GDB debugging program at a PC end, the reason is easy to analyze, and the maintenance is easy.
Example 2:
on the basis of embodiment 1, with reference to fig. 1, a real-time debugging method based on an embedded real-time system includes, in step S200:
step S210: setting in a GUI program, and setting a breakpoint on a certain code line of an original program by clicking the left side of the code line with a mouse;
step S220: the gcc compiler compiles and links the original program to obtain an executable file containing debugging information, and then analyzes the executable file by using a nm command to obtain an instruction address corresponding to a code line where the breakpoint is located;
step S230: and the PC sends the instruction address to the embedded equipment.
The working principle is as follows:
the embedded real-time system is debugged by manually setting breakpoints, after a mouse is clicked in an original program to set the breakpoints, the original program is compiled in a compiler to obtain an executable file, the executable file is analyzed by a nm command, and the instruction address of a code line where the breakpoints are located is read. The PC sends this instruction address to the embedded device.
Further, the step S300 specifically includes:
step S310: finding out a corresponding storage unit according to an instruction address in the original code;
step S320: and writing an interrupt triggering instruction into the storage unit.
The working principle is as follows:
and receiving the instruction address by the multithread server program installed on the embedded equipment, finding the corresponding storage unit, and replacing the content in the storage unit with an interrupt triggering instruction, so that when the program runs to a code line where the breakpoint is located, the interrupt triggering instruction is run, and the interrupt is triggered.
Example 3:
based on embodiment 2, as shown in fig. 1, the context information in step S500 includes a global variable, a local variable, and a function call stack.
The context information comprises global variables, local variables and function call stacks, the content contained in the context information is as little as possible, the requirement is met, and the running time of the interrupt service program is reduced.
Further, the context information does not exceed 256 bytes.
The information amount of the context information is small, so the running time of the interrupt service program is negligible relative to the running time of the original program.
Further, the PC is based on a Linux operating system, and the embedded device is based on an ARM.
The PC based on the Linux operating system and the embedded equipment based on the ARM form cross debugging of the embedded system, and the debugging is carried out between the PC and the embedded equipment in an online interactive mode.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, and all simple modifications and equivalent variations of the above embodiments according to the technical spirit of the present invention are included in the scope of the present invention.
Claims (5)
1. A real-time debugging method based on an embedded real-time system is characterized by comprising the following steps:
step S100: installing a GUI program and a GDB debugging program on a PC, installing a multithreading server program and an interrupt service routine ISR on embedded equipment, and connecting the PC with the embedded equipment through a TCP/IP protocol;
step S200: setting a breakpoint in a code line in an original program in the GUI program, analyzing an intermediate file generated by a gcc compiler to obtain an instruction address corresponding to the code line where the breakpoint is located, and then sending the instruction address to the embedded equipment;
step S300: a multithreading server program installed on the embedded equipment receives the instruction address and replaces an instruction in the instruction address with an interrupt triggering instruction;
step S400: running an interrupt service routine ISR;
step S500: the ISR captures context information and copies the context information to a target memory; the context information does not exceed 256 bytes;
step S600: the multithreading server program of the embedded equipment sends the context information in the target memory to the PC through a TCP/IP protocol;
step S700: and the GDB debugging program on the PC analyzes the context information and outputs the context information.
2. The real-time debugging method based on the embedded real-time system of claim 1, wherein the step S200 specifically comprises:
step S210: setting in a GUI program, and setting a breakpoint on a certain code line of an original program by clicking the left side of the code line with a mouse;
step S220: the gcc compiler compiles and links the original program to obtain an executable file containing debugging information, and then analyzes the executable file by using a nm command to obtain an instruction address corresponding to a code line where the breakpoint is located;
step S230: and the PC sends the instruction address to the embedded equipment.
3. The real-time debugging method based on the embedded real-time system according to claim 2, wherein the step S300 specifically comprises:
step S310: finding out a corresponding storage unit according to an instruction address in the original code;
step S320: and writing an interrupt triggering instruction into the storage unit.
4. The embedded real-time system-based real-time debugging method of any one of claims 1-3, wherein the context information in step S500 comprises global variables, local variables and function call stacks.
5. The real-time debugging method based on embedded real-time system of any of claims 1-3, characterized in that said PC is based on Linux operating system and said embedded device is based on ARM.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810221411.1A CN108319555B (en) | 2018-03-17 | 2018-03-17 | Real-time debugging method based on embedded real-time system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810221411.1A CN108319555B (en) | 2018-03-17 | 2018-03-17 | Real-time debugging method based on embedded real-time system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108319555A CN108319555A (en) | 2018-07-24 |
CN108319555B true CN108319555B (en) | 2021-03-09 |
Family
ID=62899331
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810221411.1A Expired - Fee Related CN108319555B (en) | 2018-03-17 | 2018-03-17 | Real-time debugging method based on embedded real-time system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108319555B (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109522000A (en) * | 2018-09-15 | 2019-03-26 | 谢琥 | Embedded GUI System and computer program product based on Linux |
CN109669866B (en) * | 2018-12-10 | 2021-04-30 | 北京航空航天大学 | Method for acquiring fault propagation path during software operation |
CN109753431B (en) * | 2018-12-19 | 2023-02-28 | 卡斯柯信号有限公司 | Integrated test method for hardware function diagnosis |
CN110096888B (en) * | 2019-04-18 | 2021-02-09 | 苏州浪潮智能科技有限公司 | Method and system for accelerating verification and analyzing SMM potential safety hazard |
CN110955598B (en) * | 2019-11-20 | 2024-02-27 | 杭州迪普科技股份有限公司 | Breakpoint processing method and device for kernel mode program |
CN112965892B (en) * | 2019-12-12 | 2024-06-21 | 大唐移动通信设备有限公司 | Abnormal information acquisition method and device of software system, electronic equipment and medium |
CN113590470B (en) * | 2021-06-30 | 2024-06-14 | 龙芯中科(成都)技术有限公司 | Software debugging method and device, electronic equipment and storage medium |
CN113742237B (en) * | 2021-09-13 | 2024-09-24 | 北京奕斯伟计算技术股份有限公司 | Program debugging method, device, equipment and storage medium |
CN114253837B (en) * | 2021-11-22 | 2023-03-24 | 杭州加速科技有限公司 | Multithreading debugging method and system for ATE (automatic test equipment) tester program and tester table |
CN117170987B (en) * | 2023-11-03 | 2024-03-08 | 睿思芯科(深圳)技术有限公司 | Monitoring method, system and related equipment of embedded real-time operating system |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7065481B2 (en) * | 1999-11-30 | 2006-06-20 | Synplicity, Inc. | Method and system for debugging an electronic system using instrumentation circuitry and a logic analyzer |
CN102411535B (en) * | 2011-08-02 | 2014-04-16 | 上海交通大学 | Navigating-SoC (System On Chip) simulating, verifying and debugging platform |
CN107315685A (en) * | 2017-06-28 | 2017-11-03 | 青岛东联信息科技有限公司 | A kind of real-time adjustment method of non-invasive procedure |
-
2018
- 2018-03-17 CN CN201810221411.1A patent/CN108319555B/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
CN108319555A (en) | 2018-07-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108319555B (en) | Real-time debugging method based on embedded real-time system | |
US8756572B2 (en) | Debugger-set identifying breakpoints after coroutine yield points | |
US7950001B2 (en) | Method and apparatus for instrumentation in a multiprocessing environment | |
US8370816B2 (en) | Device, method and computer program product for evaluating a debugger script | |
WO2021057057A1 (en) | Target-code coverage testing method, system, and medium of operating system-level program | |
CN104281520B (en) | Tracking and method, the apparatus and system of debugging | |
US10613964B2 (en) | Conditional debugging of server-side production code | |
CN110413316B (en) | Non-invasive testing system and method for intelligent contracts of block chain | |
US8806447B2 (en) | Step-type operation processing during debugging by machine instruction stepping concurrent with setting breakpoints | |
CN112882925A (en) | Diagnostic workflow for production commissioning | |
US8843899B2 (en) | Implementing a step-type operation during debugging of code using internal breakpoints | |
CN102184138A (en) | Method and system for automatically reproducing and positioning software error | |
US20040054991A1 (en) | Debugging tool and method for tracking code execution paths | |
CN102567164A (en) | Instruction set batch testing device and method for processor | |
Shibanai et al. | Actoverse: a reversible debugger for actors | |
JP2008033849A (en) | Fault analysis system | |
US8533683B2 (en) | Stack walking enhancements using sensorpoints | |
US8990784B2 (en) | Determining control flow divergence due to variable value difference | |
CN117632721A (en) | Method and device for generating test case and electronic equipment | |
Wu et al. | Techniques of maintaining evolving component-based software | |
Lauwaerts et al. | Event-Based Out-of-Place Debugging | |
CN117667672A (en) | Python code remote debugging method and system for industrial software | |
CN117076296A (en) | Control system, method, equipment and medium of network embedded equipment | |
EP3619612B1 (en) | Temporary de-optimization of target functions in a cloud debugger | |
CN108614704B (en) | Code compiling method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20210309 |