技术领域technical field
本发明涉及程序调试领域,尤其涉及一种软件在线调试方法和系统。The invention relates to the field of program debugging, in particular to a software online debugging method and system.
背景技术Background technique
目前,在软件开发以及软件开发后的使用过程中,不可避免地会出现各种软件问题。现有的用于定位软件问题的方法包括:运行日志、调试命令、单步追踪。At present, in the process of software development and use after software development, various software problems will inevitably occur. Existing methods for locating software problems include: running logs, debugging commands, and single-step tracing.
上述方法中,运行日志和调试命令需要将产生日志和调试信息的调试指令通过硬编码的方式预先写入软件程序的相应位置。通过硬编码写入的调试指令不易更改和删除,也因为通过硬编码写入的调试不易删除,占用了内存,使得在任意软件位置对软件错误进行定位变得不可行。此外,当技术人员通过硬编码的方式将调试指令写入软件程序的相应位置后,还需要对写入调试指令的软件程序重新进行调度、编译、连接和运行,在软件程序重新运行后,原先软件错误的运行环境可能发生丢失/改变,使软件错误不易复现。In the above method, the running logs and debugging commands need to pre-write the debugging instructions for generating logs and debugging information into corresponding positions of the software program in a hard-coded manner. The debugging instructions written by hard coding are not easy to change and delete, and because the debugging written by hard coding is not easy to delete, it takes up memory, making it impossible to locate software errors at any software location. In addition, after the technician writes the debugging instruction into the corresponding position of the software program by hard coding, it is necessary to re-schedule, compile, connect and run the software program written in the debugging instruction. After the software program is re-run, the original The operating environment of software errors may be lost/changed, making it difficult to reproduce software errors.
上述方法中,单步追踪为每执行完一条语句以后,就会停下来,显示运行情况,这种方法要求技术人员一直在现场以便对每条语句的运行结果进行分析,及时发现错误,并且这种方法更适合单任务的软件程序的调试。而在网络设备的实时软件程序中往往同时有几十个任务在运行、并且任务之间相互关联,单步追踪已不适应。In the above method, the single-step tracking means that after each statement is executed, it will stop and display the running status. This method requires technicians to be on site all the time in order to analyze the running results of each statement and find errors in time, and this This method is more suitable for debugging single-task software programs. However, in the real-time software program of network equipment, there are often dozens of tasks running at the same time, and the tasks are related to each other, so single-step tracking is no longer suitable.
发明内容Contents of the invention
本发明提供了一种软件在线调试方法和系统,以解决如何实现在调试过程中任意更改调试指令的问题。The invention provides a software online debugging method and system to solve the problem of how to change the debugging instructions arbitrarily during the debugging process.
为解决上述技术问题,本发明提供了一种软件在线调试方法,所述方法包括:In order to solve the above technical problems, the present invention provides a software online debugging method, the method comprising:
确定软件中的被追踪点;Determine the tracked point in the software;
当执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境;When executing to the tracked point, save the current running environment of the software at the tracked point;
调用已存储的在线调试指令,执行调试任务,输出在线调试信息;Call the stored online debugging instructions, execute debugging tasks, and output online debugging information;
恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序。Restore the current operating environment of the software, and continue to execute the subsequent program of the software from the tracked point.
可选地,所述确定软件中的被追踪点具体包括:Optionally, the determination of the tracked point in the software specifically includes:
通过命令行接收用户输入的设置指令,所述设置指令包括所述软件中被追踪点的地址;receiving a setting instruction input by a user through a command line, the setting instruction including the address of the tracked point in the software;
将所述被追踪点地址处的二进制机器指令反汇编为汇编程序;Disassembling the binary machine instruction at the address of the tracked point into an assembly program;
根据所述汇编程序确定所述被追踪点的位置。The location of the tracked point is determined according to the assembly program.
可选地,所述当执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境具体包括:Optionally, when the tracked point is executed, saving the current running environment of the software at the tracked point specifically includes:
当执行到所述被追踪点时,根据在被追踪点生成的跳转指令,跳转至已存储在所述软件中的保护/恢复环境指令;When executing to the tracked point, jump to the protection/restoration environment instruction stored in the software according to the jump instruction generated at the tracked point;
执行所述保护/恢复环境指令中的保护环境指令,保存所述被追踪点处的软件当前运行环境。Execute the protection environment instruction in the protection/restoration environment instruction, and save the current running environment of the software at the tracked point.
可选地,所述调用已存储的在线调试指令,执行调试任务,输出在线调试信息具体包括:Optionally, the calling the stored online debugging instruction, executing the debugging task, and outputting the online debugging information specifically includes:
执行所述保护/恢复环境指令;Execute said protection/restoration environment directives;
当执行到所述保护/恢复环境指令中的跳转点时,通过所述跳转点,跳转至所述在线调试指令;When executing to the jump point in the protection/restoration environment instruction, jump to the online debugging instruction through the jump point;
执行所述在线调试指令,输出在线调试信息。Execute the online debugging instruction, and output online debugging information.
可选地,所述恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序具体包括:Optionally, the restoring the current operating environment of the software, and continuing to execute the subsequent program of the software from the tracked point specifically includes:
当输出在线调试信息后,从所述在线调试指令跳转回所述跳转点;After the online debugging information is output, jump back to the jump point from the online debugging instruction;
执行所述保护/恢复环境指令中的恢复环境指令,并跳转回所述被追踪点,从所述被追踪点处继续执行所述软件后续程序。Execute the recovery environment command in the protection/restoration environment command, jump back to the tracked point, and continue to execute the software follow-up program from the tracked point.
可选地,所述方法还包括:Optionally, the method also includes:
在执行调试任务的过程中,通过命令行,接收用户输入的被追踪点状态查看指令;In the process of executing the debugging task, through the command line, receive the status viewing instruction of the tracked point input by the user;
根据所述查看指令,向所述用户反馈所述软件中被追踪点的状态信息,所述被追踪点的状态信息包括以下一种或多种:According to the viewing instruction, the status information of the tracked point in the software is fed back to the user, and the status information of the tracked point includes one or more of the following:
被追踪点的执行时间、当前CPU各寄存器的状态、当前任务堆栈信息。The execution time of the tracked point, the status of each register of the current CPU, and the stack information of the current task.
可选地,所述确定软件中的被追踪点之后还包括:Optionally, after determining the tracked point in the software, it also includes:
通过命令行,接收用户输入的被追踪点删除指令,所述被追踪点删除指令包括待删除的所述被追踪点的位置;receiving a tracked point deletion instruction input by a user through a command line, the tracked point deletion instruction including the location of the tracked point to be deleted;
将待删除的所述被追踪点的位置还原为设置所述被追踪点之前的二进制机器指令;restoring the position of the tracked point to be deleted to the binary machine instruction before setting the tracked point;
当执行到原所述被追踪点的位置时,执行所述二进制机器指令。When executing to the original position of the tracked point, execute the binary machine instruction.
为解决上述技术问题,本发明还提供了一种软件在线调试系统,所述系统包括:In order to solve the above technical problems, the present invention also provides a software online debugging system, said system comprising:
被追踪点确定模块,用于确定软件中的被追踪点;The tracked point determination module is used to determine the tracked point in the software;
程序执行模块,用于在执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境;以及在调试结束后,恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序;The program execution module is used to save the current running environment of the software at the tracked point when it is executed to the tracked point; continue to execute said software follow-up procedures;
调试模块,用于在保存软件当前运行环境后,调用已存储的在线调试指令,执行调试任务,输出在线调试信息。The debugging module is used for invoking the stored online debugging instructions after saving the current running environment of the software, executing debugging tasks, and outputting online debugging information.
可选地,所述被追踪点确定模块,用于确定软件中的被追踪点,具体包括:Optionally, the tracked point determination module is configured to determine the tracked point in the software, specifically including:
通过命令行接收用户输入的设置指令,所述设置指令包括所述软件中被追踪点的地址;receiving a setting instruction input by a user through a command line, the setting instruction including the address of the tracked point in the software;
将所述被追踪点地址的二进制机器指令反汇编为汇编程序;disassembling the binary machine instruction of the tracked point address into an assembly program;
根据所述汇编程序确定所述被追踪点的位置。The location of the tracked point is determined according to the assembly program.
可选地,所述程序执行模块,用于在执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境,具体包括:Optionally, the program execution module is configured to save the current running environment of the software at the tracked point when executing to the tracked point, specifically including:
当执行到所述被追踪点时,根据在被追踪点生成的跳转指令,跳转至已存储在所述软件中的保护/恢复环境指令;When executing to the tracked point, jump to the protection/restoration environment instruction stored in the software according to the jump instruction generated at the tracked point;
执行所述保护/恢复环境指令中的保护环境指令,保存所述被追踪点处的软件当前运行环境。Execute the protection environment instruction in the protection/restoration environment instruction, and save the current running environment of the software at the tracked point.
可选地,所述调试模块,用于调用已存储的在线调试指令,执行调试任务,输出在线调试信息,具体包括:Optionally, the debugging module is configured to call stored online debugging instructions, execute debugging tasks, and output online debugging information, specifically including:
执行所述保护/恢复环境指令;Execute said protection/restoration environment directives;
当执行到所述保护/恢复环境指令中的跳转点时,通过所述跳转点,跳转至所述在线调试指令;When executing to the jump point in the protection/restoration environment instruction, jump to the online debugging instruction through the jump point;
执行所述在线调试指令,输出在线调试信息。Execute the online debugging instruction, and output online debugging information.
可选地,所述程序执行模块,用于恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序,具体包括:Optionally, the program execution module is configured to restore the current operating environment of the software, and continue to execute the subsequent program of the software from the tracked point, specifically including:
当输出在线调试信息后,从所述在线调试指令跳转回所述跳转点;After the online debugging information is output, jump back to the jump point from the online debugging instruction;
执行所述保护/恢复环境指令中的恢复环境指令,并跳转回所述被追踪点,从所述被追踪点处继续执行所述软件后续程序。Execute the recovery environment command in the protection/restoration environment command, jump back to the tracked point, and continue to execute the software follow-up program from the tracked point.
可选地,所述系统还包括:Optionally, the system also includes:
状态查看模块,用于在调试任务执行过程中,通过命令行,接收用户输入的被追踪点状态查看指令;The state viewing module is used to receive the state viewing instruction of the tracked point input by the user through the command line during the execution of the debugging task;
根据所述查看指令,向所述用户反馈所述软件中被追踪点的状态信息,所述被追踪点的状态信息包括以下一种或多种:According to the viewing instruction, the status information of the tracked point in the software is fed back to the user, and the status information of the tracked point includes one or more of the following:
被追踪点的执行时间、当前CPU各寄存器的状态、当前任务堆栈信息。The execution time of the tracked point, the status of each register of the current CPU, and the stack information of the current task.
可选地,所述系统还包括:Optionally, the system also includes:
被追踪点删除模块,用于通过命令行,接收用户输入的被追踪点删除指令,所述被追踪点删除指令包括待删除的所述被追踪点的位置;The tracked point deletion module is configured to receive a tracked point deletion instruction input by a user through a command line, and the tracked point deletion instruction includes the location of the tracked point to be deleted;
将待删除的所述被追踪点的位置还原为设置所述被追踪点之前的二进制机器指令;restoring the position of the tracked point to be deleted to the binary machine instruction before setting the tracked point;
当执行到原所述被追踪点的位置时,执行所述二进制机器指令。When executing to the original position of the tracked point, execute the binary machine instruction.
通过应用本发明提供的一种软件在线调试方法和系统,在软件程序运行时,动态设置被追踪点,通过设置的被追踪点,保存被追踪点处的软件当前运行环境;调用已存储的在线调试指令,执行调试任务,输出在线调试信息;并恢复软件当前运行环境,从被追踪点处继续执行软件后续程序。以程序调用的形式调用调试指令,方便了调试指令的修改与删除,避免了将调试指令直接以硬编码的形式写入软件程序,实现在调试过程中任意更改调试指令;同时,也不需要重启软件程序;另外,上述技术方案在调用调试指令,执行调试程序之前保存软件当前运行环境,并在调试结束,先恢复保存的软件当前运行环境,再返回从被追踪点,从被追踪点处继续执行软件后续程序,使得软件后续程序能够继续在原先的运行环境下执行,避免了对原软件程序的影响。By applying a software online debugging method and system provided by the present invention, when the software program is running, the tracked point is dynamically set, and the current running environment of the software at the tracked point is saved through the set tracked point; the stored online Debugging instructions, execute debugging tasks, output online debugging information; and restore the current operating environment of the software, and continue to execute the subsequent software programs from the tracked point. Calling debugging instructions in the form of program calls facilitates the modification and deletion of debugging instructions, avoids writing debugging instructions directly into software programs in the form of hard codes, and realizes arbitrarily changing debugging instructions during debugging; at the same time, there is no need to restart Software program; In addition, the above technical solution saves the current operating environment of the software before calling the debugging instruction and executing the debugging program, and after the debugging is completed, first restores the saved current operating environment of the software, and then returns to the tracked point and continues from the tracked point Executing the software follow-up program enables the software follow-up program to continue to be executed in the original operating environment, avoiding the impact on the original software program.
附图说明Description of drawings
图1为本发明实施例提供的软件在线调试方法流程图;Fig. 1 is the flowchart of the software online debugging method provided by the embodiment of the present invention;
图2为本发明实施例提供的软件调试流程与现有的运行日志和调试命令中的软件调试流程对比图;Fig. 2 is a comparison diagram of the software debugging process provided by the embodiment of the present invention and the software debugging process in the existing operation log and debugging command;
图3为本发明实施例提供的软件在线调试系统组成模块图。FIG. 3 is a block diagram of the software online debugging system provided by the embodiment of the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚明白,下文中将结合附图对本发明的实施例进行详细说明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。In order to make the purpose, technical solution and advantages of the present invention more clear, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined arbitrarily with each other.
软件开发以及软件开发后的使用过程中,不可避免地会出现各种软件问题。当技术人员想在软件运行之前、甚至软件运行过程中且不终止现有软件运行进程的情况下,对软件进行调试,即可采用下述的实施例记载软件在线调试方法。In the process of software development and use after software development, various software problems will inevitably appear. When technicians want to debug the software before the software is running or even during the running of the software without terminating the running process of the existing software, the following embodiments can be used to record the software online debugging method.
下述实施例记载的软件在线调试方法以程序调用的形式调用在线调试指令,不需要重启软件程序;在执行在线调试程序之前保存软件在被追踪点的当前运行环境,使得调试结束后返回被追踪点时,程序能够在原先的运行环境下继续执行。The software online debugging method described in the following embodiments calls online debugging instructions in the form of program calls without restarting the software program; saves the current running environment of the software at the tracked point before executing the online debugging program, so that it returns to the tracked site after debugging. At this point, the program can continue to execute in the original operating environment.
下面以图1为例详细说明本发明实施例提供的软件在线调试方法,图1为本发明实施例提供的软件在线调试方法流程图。在本发明实施例中实施主体可为通信设备、终端、服务器等设备,所述终端具体为个人电脑(Personal Computer,简称:PC)、台式电脑等等。如图1所示,该实施例具体包括以下步骤:The software online debugging method provided by the embodiment of the present invention is described in detail below by taking FIG. 1 as an example. FIG. 1 is a flow chart of the software online debugging method provided by the embodiment of the present invention. In the embodiment of the present invention, the subject of implementation may be equipment such as communication equipment, a terminal, and a server, and the terminal is specifically a personal computer (Personal Computer, PC for short), a desktop computer, and the like. As shown in Figure 1, this embodiment specifically includes the following steps:
步骤S101、确定软件中的被追踪点;Step S101, determining the tracked point in the software;
具体地,步骤S101包括:通过命令行接收用户输入的设置指令,所述设置指令包括所述软件中被追踪点的地址;将所述被追踪点地址的二进制机器指令反汇编为汇编程序;根据所述汇编程序确定所述被追踪点的位置。Specifically, step S101 includes: receiving a setting instruction input by the user through a command line, the setting instruction including the address of the tracked point in the software; disassembling the binary machine instruction of the address of the tracked point into an assembler; The assembler determines the location of the tracked point.
例如,在vxworks操作系统中,调试人员可以通过命令行启用shell指令,通过“lkup”命令获取C代码函数名对应的地址;通过向“l”命令提供函数的地址来反汇编该函数的二进制机器指令。调试人员可根据需要,通过命令行将函数中任意点作为被追踪点。For example, in the vxworks operating system, debuggers can enable shell instructions through the command line, and obtain the address corresponding to the C code function name through the "lkup" command; disassemble the binary machine of the function by providing the address of the function to the "l" command instruction. The debugger can set any point in the function as the traced point through the command line as needed.
进一步地,还可将函数入口点设置为被追踪点,此时,通过命令行,可直接将函数名作为被追踪点的地址。Furthermore, the function entry point can also be set as the tracked point. At this time, the function name can be directly used as the address of the tracked point through the command line.
通过步骤S101可任意确定软件程序中的被追踪点。Through step S101, the tracked point in the software program can be arbitrarily determined.
步骤S102、当执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境;Step S102, when executing to the tracked point, save the current running environment of the software at the tracked point;
所述软件当前运行环境包括:CPU寄存器的内容;The current operating environment of the software includes: the contents of the CPU register;
可以理解的是,通过保存CPU寄存器的内容,可在执行完在线调试指令后,使得原有软件程序的执行得以不受影响而继续执行。It can be understood that by saving the contents of the CPU registers, the execution of the original software program can be continued without being affected after the in-circuit debugging instruction is executed.
具体地,步骤S102包括:Specifically, step S102 includes:
当执行到所述被追踪点时,根据在被追踪点生成的跳转指令,跳转至已存储在所述软件中的保护/恢复环境指令;执行所述保护/恢复环境指令中的保护环境指令,保存所述被追踪点处的软件当前运行环境。When executing to the tracked point, jump to the protection/restoration environment instruction stored in the software according to the jump instruction generated at the tracked point; execute the protection environment in the protection/restoration environment instruction An instruction for saving the current running environment of the software at the tracked point.
步骤S103、调用已存储的在线调试指令,执行调试任务,输出在线调试信息;Step S103, call the stored online debugging instruction, execute the debugging task, and output the online debugging information;
具体地,步骤S103包括:Specifically, step S103 includes:
执行所述保护/恢复环境指令;当执行到所述保护/恢复环境指令中的跳转点时,通过所述跳转点,跳转至所述在线调试指令;Execute the protection/restoration environment instruction; when the jump point in the protection/restoration environment instruction is executed, jump to the online debugging instruction through the jump point;
执行所述在线调试指令,输出在线调试信息。Execute the online debugging instruction, and output online debugging information.
进一步地,在本步骤中,输出的在线调试信息包括:被追踪点的执行时间、当前CPU各寄存器的状态、当前任务堆栈信息。上述信息包括了执行在线调试指令中关于当前调试任务在被追踪点处执行的所有信息,依据上述信息,以使得调试人员判断在被追踪点的执行是否存在异常,以及当出现异常时,对异常进行定位。Further, in this step, the output online debugging information includes: the execution time of the tracked point, the state of each register of the current CPU, and the stack information of the current task. The above information includes all information about the execution of the current debugging task at the tracked point in the execution of the online debugging command. According to the above information, the debugger can judge whether there is an exception in the execution of the tracked point, and when an exception occurs, correct the exception. to locate.
需要说明的是,在本发明实施例中,所述在线调试信息可包括多层级在线调试,例如,包括第一层级在线调试信息、第二层级在线调试信息等等。It should be noted that, in the embodiment of the present invention, the in-circuit debugging information may include multi-level in-circuit debugging, for example, including first-level in-circuit debugging information, second-level in-circuit debugging information, and so on.
可以理解的是,在本发明实施例中,在执行第一层级在线调试信息时,可通过第一层级在线调试信息中的跳转点,跳转至第二层级在线调试信息中继续进行调制,进而实现多层级在线调试。It can be understood that, in the embodiment of the present invention, when the first-level in-circuit debugging information is executed, the jump point in the first-level in-circuit debugging information can be used to jump to the second-level in-circuit debugging information to continue modulation, And then realize multi-level online debugging.
步骤S104、恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序。Step S104, restoring the current operating environment of the software, and continuing to execute the subsequent program of the software from the tracked point.
具体地,步骤S104包括:Specifically, step S104 includes:
当输出在线调试信息后,从所述在线调试指令跳转回所述跳转点;执行所述保护/恢复环境指令中的恢复环境指令,并跳转回所述被追踪点,从所述被追踪点处继续执行所述软件后续程序。After the online debugging information is output, jump back from the online debugging instruction to the jump point; execute the recovery environment instruction in the protection/restoration environment instruction, and jump back to the tracked point, from the The follow-up program of the software continues to be executed at the tracking point.
进一步地,当涉及多层级在线调试时,当前层级在线调试结束后,跳转回至前一层级的跳转点处,执行前一层级跳转点之后的程序,依次跳转回至原软件程序中。Further, when multi-level online debugging is involved, after the current level of online debugging is completed, jump back to the jump point of the previous level, execute the program after the jump point of the previous level, and then jump back to the original software program in turn middle.
需要说明的是,在本发明实施例中,还可根据设置的被追踪点的个数,存储相等数量的保护/恢复环境指令,以使得执行到每个被追踪点处时,方便、灵活地进行跳转。It should be noted that, in the embodiment of the present invention, an equal number of protection/restoration environment instructions can also be stored according to the set number of tracked points, so that when executing to each tracked point, it is convenient and flexible Make the jump.
进一步地,在本发明实施例中,还自动存储被追踪点的位置和被追踪点处二进制机器指令,以便在被追点处进行跳转或者回调。例如,通过直接写内存方式,将被追踪点地址处的内存修改为“保护/恢复环境指令”程序段的起始地址处,进而实现跳转;并将被追踪点处二进制机器指令添加到“保护/恢复环境指令”程序段的末尾处,进而实现回调。Further, in the embodiment of the present invention, the position of the tracked point and the binary machine instruction at the tracked point are also automatically stored, so as to perform jump or callback at the tracked point. For example, by directly writing the memory, the memory at the address of the tracked point is modified to the starting address of the "protection/restoration environment instruction" program segment, and then the jump is realized; and the binary machine instruction at the tracked point is added to the " Protect/Restore Environment Instructions" program segment, and then implement the callback.
通过应用本发明实施例的上述步骤S101-步骤S104,在软件程序运行时,动态设置被追踪点,通过设置的被追踪点,保存被追踪点处的软件当前运行环境;调用已存储的在线调试指令,执行调试任务,输出在线调试信息;并恢复软件当前运行环境,从被追踪点处继续执行软件后续程序。避免了将调试指令直接以硬编码的形式写入软件程序中,而是以程序调用的形式调用调试指令,方便了调试指令的修改与删除,实现在调试过程中任意更改调试指令;同时,也不需要重启软件程序。By applying the above steps S101 to S104 of the embodiment of the present invention, when the software program is running, the tracked point is dynamically set, and the current running environment of the software at the tracked point is saved through the set tracked point; the stored online debugging is called Instructions, execute debugging tasks, output online debugging information; and restore the current operating environment of the software, and continue to execute the subsequent software programs from the tracked point. It avoids writing the debugging instructions directly into the software program in the form of hard coding, but calls the debugging instructions in the form of program calls, which facilitates the modification and deletion of debugging instructions, and realizes arbitrarily changing debugging instructions during the debugging process; at the same time, it also There is no need to restart the software program.
可选地,在上述实施例通过步骤S101确定了软件中的被追踪点之后,还包括接收用户输入的被追踪点删除指令,根据该指令删除被追踪点的步骤,通过该步骤可使调试过程更加方便、灵活。具体步骤如下:Optionally, after the above-mentioned embodiment determines the tracked point in the software through step S101, it also includes the step of receiving a tracked point deletion instruction input by the user, and deleting the tracked point according to the instruction. Through this step, the debugging process can More convenient and flexible. Specific steps are as follows:
通过命令行,接收用户输入的被追踪点删除指令,所述被追踪点删除指令包括待删除的所述被追踪点的位置;receiving a tracked point deletion instruction input by a user through a command line, the tracked point deletion instruction including the location of the tracked point to be deleted;
将待删除的所述被追踪点的位置还原为设置所述被追踪点之前的二进制机器指令;restoring the position of the tracked point to be deleted to the binary machine instruction before setting the tracked point;
当执行到原所述被追踪点的位置时,执行所述二进制机器指令,这样程序就表现为设置被追踪点之前的行为。When executing to the original position of the tracked point, the binary machine instruction is executed, so that the program behaves as before the tracked point is set.
具体地,通过命令行,接收用户输入的被追踪点删除指令,将被追踪点的位置还原为设置被追踪点之前的二进制机器指令;进而当软件执行到原被追踪点所在的位置时,由于此位置已没有被追踪点,则执行设置被追踪点之前的二进制机器指令,使程序恢复为设置被追踪点之前状态。由此可见,本发明实施例相对于现有技术,不仅可以在线设置被追踪点,还可在线删除被追踪点,使调试过程更加灵活。Specifically, through the command line, the tracked point deletion command input by the user is received, and the position of the tracked point is restored to the binary machine instruction before setting the tracked point; and when the software is executed to the original position of the tracked point, because There is no tracked point at this position, then execute the binary machine instruction before setting the tracked point to restore the program to the state before setting the tracked point. It can be seen that, compared with the prior art, the embodiment of the present invention can not only set the tracked point online, but also delete the tracked point online, so that the debugging process is more flexible.
可选地,上述方法中,在上述步骤S103执行调试任务过程中,还包括接收用户输入的被追踪点状态查看指令,根据该指令向用户反馈被追踪点的状态信息的步骤,通过该步骤可方便调试人员判断在被追踪点的执行动作是否异常,并在出现异常时分析原因。具体步骤如下:Optionally, in the above method, in the process of executing the debugging task in the above step S103, it also includes the step of receiving the status check instruction of the tracked point input by the user, and feeding back the status information of the tracked point to the user according to the instruction. Through this step, It is convenient for debuggers to judge whether the execution action at the tracked point is abnormal, and to analyze the cause when an exception occurs. Specific steps are as follows:
在执行调试任务的过程中,通过命令行,接收用户输入的被追踪点状态查看指令;In the process of executing the debugging task, through the command line, receive the status viewing instruction of the tracked point input by the user;
根据所述查看指令,向所述用户反馈所述软件中被追踪点的状态信息,所述被追踪点的状态信息包括以下一种或多种:According to the viewing instruction, the status information of the tracked point in the software is fed back to the user, and the status information of the tracked point includes one or more of the following:
被追踪点的执行时间、当前CPU各寄存器的状态、当前任务堆栈信息。The execution time of the tracked point, the status of each register of the current CPU, and the stack information of the current task.
具体地,在执行调试任务的过程中,当接收到用户输入的被追踪点状态查看指令时,根据查看指令,向用户反馈软件中被追踪点的状态信息。Specifically, in the process of executing the debugging task, when receiving the status check command of the tracked point input by the user, the status information of the tracked point in the software is fed back to the user according to the check command.
进一步地,被追踪点的状态信息还包括:软件程序中全部设置的被追踪点的设置信息,例如,被追踪点的设置位置、执行次数等等。Further, the status information of the tracked point also includes: setting information of all the tracked points set in the software program, for example, the setting position of the tracked point, the number of times of execution, and the like.
上述被追踪点的状态信息可方便调试人员判断在被追踪点的执行动作是否异常,并在出现异常时分析原因,同时,调试人员还可根据被追踪点的状态信息对被追踪点进行重设置。The above status information of the tracked point can facilitate the debugger to judge whether the execution action at the tracked point is abnormal, and analyze the cause when an exception occurs. At the same time, the debugger can also reset the tracked point according to the status information of the tracked point .
可选地,上述方法中,在步骤S103输出在线调试信息后,还可将该在线调试信息保存进内存,方便调试人员查阅,避免了调试人员一直守候在现场。Optionally, in the above method, after the online debugging information is output in step S103, the online debugging information can also be saved in the memory, which is convenient for the debugging personnel to check, and avoids the debugging personnel waiting at the scene all the time.
通过应用本发明实施例的提供的软件在线调试方法,在软件程序运行时,动态设置被追踪点,通过设置的被追踪点,保存被追踪点处的软件当前运行环境;调用已存储的在线调试指令,执行调试任务,输出在线调试信息;并恢复软件当前运行环境,从被追踪点处继续执行软件后续程序。由于在本发明实施例中,通过设置的被追踪点调用已存储的在线调试指令,并在被追踪点处进行软件当前运行环境的保存/恢复,避免了将调试指令直接以硬编码的形式写入软件程序,而是以程序调用的形式调用调试指令,方便了调试指令的修改与删除,实现在调试过程中任意更改调试指令;同时,也不需要重启软件程序;另外,上述技术方案在调用调试指令,执行调试程序之前保存软件当前运行环境,使得调试结束后返回被追踪点时,程序能够继续在原先的运行环境下执行,避免了对原软件程序的影响。By applying the software online debugging method provided by the embodiment of the present invention, when the software program is running, the tracked point is dynamically set, and the current running environment of the software at the tracked point is saved through the set tracked point; the stored online debugging is called Instructions, execute debugging tasks, output online debugging information; and restore the current operating environment of the software, and continue to execute the subsequent software programs from the tracked point. Since in the embodiment of the present invention, the stored online debugging instructions are invoked through the set tracked point, and the current running environment of the software is saved/restored at the tracked point, it is avoided to directly write the debugging instruction in a hard-coded form. Instead of entering the software program, the debugging instruction is called in the form of program call, which facilitates the modification and deletion of the debugging instruction, and realizes any modification of the debugging instruction during the debugging process; at the same time, there is no need to restart the software program; in addition, the above technical solution is called Debugging instructions, save the current running environment of the software before executing the debugging program, so that when the debugging ends and returns to the tracked point, the program can continue to execute in the original running environment, avoiding the impact on the original software program.
图2为本发明实施例中的软件调试流程与现有的运行日志和调试命令中的软件调试流程对比图,其中,实线表示现有的运行日志和调试命令中的被调试函数指令的软件调试流程,虚线表示本发明实施例中的软件在线调试流程。Figure 2 is a comparison diagram between the software debugging process in the embodiment of the present invention and the software debugging process in the existing running log and debugging command, wherein the solid line represents the software of the debugged function instruction in the existing running log and debugging command The debugging process, the dotted line represents the online debugging process of the software in the embodiment of the present invention.
在被调试函数指令的软件调试流程中,当软件在内存中运行之前,确定被追踪点,在线调试指令被直接以硬编码的形式写入软件程序的被追踪点,当软件程序执行到被追踪点后,在被追踪点执行在线调试指令;待完成在线调试任务后,继续执行软件的后续程序。如果软件已经运行,则通过编码、编译、链接步骤将在线调试指令写入软件中的被追踪点,再通过软件重启程序将经过修改的软件加载到内存中运行。In the software debugging process of the debugged function instruction, before the software runs in the memory, the tracked point is determined, and the online debugging instruction is directly written into the tracked point of the software program in the form of hard code. When the software program executes to the tracked point After the point, execute the online debugging instruction at the tracked point; after the online debugging task is completed, continue to execute the follow-up program of the software. If the software is already running, the online debugging instructions are written into the tracked point in the software through the steps of encoding, compiling and linking, and then the modified software is loaded into the memory to run through the software restart program.
本发明实施例中的软件在线调试流程,根据被追踪点地址反汇编的二进制机器指令确定了软件中的被追踪点,这一步直接在内存中完成;当执行到被追踪点时,跳转至已存储在软件中的保护/恢复环境指令,执行保护/恢复环境指令中的保护环境指令,保存被追踪点处的软件当前运行环境;继续执行保护/恢复环境指令;当执行到保护/恢复环境指令中的跳转点时,通过跳转点,跳转至在线调试指令;执行在线调试指令,输出在线调试信息。整个过程通过程序调用完成调试,不需要通过编码、编译、链接步骤将调试指令写入软件中的被追踪点,由于软件一直在内存中运行,因此也不需要再通过软件重启程序将经过修改的软件加载到内存中运行。In the software online debugging process in the embodiment of the present invention, the tracked point in the software is determined according to the binary machine instruction disassembled by the address of the tracked point, and this step is directly completed in the memory; when the tracked point is executed, jump to The protection/restoration environment instruction stored in the software executes the protection/restoration environment instruction in the protection/restoration environment instruction, saves the current operating environment of the software at the tracked point; continues to execute the protection/restoration environment instruction; when the execution reaches the protection/restoration environment When there is a jump point in the command, jump to the online debugging command through the jump point; execute the online debugging command and output the online debugging information. The whole process is debugged by calling the program. It is not necessary to write the debugging instructions into the tracked point in the software through the steps of coding, compiling and linking. Since the software is always running in the memory, there is no need to restart the program to save the modified The software is loaded into memory to run.
本发明实施例提供的软件调试流程,当输出在线调试信息后,从在线调试指令跳转回跳转点;执行保护/恢复环境指令中的恢复环境指令,并跳转回被追踪点,从被追踪点处继续执行软件后续程序。由于程序能够继续在原先的运行环境下执行,避免了调试对原软件程序的影响。In the software debugging process provided by the embodiment of the present invention, after the online debugging information is output, jump back from the online debugging instruction to the jump point; execute the recovery environment instruction in the protection/restoration environment instruction, and jump back to the tracked point, from the Continue to execute the software follow-up program at the tracking point. Since the program can continue to be executed in the original operating environment, the influence of debugging on the original software program is avoided.
下面以图3为例详细说明本发明实施例提供的软件在线调试系统,图3为本发明实施例提供的软件在线调试系统组成模块图。在本发明实施例中所述软件在线调试系统可应用或加载在通信设备、终端、服务器等设备,所述终端具体为个人电脑(PersonalComputer,简称:PC)、台式电脑等等。如图3所示The software online debugging system provided by the embodiment of the present invention is described in detail below by taking FIG. 3 as an example. FIG. 3 is a block diagram of the software online debugging system provided by the embodiment of the present invention. In the embodiment of the present invention, the software online debugging system can be applied or loaded on communication devices, terminals, servers and other devices, and the terminals are specifically personal computers (Personal Computer, PC for short), desktop computers and the like. As shown in Figure 3
所述系统包括:The system includes:
被追踪点确定模块310,用于确定软件中的被追踪点;The tracked point determination module 310 is used to determine the tracked point in the software;
程序执行模块320,用于在执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境;以及在调试结束后,恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序;The program execution module 320 is configured to save the current running environment of the software at the tracked point when executing to the tracked point; Continue to execute the software follow-up program;
调试模块330,用于在保存软件当前运行环境后,调用已存储的在线调试指令,执行调试任务,输出在线调试信息。The debugging module 330 is configured to call the stored online debugging instructions after saving the current running environment of the software, execute debugging tasks, and output online debugging information.
所述被追踪点确定模块310,用于确定软件中的被追踪点,具体包括:The tracked point determination module 310 is used to determine the tracked point in the software, specifically including:
通过命令行接收用户输入的设置指令,所述设置指令包括所述软件中被追踪点的地址;receiving a setting instruction input by a user through a command line, the setting instruction including the address of the tracked point in the software;
将所述被追踪点地址的二进制机器指令反汇编为汇编程序;disassembling the binary machine instruction of the tracked point address into an assembly program;
根据所述汇编程序确定所述被追踪点的位置。The location of the tracked point is determined according to the assembly program.
所述程序执行模块320,用于在执行到所述被追踪点时,保存所述被追踪点处的软件当前运行环境,具体包括:The program execution module 320 is configured to save the current running environment of the software at the tracked point when executing to the tracked point, specifically including:
当执行到所述被追踪点时,根据在被追踪点生成的跳转指令,跳转至已存储在所述软件中的保护/恢复环境指令;When executing to the tracked point, jump to the protection/restoration environment instruction stored in the software according to the jump instruction generated at the tracked point;
执行所述保护/恢复环境指令中的保护环境指令,保存所述被追踪点处的软件当前运行环境。Execute the protection environment instruction in the protection/restoration environment instruction, and save the current running environment of the software at the tracked point.
所述调试模块330,用于调用已存储的在线调试指令,执行调试任务,输出在线调试信息,具体包括:The debugging module 330 is used for invoking stored online debugging instructions, executing debugging tasks, and outputting online debugging information, specifically including:
执行所述保护/恢复环境指令;Execute said protection/restoration environment directives;
当执行到所述保护/恢复环境指令中的跳转点时,通过所述跳转点,跳转至所述在线调试指令;When executing to the jump point in the protection/restoration environment instruction, jump to the online debugging instruction through the jump point;
执行所述在线调试指令,输出在线调试信息。Execute the online debugging instruction, and output online debugging information.
所述程序执行模块320,用于恢复所述软件当前运行环境,从所述被追踪点处继续执行所述软件后续程序,具体包括:The program execution module 320 is configured to restore the current operating environment of the software, and continue to execute the subsequent program of the software from the tracked point, specifically including:
当输出在线调试信息后,从所述在线调试指令跳转回所述跳转点;After the online debugging information is output, jump back to the jump point from the online debugging instruction;
执行所述保护/恢复环境指令中的恢复环境指令,并跳转回所述被追踪点,从所述被追踪点处继续执行所述软件后续程序。Execute the recovery environment command in the protection/restoration environment command, jump back to the tracked point, and continue to execute the software follow-up program from the tracked point.
所述系统还包括:状态查看模块340,用于在调试任务执行过程中,通过命令行,接收用户输入的被追踪点状态查看指令;The system also includes: a state viewing module 340, configured to receive the state viewing instruction of the tracked point input by the user through the command line during the execution of the debugging task;
根据所述查看指令,向所述用户反馈所述软件中被追踪点的状态信息,所述被追踪点的状态信息包括以下一种或多种:According to the viewing instruction, the status information of the tracked point in the software is fed back to the user, and the status information of the tracked point includes one or more of the following:
被追踪点的执行时间、当前CPU各寄存器的状态、当前任务堆栈信息。The execution time of the tracked point, the status of each register of the current CPU, and the stack information of the current task.
所述系统还包括:被追踪点删除模块350,用于当软件中的被追踪点确定后,通过命令行,接收用户输入的被追踪点删除指令,所述被追踪点删除指令包括待删除的所述被追踪点的位置;The system also includes: a tracked point deletion module 350, configured to receive a tracked point deletion command input by the user through a command line after the tracked point is determined in the software, and the tracked point deletion command includes the the location of said tracked point;
将待删除的所述被追踪点的位置还原为设置所述被追踪点之前的二进制机器指令;restoring the position of the tracked point to be deleted to the binary machine instruction before setting the tracked point;
当执行到原所述被追踪点的位置时,执行所述二进制机器指令。When executing to the original position of the tracked point, execute the binary machine instruction.
通过应用本发明实施例的提供的软件在线调试系统,在软件程序运行时,动态设置被追踪点,通过设置的被追踪点,保存被追踪点处的软件当前运行环境;调用已存储的在线调试指令,执行调试任务,输出在线调试信息;并恢复软件当前运行环境,从被追踪点处继续执行软件后续程序。由于在本发明实施例中,通过设置的被追踪点调用已存储的在线调试指令,并在被追踪点处进行软件当前运行环境的保存/恢复,避免了将调试指令直接以硬编码的形式写入软件程序,而是以程序调用的形式调用调试指令,方便了调试指令的修改与删除,实现在调试过程中任意更改调试指令;同时,也不需要重启软件程序;另外,上述技术方案在调用调试指令,执行调试程序之前保存软件当前运行环境,使得调试结束后返回被追踪点时,程序能够继续在原先的运行环境下执行,避免了对原软件程序的影响。By applying the software online debugging system provided by the embodiment of the present invention, when the software program is running, the tracked point is dynamically set, and the current running environment of the software at the tracked point is saved through the set tracked point; the stored online debugging is called Instructions, execute debugging tasks, output online debugging information; and restore the current operating environment of the software, and continue to execute the subsequent software programs from the tracked point. Since in the embodiment of the present invention, the stored online debugging instructions are invoked through the set tracked point, and the current running environment of the software is saved/restored at the tracked point, it is avoided to directly write the debugging instruction in a hard-coded form. Instead of entering the software program, the debugging instruction is called in the form of program call, which facilitates the modification and deletion of the debugging instruction, and realizes any modification of the debugging instruction during the debugging process; at the same time, there is no need to restart the software program; in addition, the above technical solution is called Debugging instructions, save the current running environment of the software before executing the debugging program, so that when the debugging ends and returns to the tracked point, the program can continue to execute in the original running environment, avoiding the impact on the original software program.
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序来指令相关硬件完成,所述程序可以存储于计算机可读存储介质中,如只读存储器、磁盘或光盘等。可选地,上述实施例的全部或部分步骤也可以使用一个或多个集成电路来实现,相应地,上述实施例中的各模块/单元可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。本发明不限制于任何特定形式的硬件和软件的结合。Those of ordinary skill in the art can understand that all or part of the steps in the above method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk or an optical disk, and the like. Optionally, all or part of the steps in the above embodiments can also be implemented using one or more integrated circuits. Correspondingly, each module/unit in the above embodiments can be implemented in the form of hardware, or can be implemented in the form of software function modules. The form is realized. The present invention is not limited to any specific combination of hardware and software.
需要说明的是,本发明还可有其他多种实施例,在不背离本发明精神及其实质的情况下,熟悉本领域的技术人员可根据本发明作出各种相应的改变和变形,但这些相应的改变和变形都应属于本发明所附的权利要求的保护范围。It should be noted that the present invention can also have other various embodiments, without departing from the spirit and essence of the present invention, those skilled in the art can make various corresponding changes and deformations according to the present invention, but these Corresponding changes and deformations should belong to the scope of protection of the appended claims of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510003876.6ACN104536892B (en) | 2015-01-05 | 2015-01-05 | A kind of software on-line debugging method and system |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201510003876.6ACN104536892B (en) | 2015-01-05 | 2015-01-05 | A kind of software on-line debugging method and system |
| Publication Number | Publication Date |
|---|---|
| CN104536892A CN104536892A (en) | 2015-04-22 |
| CN104536892Btrue CN104536892B (en) | 2018-03-27 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201510003876.6AExpired - Fee RelatedCN104536892B (en) | 2015-01-05 | 2015-01-05 | A kind of software on-line debugging method and system |
| Country | Link |
|---|---|
| CN (1) | CN104536892B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105204990B (en)* | 2015-08-21 | 2017-11-28 | 上海斐讯数据通信技术有限公司 | A kind of abnormal adjustment method and system |
| CN105824751A (en)* | 2016-03-16 | 2016-08-03 | 上海斐讯数据通信技术有限公司 | System and method for automatically debugging software of network device |
| CN112433945A (en)* | 2020-11-26 | 2021-03-02 | 百富计算机技术(深圳)有限公司 | Method and device for dynamically tracking program and electronic equipment |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6915509B1 (en)* | 2000-06-28 | 2005-07-05 | Microsoft Corporation | Method and system for debugging a program |
| CN1752946A (en)* | 2005-10-31 | 2006-03-29 | 大唐微电子技术有限公司 | Debugging method of embedded system and its system |
| CN101295279A (en)* | 2007-04-29 | 2008-10-29 | 国际商业机器公司 | Method and system for debugging program in multi-threading surroundings |
| CN101482848A (en)* | 2009-02-03 | 2009-07-15 | 中兴通讯股份有限公司 | Dynamic debugging method and system in embedded software running state |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101446918B (en)* | 2008-12-10 | 2011-12-28 | 中兴通讯股份有限公司 | Method for realizing debugging of single function by user state debugger and system thereof |
| US8473921B2 (en)* | 2009-12-15 | 2013-06-25 | Microsoft Corporation | Debugging mechanisms in a cache-based memory isolation system |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6915509B1 (en)* | 2000-06-28 | 2005-07-05 | Microsoft Corporation | Method and system for debugging a program |
| CN1752946A (en)* | 2005-10-31 | 2006-03-29 | 大唐微电子技术有限公司 | Debugging method of embedded system and its system |
| CN101295279A (en)* | 2007-04-29 | 2008-10-29 | 国际商业机器公司 | Method and system for debugging program in multi-threading surroundings |
| CN101482848A (en)* | 2009-02-03 | 2009-07-15 | 中兴通讯股份有限公司 | Dynamic debugging method and system in embedded software running state |
| Publication number | Publication date |
|---|---|
| CN104536892A (en) | 2015-04-22 |
| Publication | Publication Date | Title |
|---|---|---|
| CN107077414B (en) | Diagnostic workflow for production commissioning | |
| US8756572B2 (en) | Debugger-set identifying breakpoints after coroutine yield points | |
| US8627296B1 (en) | Unified unit and integration test with automatic mock creation | |
| JP5415557B2 (en) | User script code conversion for debugging | |
| CN104756086A (en) | System and method for debugging domain specific languages | |
| US20190073292A1 (en) | State machine software tester | |
| US8667255B2 (en) | Measuring runtime coverage of architectural events of a microprocessor | |
| US8402446B2 (en) | Associating probes with test cases | |
| US20170075789A1 (en) | Method and apparatus for generating, capturing, storing, and loading debug information for failed tests scripts | |
| CN101246449B (en) | Tracking function invocation track method and device | |
| CN111611008A (en) | A software code packaging and deployment method, device, device and storage medium | |
| CN107729238A (en) | A kind of plug-in unit adjustment method, system, device and computer-readable recording medium | |
| US9824000B1 (en) | Testing calling code dynamically with random error injection based on user-specified configuration | |
| CN110727581A (en) | Crash localization method and electronic device | |
| CN110045952B (en) | Code calling method and device | |
| US9117020B2 (en) | Determining control flow divergence due to variable value difference | |
| CN104536870B (en) | A kind of process monitoring method and device | |
| CN104536892B (en) | A kind of software on-line debugging method and system | |
| US11249880B1 (en) | Debugging and simulating application runtime execution | |
| CN111858302B (en) | Method and device for testing small program, electronic equipment and storage medium | |
| CN113986263A (en) | Code automation testing method, device, electronic device, storage medium | |
| CN110502439B (en) | Debugging method, device, electronic equipment and storage medium | |
| CN113342702A (en) | Application program testing method, device, equipment and readable storage medium | |
| US20180032424A1 (en) | System, method, and apparatus for crowd-sourced gathering of application execution events for automatic application testing and replay | |
| CN117667672A (en) | Python code remote debugging method and system for industrial software |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| C10 | Entry into 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 | Granted publication date:20180327 | |
| CF01 | Termination of patent right due to non-payment of annual fee |