WO2015184908A1 - 一种反向调试方法、装置及调试器 - Google Patents

一种反向调试方法、装置及调试器 Download PDF

Info

Publication number
WO2015184908A1
WO2015184908A1 PCT/CN2015/074971 CN2015074971W WO2015184908A1 WO 2015184908 A1 WO2015184908 A1 WO 2015184908A1 CN 2015074971 W CN2015074971 W CN 2015074971W WO 2015184908 A1 WO2015184908 A1 WO 2015184908A1
Authority
WO
WIPO (PCT)
Prior art keywords
command
event
instruction
debugging
module
Prior art date
Application number
PCT/CN2015/074971
Other languages
English (en)
French (fr)
Inventor
蒋曦
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015184908A1 publication Critical patent/WO2015184908A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the invention relates to the field of debugging, in particular to a reverse debugging method, device and debugger.
  • Debugging is often a process of guessing that requires repeated analysis of suspected code, and it is generally unlikely that the breakpoint will be placed in the most appropriate position for the first time. For example, we often find that important code has been missed or some state of the program is not correct before running to the breakpoint. Usually we can only exit the debug and restart the new debug from the beginning, and the debugging efficiency is relatively low.
  • the standard gdb supports reverse debugging new features from version 7.0. This new feature allows users to debug the target code back and forth without restarting the debugger, just as we can use the repeater when learning English. Partial replay and analysis.
  • the debugger records the details of each instruction executed by the program, and restores the operation of each instruction according to the record when it needs to be retracted, thereby restoring the program to the current state. For example, if an instruction adds 1 to the value of register reg1, then undo will decrement it by 1.
  • the reverse debugging process is just like the normal debugging process we are familiar with, except that you need to use the corresponding reverse debugging control commands. It should be noted that the current reverse debugging only supports the recovery of the operation of the program on the memory and the register and the operation of the file or the terminal cannot be resumed.
  • Standard gdb implements this functionality in the context of a synchronous mode in which the debugger can receive and process any debug commands from the user only if the called program is in a stopped state.
  • the gdb debugger subsystem debugger section decomposes the modules according to their functions, and then refines the function for each functional unit within each module.
  • the module is divided into two parts: the debug control module gdb and the debug agent module gdbserver:
  • Debug control module gdb
  • the main function of gdb is set to receive the debugging command input by the user and send the debugging command to the debugging agent module, perform debugging control on the target end, and parse the debugging event returned by the debugging agent module.
  • Debug agent module gdbserver
  • gdbserver The main function of gdbserver is set to accept the debugging commands sent by gdb, and actively return debugging events to gdb; gdbserver is based on the synchronization model, and monitors the gdb debugging commands and status events of the tracked tasks.
  • Step A.gdb parses the debug command input by the user and then sends a corresponding command to gdbserver to let the program run, and then wait for the gdbserver debug event to report. Since gdb has been waiting for gdbserver to report events synchronously, gdb cannot receive user input during this process.
  • Step B gdbserver receives the debug command of gdb and then reports the corresponding debugging action or trigger event (received signal or break point, etc.) to report gdb.
  • Step C If the event is reported by gdbserver, gdb can receive the user input command again after receiving the event. If gdbserver reports not a stop event, gdb still cannot receive user input.
  • Step A Start recording, gdb will all the debugging control commands issued by the user, such as continuing to run the command, the source code single step, return, etc. are all converted into instruction step.
  • Step B The gdbserver control program reports the single-step completion event to gdb after completing one instruction step, and gdb disassembles the instruction to see what operations the instruction completes and records the operations into a log list.
  • Step C After the recording is completed, gdb starts to process the event flow to see if the current break point or whether the current pc has met the boundary condition of the current run. If it is, then stop the single step operation and then report the user, if not Then continue to take a single step. In synchronous mode, gdb does not need to fall back to the event processing loop to sense and get gdbserver to report debug events.
  • the structure of the instruction recording frame is shown in Figure 1.
  • the inst1 in the figure indicates the recording frame of the first instruction.
  • the instruction operates on both the memory and the register. Therefore, this instruction is used to record the instruction to the memory in the frame using mem entry (memory entry) and reg entry (register entry) respectively.
  • register write operations Details such as the address and value of the modified memory or the number and value of the modified register, etc., end entry indicates the end of this recorded frame.
  • inst2 represents the second instruction recording frame, it also has operations on the memory and registers; and inst3 represents the third instruction recording frame, this instruction only has operations on the register and therefore no mem enrty; and those on the memory or
  • the register has no write operation instructions, such as the branch delay slot instruction, and the recording frame has only the end entry; and so on, the debugger records all the instructions in the recording range according to this format and uses the recording frame of each instruction as the node.
  • the doubly linked list is saved and used during instruction playback.
  • the recording process in synchronous mode is shown in Figure 2.
  • the arrow from step 203 to step 211 indicates that gdb is in the state of sending the single-step command, and sends an instruction step to gdbserver, so that gdbserver enters the processing command transmission event step from the command waiting step to process the instruction step.
  • the arrow from step 212 to step 204 indicates that gdbserver is in the process of processing the command sending event step, and reports the event that completes the instruction step to gdb.
  • Step A The user inputs a reverse execution command (eg, reverse execution, return, single step).
  • gdb reads the previous instruction record information from the recorded log list and parses and then notifies the debug agent module to perform a reverse operation on the register or the memory.
  • Step B Each time a reverse operation gdb is executed, it is regarded as a debug event, and enters the event processing flow. If the current pc has satisfied the operation boundary condition gdb, the reverse operation operation is stopped and reported to the user.
  • Step A Debug Control Module Command
  • the debug agent module allows the program to run, and then waits for the debug agent module to report the program debug event report. In this process, the debug control module returns to the event/command wait flow, so the user command can still be received and processed.
  • Step B The debug agent module notifies the debug control module that an event has occurred after receiving the command to complete the corresponding debugging work.
  • Step C The debug control module learns that a debug event occurs and queries the debug agent module for an event, and then the debug agent module reports the event to the debug control module.
  • Step D The debug control module processes the event.
  • An object of the embodiments of the present invention is to provide a reverse debugging method, apparatus, and debugger, so that reverse debugging can also be implemented in the asynchronous debugging mode.
  • An embodiment of the present invention provides a reverse debugging method for a control module, including:
  • processing the first command includes:
  • the second determining result is that the first command is an instruction single step command, sending the first command to the debugging proxy module, informing the debugging proxy module to process the first command;
  • the second determination result is that the first command is not an instruction single step
  • converting the first command into an instruction single step command and sending the instruction single step command to the debugging proxy module, notifying the The debug agent module processes the instruction single step command.
  • the obtaining, by the debugging agent module, the completion event of the single-step instruction for the event or command occurrence notification includes:
  • the processing the completion event includes:
  • the program running state information is recorded into a logical storage space, and the logical storage space is used to record required program running state information of the debugging control module for performing instruction playback.
  • the program running status information includes: a memory operation record frame of the operation performed by the debug agent module on the memory according to the single step instruction, and the operation of the register by the debug agent module according to the single step instruction The register operation record frame and the end frame created when the debug agent module completes the memory operation record frame and the register operation record frame.
  • the logical storage space includes a linked list.
  • the embodiment of the invention further provides a reverse debugging device for a control module, comprising:
  • the receiving module is configured to receive an event or a command occurrence notification after sending a single step instruction to the debug proxy module, where the single step instruction is determined by the debug control module according to a debug control command input by the user;
  • a judging module configured to determine whether the event or the command occurrence notification is for an event or a command, and obtain a first judgment result
  • parsing and processing module is configured to: when the first determination result is the event or the command occurrence notification is directed to the command, parse the command, obtain the first command for the event or command occurrence notification; and process the first An order
  • an acquisition and processing module configured to acquire, when the first determination result is that the event or the command occurrence notification is for an event, obtain, from the debugging proxy module, a completion event of the single-step instruction for the event or the command occurrence notification And processing the completion event.
  • the parsing and processing module includes:
  • a parsing unit configured to parse the command when the first judgment result is the event or the command occurrence notification is for the command, and obtain the first command for the event or the command occurrence notification;
  • a determining unit configured to determine whether the first command is an instruction single step command, and obtain a second determination result
  • a sending unit configured to: when the second determining result is that the first command is an instruction single step command, send the first command to the debugging proxy module, to notify the debugging proxy module to The first command is processed;
  • a conversion and transmission unit configured to, when the second determination result is that the first command is not an instruction single step command, convert the first command into an instruction single step command, and send the to the debug agent module
  • the instruction step command notifies the debug agent module to process the instruction single step command.
  • the acquiring and processing module includes:
  • a query unit configured to query the debug agent module for an event for the event or command occurrence notification
  • a receiving unit configured to receive a completion event of the single-step instruction that is sent by the debugging proxy module
  • An obtaining unit configured to acquire program running state information that is processed by the debugging agent module to process the single step instruction
  • the recording unit is configured to record the program running state information into a logical storage space, where the logical storage space is set to record required program running state information of the debugging control module for performing instruction playback.
  • the program running status information includes: a memory operation record frame of the operation performed by the debug agent module on the memory according to the single step instruction, and the operation of the register by the debug agent module according to the single step instruction The register operation record frame and the end frame created when the debug agent module completes the memory operation record frame and the register operation record frame.
  • the logical storage space includes a linked list.
  • the embodiment of the invention further provides a debugger comprising the reverse debugging device described above.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the above method.
  • Figure 1 shows a structural diagram of an instruction recording frame
  • Figure 2 shows a recording flow chart in the synchronous mode
  • FIG. 3 is a flow chart showing the steps of a reverse debugging method according to an embodiment of the present invention.
  • Figure 4 shows a recording flow chart in the asynchronous mode
  • Figure 5 shows a flow chart of the playback process
  • FIG. 6 is a structural block diagram of a reverse debugging apparatus according to an embodiment of the present invention.
  • FIG. 3 is a flow chart showing the steps of a reverse debugging method according to an embodiment of the present invention.
  • an embodiment of the present invention provides a reverse debugging method, including the following steps:
  • Step 301 After sending a single-step instruction to a debugging proxy module, receiving an event or command occurrence notification, where the single-step instruction is determined by the debugging control module according to a debugging control command input by the user;
  • Step 302 Determine whether the event or the command occurrence notification is for an event or a command, and obtain a first determination result.
  • Step 303 When the first determination result is that the event or the command occurrence notification is for the command, parsing the command, obtaining the first command for the event or the command occurrence notification; and processing the first command, executing Step 305;
  • Step 304 When the first determination result is that the event or the command occurrence notification is for an event, acquiring, by the debugging agent module, a completion event of the single-step instruction for the event or command occurrence notification; and processing Completion event
  • step 305 ends.
  • the method is for a debug control module.
  • the event is judged by receiving an event or a command occurrence notification.
  • the command occurrence notification is for the event or the command, and the different processing is performed according to the difference of the judgment result, thereby implementing the reverse debugging in the asynchronous debugging mode.
  • the logical storage space includes a linked list.
  • the processing the first command may include:
  • the second determining result is that the first command is an instruction single step command, sending the first command to the debugging proxy module, informing the debugging proxy module to process the first command;
  • the second determination result is that the first command is not an instruction single step command
  • converting the first command into an instruction single step command and sending the instruction single step command to the debugging proxy module, notifying the The debug agent module processes the instruction single step command.
  • the completion event of the single-step instruction for obtaining the event or the command occurrence notification from the debugging agent module may include:
  • the processing the completion event includes:
  • the program running state information is recorded into a logical storage space, and the logical storage space is used to record required program running state information of the debugging control module for performing instruction playback.
  • the recording program running status information may include: recording a memory operation recording frame of the operation performed by the debugging agent module on the memory according to the single-step instruction, and recording, by the debugging agent module, the register according to the single-step instruction The operation of the register operation record frame and the end frame created by the debug agent module when the memory operation record frame and the register operation record frame are completed.
  • the embodiment provides a reverse debugging method in the asynchronous debugging mode.
  • the embodiment relates to an implementation technology of a debugger, in particular, a method for implementing a reverse debugging in an asynchronous mode by a debugger, so that the debugger can record the instructions of the called program in the asynchronous mode and then execute in reverse. If you want to implement reverse debugging in asynchronous mode, you need to adjust and integrate the reverse debugging module and the asynchronous debugging framework accordingly.
  • the purpose of this embodiment is to integrate a reverse debugging module and an asynchronous framework of a debugger to provide a reverse debugging method.
  • the present embodiment relates to the following aspects.
  • Step A The debug control module receives the debug control command input by the user, and the debug control module parses the command. If it is continued operation, the source code single step or the return operation, etc., all are converted into the instruction single step command to notify the debug agent module to complete the command. The instruction is single-stepped, and then the debug control module enters the event wait and processing loop. 2. Step B. The debug agent module notifies the debug control module that an event has occurred after completing a single step.
  • Step C The debug control module learns that an event has been queried and an event is acquired, and the instruction is recorded before the event is processed.
  • Step D The debug control module processes the single-step event. If the breakpoint reaches the boundary condition of the current operation, the single-step command is stopped and reported to the user, and if the boundary condition is not reached, the single step is continued.
  • command recording only records the operation of the memory and registers.
  • the function of command recording is completed by the debug control module. The basic flow is as follows:
  • Step A If it is the first instruction step, it is recorded in the process of restoring the program running. If it is not the first instruction, it is recorded in the event waiting process. Synchronous mode continuously steps and records in the loop of the event waiting flow. In asynchronous mode, it must return to the event processing loop every time an instruction is recorded. If every instruction is recorded, the event processing loop is not returned, but the next instruction is continued. The debug control module will not receive a single step completion event.
  • Step C If the instruction has an operation on the memory, create a memory operation record frame to record its operation on the memory; if the instruction has an operation on the register, create a register operation record frame to record its operation on the register; Create an end frame after recording this instruction. These record frames are added to the log list of the debug control module.
  • the debug control module will read the record of each instruction from the log list and play it back one by one. It should be noted that if it is executed in the forward direction and the execution range is within the range of the recorded instructions, it will also be executed in the playback mode. Referring to Figure 5, the basic process is as follows:
  • Step 500 the process begins
  • Step 501 it is determined whether there is any record in the record log list, if there is no record, step 512 is performed, if there is a record, step 502 is performed;
  • Step 502 it is determined whether the record is forward execution or reverse execution, if it is forward execution, step 503 is performed; if it is reverse execution, step 504 is performed;
  • Step 503 reading the next frame of the current linked list pointer, step 505;
  • Step 504 reading a previous frame of the current linked list pointer
  • Step 505 it is determined whether it is a memory frame or a register frame, if it is a memory frame, step 506; if it is a register frame, step 507;
  • Step 506 restore the memory, step 508;
  • Step 507 restoring the register
  • Step 508 it is determined whether the playback of an instruction is completed, if it is completed, step 509 is performed; if not, return to step 502;
  • Step 509 marking a SIGTRAP event
  • Step 510 processing the event
  • Step 511 in the event processing flow, determine whether the current pc has a breakpoint or reach the boundary condition of the current run, if yes, go to step 512; if not, go to step 501;
  • step 512 the playback is stopped and reported to the user.
  • Figure 4 shows the recording flow chart in asynchronous mode.
  • the arrow extending from the step 421 to the left side indicates that the agent module is in the notification event step, and sends a notification event to the control module that the instruction step processing is completed, so that the control module performs the judgment on whether the event is an event or a command.
  • the arrow from step 402 to step 422 indicates that the control module sends a query request to the proxy module when the event query step is in progress, querying the event for which the notification event was just sent by the proxy module.
  • the arrow from step 413 to step 424 indicates that the control module is in the process of sending a command step to send an instruction step to the agent module, so that the agent module enters from the waiting command step.
  • the command state is processed to process the instruction step.
  • the local_zdb user-mode command line debugger developed by the Chengdu Research Institute of ZTE Research Center will be used as an example to briefly explain the reverse debugging of this asynchronous mode debugger.
  • the debug control module records the operation of the instruction. This information can completely describe the effect of an instruction execution, including two types: operation information on the register and operation information on the memory.
  • a machine instruction records the address and value of the modified memory if it modifies the memory; if it modifies the register, it records the sequence number and value of the register.
  • These modified records are represented and stored by struct record_entry:
  • Multiple record_entry are connected to the record_list linked list by prev and next.
  • a machine instruction may modify both the memory and the register, so the execution of an instruction consists of multiple entries in the record_list.
  • the register entry is used to record the modification of the register; the memory entry is used to record the memory modification; the end entry indicates The order ends.
  • the instruction record frame structure is represented by FIG.
  • the log chain header and the current pointer of the linked list are respectively represented by two global record_full_list and record_full_first defined by the structure.
  • Instruction recording and playback are performed by the record_target layer.
  • the record mode it is located at the top level of the target stack. All control of the debugger in the run control process is called first and then recorded or played back, and then the async_target asynchronous layer is called.
  • the corresponding run control function performs the actual operation on the program. The following is the call correspondence between the important run control functions between the two layers of targets:
  • Record_full_resume is the target recovery run function of the record_target layer. During the recording process, since the pc has stopped at the next instruction after his execution is completed, the recording of the first pointer must be completed here:
  • the resume function calls the remote_async_resume function, which determines whether it is currently in the recording state. If so, all the running commands sent to the debugging agent module are single steps:
  • FIG. 6 is a block diagram showing the structure of a reverse debugging device according to an embodiment of the present invention. Referring to Figure 6, an embodiment of the present invention further provides a reverse debugging device, including:
  • the receiving module 601 is configured to: after sending a single-step instruction to a debugging proxy module, receive an event or command occurrence notification, where the single-step instruction is determined by the debugging control module according to a debugging control command input by a user;
  • the determining module 602 is configured to determine whether the event or the command occurrence notification is for an event or a command, and obtain a first determination result;
  • the parsing and processing module 603 is configured to: when the first determination result is the event or the command occurrence notification is directed to the command, parse the command, obtain the first command for the event or command occurrence notification; and process the First order
  • the obtaining and processing module 604 is configured to: when the first determination result is that the event or the command occurrence notification is for an event, acquire, by the debugging proxy module, the completion of the single-step instruction for the event or command occurrence notification An event; and processing the completion event.
  • the device is used for a debug control module.
  • the parsing and processing module 603 can include:
  • a parsing unit configured to parse the command when the first judgment result is the event or the command occurrence notification is for the command, and obtain the first command for the event or the command occurrence notification;
  • a determining unit configured to determine whether the first command is a single step of the instruction, and obtain a second determination result
  • a sending unit configured to send the first command to the debugging proxy module to notify the debugging proxy module to the first command when the second determining result is that the first command is an instruction single step command Process
  • a conversion and transmission unit configured to, when the second determination result is that the first command is not an instruction single step command, convert the first command into an instruction single step command, and send the to the debug agent module
  • the instruction step command notifies the debug agent module to process the instruction single step command.
  • the obtaining and processing module 604 can include:
  • a query unit configured to query the debug agent module for an event for the event or command occurrence notification
  • a receiving unit configured to receive a completion event of the single-step instruction that is sent by the debugging proxy module
  • An obtaining unit configured to acquire program running state information that is processed by the debugging agent module to process the single step instruction
  • the recording unit is configured to record the program running state information into a logical storage space, where the logical storage space is set to record required program running state information of the debugging control module for performing instruction playback.
  • the program running status information may include: a memory operation record frame of the operation of the debug agent module according to the single step instruction on the memory, and a register operation of the operation of the register by the debug agent module according to the single step instruction The recording frame and the end frame created by the debug agent module when the memory operation recording frame and the register operation recording frame are completed.
  • the logical storage space can include a linked list.
  • the embodiment of the invention further provides a debugger, which includes the reverse debugging device described above.
  • all or part of the steps of the above embodiments may also be implemented by using an integrated circuit. These steps may be separately fabricated into individual integrated circuit modules, or multiple modules or steps may be fabricated into a single integrated circuit module. achieve.
  • the devices/function modules/functional units in the above embodiments may be implemented by a general-purpose computing device, which may be centralized on a single computing device or distributed over a network of multiple computing devices.
  • each device/function module/functional unit in the above embodiment When each device/function module/functional unit in the above embodiment is implemented in the form of a software function module and sold or used as a stand-alone product, it can be stored in a computer readable storage medium.
  • the above mentioned computer readable storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
  • the above technical solution can perform different processing on the event or command occurrence notification for an event or a command, and implement reverse debugging in the asynchronous debugging mode.

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

一种反向调试方法、装置及调试器。所述方法包括:在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由所述调试控制模块根据用户输入的调试控制命令确定;判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述用户命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令;当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件。上述技术方案实现了异步调试模式下的反向调试。

Description

一种反向调试方法、装置及调试器 技术领域
本发明涉及调试领域,尤其涉及一种反向调试方法、装置及调试器。
背景技术
调试往往是一个猜测的过程需要对怀疑的代码重复分析,一般不太可能第一次就将断点放在最合适的位置。比如我们经常会发现重要的代码已经错过或者在运行到断点之前程序的某些状态已经不正确了,通常我们只能退出调试并重新启动新的调试从头再来,调试效率比较低。
假如有反向调试功能,在这种情况下我们无需重新启动调试只要简单的让被调程序反向执行到我们怀疑的地方,排查完后我们还可以继续正向执行调试。这无疑将极大的提高了调试效率。
标准gdb从7.0版本开始支持反向调试(reverse debug)新特性,这个新功能允许用户无需重新启动调试就可对目标代码来回调试,就像我们在学习英语的时候使用复读机一样将听不懂的部分重放和分析。
它的基本原理为:调试器将程序执行的每一条指令细节录制下来,当需要回退时根据记录对每一条指令的操作进行恢复,从而将程序恢复到当时的状态。比如某条指令将寄存器reg1的值加了1那么undo就是将其减1。反向调试过程就象我们熟悉的普通调试过程一样,只是需要使用相应的反向调试控制命令而已。需要说明的是,目前反向调试只支持恢复程序对内存和寄存器的操作而对文件或终端的操作则无法恢复。
标准gdb是在同步模式的框架下来实现这种功能的,在这种模式下只有当被调程序处于停止状态,调试器才能接收和处理用户的任何调试命令。
gdb调试器子系统调试器部分按照功能对模块进行分解,然后在每个模块内部细化功能为每个功能单元。模块划分为调试控制模块gdb和调试代理模块gdbserver两部分:
调试控制模块gdb:
gdb主要功能设置为接收用户输入的调试命令并将该调试命令发送至调试代理模块,对目标端进行调试控制,对调试代理模块返回的调试事件进行解析。
调试代理模块gdbserver:
gdbserver主要功能设置为接受gdb发送的调试命令,并主动向gdb返回调试事件;gdbserver以同步模型为基础,同时监控gdb调试命令和被跟踪任务的状态事件。
gdb-gdbserver同步框架基本流程:
步骤A.gdb解析用户输入的调试命令然后向gdbserver发送相应的命令让程序运行起来,然后等待gdbserver调试事件上报。由于gdb一直在同步等待gdbserver上报事件,因此在此过程中gdb无法接收用户输入。
步骤B.gdbserver收到gdb的调试命令然后执行完相应调试动作或者触发事件(收到信号或撞断点等)上报gdb。
步骤C.如果被调程序发生事件由gdbserver上报,gdb收到该事件处理后才能再次接收用户输入命令,如果gdbserver上报的不是停止事件,gdb仍然不能接收用户输入。
同步模式下反向调试的录制流程:
步骤A.开始录制,gdb将用户下发的所有调试控制命令比如继续运行命令,源代码单步,返回等全部转换为指令单步。
步骤B.gdbserver控制程序完成一次指令单步后将单步完成事件上报给gdb,gdb对该指令进行反汇编分析看这条指令完成了哪些操作并把这些操作记录到一个log链表中去。
步骤C.完成了录制之后gdb才开始处理事件流程,看当前是否撞断点或当前pc是否已经满足本次运行的边界条件,如果是的话就停止下发指令单步操作然后上报用户,如果不是则继续走单步。在同步模式下,gdb不需要退回到事件处理循环去感知和获取gdbserver上报调试事件。
指令录制帧的结构如图1所示。图中的inst1表示第一条指令的录制帧,该指令对内存和寄存器都进行了操作,因此在本帧分别用mem entry(内存条目)和reg entry(寄存器条目)记录了这条指令对内存和寄存器的写操作的 详细信息,比如被修改内存的地址和值或被修改寄存器的编号和值等,end entry(结束条目)表示这条录制帧的结束。同理,inst2表示第二条指令录制帧,它也对内存和寄存器都有操作;而inst3表示第三条指令录制帧,这条指令只对寄存器有操作因此没有mem enrty;而那些对内存或寄存器没有写操作的指令,比如分支延迟槽指令,其录制帧只有end entry;以此类推,调试器将录制范围内的所有指令都按照这种格式记录下来并用每个指令的录制帧为节点的双向链表保存,在指令回放时使用这些数据。
同步模式下的录制流程如图2所示。其中,从步骤203到步骤211的箭头表示gdb处于发送单步命令的状态时向gdbserver发送指令单步,使得gdbserver从命令等待步骤进入处理命令发送事件步骤来处理该指令单步。从步骤212到步骤204的箭头表示gdbserver处于处理命令发送事件步骤时,将处理完成该指令单步的事件上报给gdb。
同步模式下反向调试的回放流程:
步骤A.用户输入反向执行命令(如反向执行,返回,单步)gdb从录制log链表中读取上一条指令记录信息并解析然后通知调试代理模块对寄存器或内存执行反向操作。
步骤B.每执行一条反向操作gdb将其视为一个调试事件发生,进入事件处理流程,如果当前pc已经满足本次操作边界条件gdb就停止反向运行操作,并上报用户。
由于同步模式的调试不允许调试器在程序运行时处理用户命令,用户体验较差,因此有些调试器采用异步模式框架。异步框架的基本流程:
步骤A.调试控制模块命令调试代理模块让程序运行起来,然后等待调试代理模块上报程序调试事件上报,在这个过程中调试控制模块退回到事件/命令等待流程,因此仍然可以接收和处理用户命令。
步骤B.调试代理模块收到命令完成相应调试工作后通知调试控制模块当前有事件发生。
步骤C.调试控制模块得知有调试事件发生向调试代理模块查询事件然后调试代理模块将事件上报给调试控制模块。
步骤D.调试控制模块处理事件。
在目前的调试器中还没有在异步模式下可进行反向调试的实现。
发明内容
本发明实施例的目的是提供一种反向调试方法、装置及调试器,使得反向调试在异步调试模式下也能够实现。
为解决上述技术问题,本发明实施例提供方案如下:
本发明实施例提供一种用于一控制模块的反向调试方法,包括:
在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由所述调试控制模块根据用户输入的调试控制命令确定;
判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;
当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令;
当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件。
可选地,所述处理所述第一命令包括:
判断所述第一命令是否是指令单步命令,获取一第二判断结果;
当所述第二判断结果为所述第一命令是指令单步命令时,向所述调试代理模块发送所述第一命令,通知所述调试代理模块对所述第一命令进行处理;
当所述第二判断结果为所述第一命令不是指令单步时,将所述第一命令转换为指令单步命令,以及向所述调试代理模块发送所述指令单步命令,通知所述调试代理模块对所述指令单步命令进行处理。
可选地,所述从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件包括:
向所述调试代理模块查询所述事件或命令发生通知针对的事件;
接收所述调试代理模块响应的所述所述单步指令的完成事件;
所述处理所述完成事件包括:
获取所述调试代理模块对所述单步指令进行处理的程序运行状态信息;
将所述程序运行状态信息记录到一逻辑存储空间中,所述逻辑存储空间用于记录所述调试控制模块进行指令回放的所需的程序运行状态信息。
可选地,所述程序运行状态信息包括:所述调试代理模块根据所述单步指令对内存进行的操作的内存操作记录帧、所述调试代理模块根据所述单步指令对寄存器进行的操作的寄存器操作记录帧和所述调试代理模块完成所述内存操作记录帧和所述寄存器操作记录帧时创建的结束帧。
可选地,所述逻辑存储空间包括链表。
本发明实施例还提供一种用于一控制模块的反向调试装置,包括:
接收模块,设置为在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由所述调试控制模块根据用户输入的调试控制命令确定;
判断模块,设置为判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;
解析及处理模块,设置为当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令;
获取及处理模块,设置为当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件。
可选地,所述解析及处理模块包括:
解析单元,设置为当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;
判断单元,设置为判断所述第一命令是否是指令单步命令,获取一第二判断结果;
发送单元,设置为当所述第二判断结果为所述第一命令是指令单步命令时,向所述调试代理模块发送所述第一命令,通知所述调试代理模块对所述 第一命令进行处理;
转换及发送单元,设置为当所述第二判断结果为所述第一命令不是指令单步命令时,将所述第一命令转换为指令单步命令,以及向所述调试代理模块发送所述指令单步命令,通知所述调试代理模块对所述指令单步命令进行处理。
可选地,所述获取及处理模块包括:
查询单元,设置为向所述调试代理模块查询所述事件或命令发生通知针对的事件;
接收单元,设置为接收所述调试代理模块响应的所述单步指令的完成事件;
获取单元,设置为获取所述调试代理模块对所述单步指令进行处理的程序运行状态信息;
记录单元,设置为将所述程序运行状态信息记录到一逻辑存储空间中,所述逻辑存储空间设置为记录所述调试控制模块进行指令回放的所需的程序运行状态信息。
可选地,所述程序运行状态信息包括:所述调试代理模块根据所述单步指令对内存进行的操作的内存操作记录帧、所述调试代理模块根据所述单步指令对寄存器进行的操作的寄存器操作记录帧和所述调试代理模块完成所述内存操作记录帧和所述寄存器操作记录帧时创建的结束帧。
可选地,所述逻辑存储空间包括链表。
本发明实施例还提供一种包括以上所述的反向调试装置的调试器。
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行上述方法。
从以上所述可以看出,本发明实施例至少具有如下有益效果:
通过接收一事件或命令发生通知,判断所述事件或命令发生通知是针对事件还是命令,根据判断结果的不同做不同处理,从而实现了异步调试模式 下的反向调试。
附图概述
图1表示指令录制帧的结构图;
图2表示同步模式下的录制流程图;
图3表示本发明实施例提供的一种反向调试方法的步骤流程图;
图4表示异步模式下的录制流程图;
图5表示回放过程流程图;
图6表示本发明实施例提供的一种反向调试装置的结构框图。
本发明的较佳实施方式
下面将结合附图对本发明实施例进行详细描述。
图3表示本发明实施例提供的一种反向调试方法的步骤流程图,参照图3,发明实施例提供一种反向调试方法,包括如下步骤:
步骤301,在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由调试控制模块根据用户输入的调试控制命令确定;
步骤302,判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;
步骤303,当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令,执行步骤305;
步骤304,当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件;
步骤305流程结束。
所述方法用于一调试控制模块。
可见,通过上述方式,通过接收一事件或命令发生通知,判断所述事件 或命令发生通知是针对事件还是命令,根据判断结果的不同做不同处理,从而实现了异步调试模式下的反向调试。
其中,所述逻辑存储空间包括链表。
本发明实施例中,所述处理所述第一命令可以包括:
判断所述第一命令是否是指令单步命令,获取一第二判断结果;
当所述第二判断结果为所述第一命令是指令单步命令时,向所述调试代理模块发送所述第一命令,通知所述调试代理模块对所述第一命令进行处理;
当所述第二判断结果为所述第一命令不是指令单步命令时,将所述第一命令转换为指令单步命令,以及向所述调试代理模块发送所述指令单步命令,通知所述调试代理模块对所述指令单步命令进行处理。
本发明实施例中,所述从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件可以包括:
向所述调试代理模块查询所述事件或命令发生通知针对的事件;
接收所述调试代理模块响应的所述单步指令的完成事件;
所述处理所述完成事件包括:
获取所述调试代理模块对所述单步指令进行处理的程序运行状态信息;
将所述程序运行状态信息记录到一逻辑存储空间中,所述逻辑存储空间用于记录所述调试控制模块进行指令回放的所需的程序运行状态信息。
其中,所述记录程序运行状态信息可包括:记录所述调试代理模块根据所述单步指令对内存进行的操作的内存操作记录帧、记录所述调试代理模块根据所述单步指令对寄存器进行的操作的寄存器操作记录帧和所述调试代理模块完成所述内存操作记录帧和所述寄存器操作记录帧时创建的结束帧。
本实施方式提供一种异步调试模式下的反向调试方法。本实施方式涉及调试器的实现技术,尤其调试器在异步模式下实现反向调试的方法,让调试器能够在异步模式下对被调程序的指令进行录制然后反向执行。如果要在异步模式下实现反向调试,则需要对反向调试模块与异步调试框架进行相应的调整与整合。
本实施方式的目的在于,整合调试器的反向调试模块和异步框架,提供一种反向调试方法。
为达到这一目的,本实施方式涉及以下几方面内容。
(1)运行调试控制
反向调试的前提就是调试器对程序执行的每一条指令进行录制,在录制模式下用户的任何一个运行控制命令最终都是以指令单步的形式来完成的。其流程如下:
1.步骤A.调试控制模块接收用户输入的调试控制命令,调试控制模块解析该命令,如果是继续运行、源代码单步或返回等操作则全部转换为指令单步命令通知调试代理模块完成一次指令单步操作,然后调试控制模块进入事件等待和处理循环。2.步骤B.调试代理模块完成一次单步后通知调试控制模块有事件发生。
3.步骤C.调试控制模块获知有事件发生后查询并获取事件,在处理事件之前对该指令进行录制。
4.步骤D.调试控制模块处理该单步事件,如果有断点达到本次操作的边界条件则停止下发单步命令并上报用户,如果没有达到所述边界条件则继续走单步。
(2)指令录制
由于反向调试无法对文件和终端(如屏幕显示等)进行反向操作,因此指令录制只记录对内存和寄存器的操作。指令录制的功能由调试控制模块完成,基本流程如下:
1.步骤A.如果是第一条指令单步则在恢复程序运行的流程中记录,如果不是第一条指令,就在事件等待流程中记录。同步模式在事件等待流程的循环中连续走单步并录制,而异步模式下必须每录制一条指令就返回事件处理循环,如果每录制一条指令不返回事件处理循环,而是继续录制下一条指令,调试控制模块将无法收到单步完成事件。
2.步骤B.对指令进行分析。
3.步骤C.如果该指令有对内存的操作则建立一个内存操作记录帧记录其对内存的操作;如果该指令有对寄存器的操作则建立一个寄存器操作记录帧记录其对寄存器的操作;完成对这条指令的记录后创建一个结束帧。这些记录帧都被加入到调试控制模块的log链表中。
(3)回放
指令回放,调试控制模块将从log链表读取每一条指令的记录然后逐条回放。需要说明的是,如果是正向执行且执行范围在已录制的指令范围之内则也将采用回放模式执行。参照图5,基本流程如下:
步骤500,流程开始;
步骤501,判断录制log链表中是否还有记录,如果没有记录,执行步骤512,如果有记录,执行步骤502;
步骤502,判断所述记录是正向执行还是反向执行,如果是正向执行,执行步骤503;如果是反向执行,执行步骤504;
步骤503,读取当前链表指针的后一帧,执行步骤505;
步骤504,读取当前链表指针的前一帧,
步骤505,判断是内存帧还是寄存器帧,如果是内存帧,执行步骤506;如果是寄存器帧,执行步骤507;
步骤506,恢复内存,执行步骤508;
步骤507,恢复寄存器;
步骤508,判断是否完成一条指令的回放,如果完成,执行步骤509;如果没有完成,返回步骤502;
步骤509,标记一条SIGTRAP事件;
步骤510,对这个事件进行处理;
步骤511,在事件处理流程中判断当前pc是否存在断点或达到本次运行的边界条件,如果是,执行步骤512;如果不是,执行步骤501;
步骤512,,停止回放并上报用户。
图4表示异步模式下的录制流程图。
图4中,从步骤421向左侧延伸的箭头表示代理模块处于通知事件步骤时,向控制模块发送指令单步处理完成的通知事件,使控制模块来进行关于感知到的是事件还是命令的判断。从步骤402到步骤422的箭头表示控制模块处于事件查询步骤时向代理模块发送查询请求,查询代理模块刚才发送的通知事件所针对的事件。从步骤413到步骤424的箭头表示控制模块处于发送命令步骤时向代理模块发送指令单步,使得代理模块从等待命令步骤进入 处理命令状态来处理该指令单步。
<具体实施例>
下面将以中兴通讯中心研究院成都研究所研发的local_zdb用户态命令行调试器为例对这种异步模式调试器支持反向调试进行简要说明。
(1)指令录制
每次执行一条指令调试控制模块便将关于该指令的操作录制下来,这些信息可以完整地描述一条指令执行的效果,包括两类:对寄存器的操作信息和对内存的操作信息。
一条机器指令如果它修改了内存,那么便记录下被修改内存的地址和值;如果它修改了寄存器,便记录下寄存器的序号和值。这些修改记录由struct record_entry表示和存储:
Figure PCTCN2015074971-appb-000001
多个record_entry通过prev和next连接成record_list链表。一条机器指令可能既修改内存也修改寄存器,因此一条指令的执行效果由record_list中的多个entry组成。有三种entry,表示寄存器的entry,表示memory的entry和标志指令结束的entry。顾名思义,register entry用来记录寄存器的修改情况;memory entry用来记录内存的修改;end entry表示指 令结束。
指令记录帧结构由图1表示。
log链表头和链表当前指针分别由该结构体定义的两个全局record_full_list和record_full_first表示。
指令录制和回放都由record_target层来完成,在record模式下它位于target栈的顶层,运行控制流程所有对调试程序的控制首先调用它并在其中完成录制或回放,然后由它来调用async_target异步层对应的运行控制函数对程序作实际上的操作,以下为两层target之间重要的运行控制函数之间的调用对应关系:
record_full_resume->remote_async_resume
record_wait->remote_async_wait
record_full_resume是record_target层的目标恢复运行函数,在录制过程中因为当他执行完成以后pc已经停在下一条指令处因此第一条指针的录制必须在这里完成:
Figure PCTCN2015074971-appb-000002
Figure PCTCN2015074971-appb-000003
此后的指令录制都在事件等待函数record_full_wait中完成。
Figure PCTCN2015074971-appb-000004
Figure PCTCN2015074971-appb-000005
Figure PCTCN2015074971-appb-000006
Figure PCTCN2015074971-appb-000007
(2)指令回放
指令回放也是在record_full_wait函数中完成:
Figure PCTCN2015074971-appb-000008
Figure PCTCN2015074971-appb-000009
Figure PCTCN2015074971-appb-000010
Figure PCTCN2015074971-appb-000011
(3)运行控制
所有的正反向的恢复运行,单步,返回等操作都会调用调试控制模块的proceed函数,由它来调用resume函数并最终由record层的record_full_resume,record_full_wait和异步层的remote_async_resume完成录制和回放,对应的运行控制也在这个流程中完成。
Figure PCTCN2015074971-appb-000012
Figure PCTCN2015074971-appb-000013
录制时resume函数调用remote_async_resume函数,由他来判断当前是否是录制状态,如果是的话向调试代理模块下发的所有运行命令都是指令单步:
Figure PCTCN2015074971-appb-000014
Figure PCTCN2015074971-appb-000015
指令回放时在proceed函数中进入wait_for_inferior(),调试控制模块在非录制模式下是不会进入这个函数的。这个函数的每一次循环都调用record_full_wait来完成一条指令回放然后调用handle_inferior_event函数处理事件并控制运行:
Figure PCTCN2015074971-appb-000016
Figure PCTCN2015074971-appb-000017
图6表示本发明实施例提供的一种反向调试装置的结构框图,参照图6,本发明实施例还提供一种反向调试装置,包括:
接收模块601,设置为在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由所述调试控制模块根据用户输入的调试控制命令确定;
判断模块602,设置为判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;
解析及处理模块603,设置为当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令;
获取及处理模块604,设置为当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件。
所述装置用于一调试控制模块。
可见,通过上述方式,通过接收一事件或命令发生通知,判断所述事件或命令发生通知是针对事件还是命令,根据判断结果的不同做不同处理,从而实现了异步调试模式下的反向调试。
其中,所述解析及处理模块603可包括:
解析单元,设置为当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;
判断单元,设置为判断所述第一命令是否是指令单步,获取一第二判断结果;
发送单元,设置为当所述第二判断结果为所述第一命令是指令单步命令时,向所述调试代理模块发送所述第一命令,通知所述调试代理模块对所述第一命令进行处理;
转换及发送单元,设置为当所述第二判断结果为所述第一命令不是指令单步命令时,将所述第一命令转换为指令单步命令,以及向所述调试代理模块发送所述指令单步命令,通知所述调试代理模块对所述指令单步命令进行处理。
所述获取及处理模块604可包括:
查询单元,设置为向所述调试代理模块查询所述事件或命令发生通知针对的事件;
接收单元,设置为接收所述调试代理模块响应的所述单步指令的完成事件;
获取单元,设置为获取所述调试代理模块对所述单步指令进行处理的程序运行状态信息;
记录单元,设置为将所述程序运行状态信息记录到一逻辑存储空间中,所述逻辑存储空间设置为记录所述调试控制模块进行指令回放的所需的程序运行状态信息。
所述程序运行状态信息可包括:所述调试代理模块根据所述单步指令对内存进行的操作的内存操作记录帧、所述调试代理模块根据所述单步指令对寄存器进行的操作的寄存器操作记录帧和所述调试代理模块完成所述内存操作记录帧和所述寄存器操作记录帧时创建的结束帧。
所述逻辑存储空间可包括链表。
本发明实施例还提供一种调试器,所述调试器包括以上所述的反向调试装置。
以上内容是结合具体的实施方式对本发明所作的进一步详细说明,不能 认定本发明的具体实施只局限于这些说明。
本领域普通技术人员可以理解上述实施例的全部或部分步骤可以使用计算机程序流程来实现,所述计算机程序可以存储于一计算机可读存储介质中,所述计算机程序在相应的硬件平台上(如系统、设备、装置、器件等)执行,在执行时,包括方法实施例的步骤之一或其组合。
可选地,上述实施例的全部或部分步骤也可以使用集成电路来实现,这些步骤可以被分别制作成一个个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。
上述实施例中的各装置/功能模块/功能单元可以采用通用的计算装置来实现,它们可以集中在单个的计算装置上,也可以分布在多个计算装置所组成的网络上。
上述实施例中的各装置/功能模块/功能单元以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。上述提到的计算机可读取存储介质可以是只读存储器,磁盘或光盘等。
工业实用性
上述技术方案能够对针对事件或命令的事件或命令发生通知做不同处理,实现了异步调试模式下的反向调试。

Claims (12)

  1. 一种用于一调试控制模块的反向调试方法,包括:
    在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由所述调试控制模块根据用户输入的调试控制命令确定;
    判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;
    当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令;
    当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件。
  2. 根据权利要求1所述的反向调试方法,其中,所述处理所述第一命令包括:
    判断所述第一命令是否是指令单步命令,获取一第二判断结果;
    当所述第二判断结果为所述第一命令是指令单步命令时,向所述调试代理模块发送所述第一命令,通知所述调试代理模块对所述第一命令进行处理;
    当所述第二判断结果为所述第一命令不是指令单步时,将所述第一命令转换为指令单步命令,以及向所述调试代理模块发送所述指令单步命令,通知所述代理模块对所述指令单步命令进行处理。
  3. 根据权利要求1所述的反向调试方法,其中,所述从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件包括:
    向所述调试代理模块查询所述事件或命令发生通知针对的事件;
    接收所述调试代理模块响应的所述单步指令的完成事件;
    所述处理所述完成事件包括:
    获取所述调试代理模块对所述单步指令进行处理的程序运行状态信息;
    将所述程序运行状态信息记录到一逻辑存储空间中,所述逻辑存储空间用于记录所述调试控制模块进行指令回放的所需的程序运行状态信息。
  4. 根据权利要求3所述的反向调试方法,其中,所述程序运行状态信息包括:
    所述调试代理模块根据所述单步指令对内存进行的操作的内存操作记录帧、所述调试代理模块根据所述单步指令对寄存器进行的操作的寄存器操作记录帧和所述调试代理模块完成所述内存操作记录帧和所述寄存器操作记录帧时创建的结束帧。
  5. 根据权利要求3所述的反向调试方法,其中,
    所述逻辑存储空间包括链表。
  6. 一种用于一调试控制模块的反向调试装置,包括:
    接收模块,设置为在向一调试代理模块发送一单步指令之后,接收一事件或命令发生通知,所述单步指令由所述调试控制模块根据用户输入的调试控制命令确定;
    判断模块,设置为判断所述事件或命令发生通知是针对事件还是命令,获取一第一判断结果;
    解析及处理模块,设置为当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;以及处理所述第一命令;
    获取及处理模块,设置为当所述第一判断结果为所述事件或命令发生通知针对事件时,从所述调试代理模块获取所述事件或命令发生通知针对的所述单步指令的完成事件;以及处理所述完成事件。
  7. 根据权利要求6所述的反向调试装置,其中,所述解析及处理模块包括:
    解析单元,设置为当所述第一判断结果为所述事件或命令发生通知针对命令时,解析所述命令,获得所述事件或命令发生通知针对的第一命令;
    判断单元,设置为判断所述第一命令是否是指令单步命令,获取一第二判断结果;
    发送单元,设置为当所述第二判断结果为所述第一命令是指令单步命令时,向所述调试代理模块发送所述第一命令,通知所述调试代理模块对所述第一命令进行处理;
    转换及发送单元,设置为当所述第二判断结果为所述第一命令不是指令单步命令时,将所述第一命令转换为指令单步命令,以及向所述调试代理模块发送所述指令单步命令,通知所述调试代理模块对所述指令单步命令进行处理。
  8. 根据权利要求6所述的反向调试装置,其中,所述获取及处理模块包括:
    查询单元,设置为向所述调试代理模块查询所述事件或命令发生通知针对的事件;
    接收单元,设置为接收所述调试代理模块响应的所述单步指令的完成事件;
    获取单元,设置为获取所述调试代理模块对所述单步指令进行处理的程序运行状态信息;
    记录单元,设置为将所述程序运行状态信息记录到一逻辑存储空间中,所述逻辑存储空间设置为记录所述调试控制模块进行指令回放的所需的程序运行状态信息。
  9. 根据权利要求8所述的反向调试装置,其中,
    所述程序运行状态信息包括:所述调试代理模块根据所述单步指令对内存进行的操作的内存操作记录帧、所述调试代理模块根据所述单步指令对寄存器进行的操作的寄存器操作记录帧和所述调试代理模块完成所述内存操作记录帧和所述寄存器操作记录帧时创建的结束帧。
  10. 根据权利要求8所述的反向调试装置,其中,
    所述逻辑存储空间包括链表。
  11. 一种调试器,包括如权利要求6至10中任一项所述的反向调试装置。
  12. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1~5中任一项所述的方法。
PCT/CN2015/074971 2014-11-06 2015-03-24 一种反向调试方法、装置及调试器 WO2015184908A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410621460.6 2014-11-06
CN201410621460.6A CN105630664B (zh) 2014-11-06 2014-11-06 一种反向调试方法、装置及调试器

Publications (1)

Publication Number Publication Date
WO2015184908A1 true WO2015184908A1 (zh) 2015-12-10

Family

ID=54766130

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/074971 WO2015184908A1 (zh) 2014-11-06 2015-03-24 一种反向调试方法、装置及调试器

Country Status (2)

Country Link
CN (1) CN105630664B (zh)
WO (1) WO2015184908A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674368A (zh) * 2019-09-11 2020-01-10 深圳创维-Rgb电子有限公司 一种系统调试结果信息的处理方法及装置
CN112416790A (zh) * 2020-11-30 2021-02-26 中国航空工业集团公司西安航空计算技术研究所 一种嵌入式软件离线重放调试方法和装置
CN113179227A (zh) * 2021-04-26 2021-07-27 哈尔滨铁路科研所科技有限公司 基于队列的at指令控制方法

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106897213A (zh) * 2017-01-04 2017-06-27 浙江大学 一种轻量级的测试平台系统的逆向调试实现方法
CN114691486A (zh) * 2020-12-30 2022-07-01 腾讯科技(深圳)有限公司 程序调试方法、装置及计算机设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102713863A (zh) * 2009-10-05 2012-10-03 国际商业机器公司 基于运行时行为自动纠正应用程序
CN103268283A (zh) * 2013-05-10 2013-08-28 华为技术有限公司 反向调试方法、反向调试系统、主机及单板
US20140033178A1 (en) * 2012-07-26 2014-01-30 Adobe Systems Inc. Method and apparatus for reverse debugging source code using causal analysis
CN103577315A (zh) * 2012-07-30 2014-02-12 国际商业机器公司 反向调试器和反向调试方法

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102346708B (zh) * 2010-08-03 2014-07-16 中兴通讯股份有限公司 一种调试器及其调试方法
CN102129408B (zh) * 2011-04-14 2013-09-25 电子科技大学 一种基于记录回放技术的嵌入式软件调试装置和方法
CN104133763A (zh) * 2013-05-03 2014-11-05 富泰华工业(深圳)有限公司 程序调试系统及方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102713863A (zh) * 2009-10-05 2012-10-03 国际商业机器公司 基于运行时行为自动纠正应用程序
US20140033178A1 (en) * 2012-07-26 2014-01-30 Adobe Systems Inc. Method and apparatus for reverse debugging source code using causal analysis
CN103577315A (zh) * 2012-07-30 2014-02-12 国际商业机器公司 反向调试器和反向调试方法
CN103268283A (zh) * 2013-05-10 2013-08-28 华为技术有限公司 反向调试方法、反向调试系统、主机及单板

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674368A (zh) * 2019-09-11 2020-01-10 深圳创维-Rgb电子有限公司 一种系统调试结果信息的处理方法及装置
CN110674368B (zh) * 2019-09-11 2023-10-10 深圳创维-Rgb电子有限公司 一种系统调试结果信息的处理方法及装置
CN112416790A (zh) * 2020-11-30 2021-02-26 中国航空工业集团公司西安航空计算技术研究所 一种嵌入式软件离线重放调试方法和装置
CN112416790B (zh) * 2020-11-30 2023-04-14 中国航空工业集团公司西安航空计算技术研究所 一种嵌入式软件离线重放调试方法和装置
CN113179227A (zh) * 2021-04-26 2021-07-27 哈尔滨铁路科研所科技有限公司 基于队列的at指令控制方法
CN113179227B (zh) * 2021-04-26 2023-05-19 哈尔滨铁路科研所科技有限公司 基于队列的at指令控制方法

Also Published As

Publication number Publication date
CN105630664B (zh) 2020-03-13
CN105630664A (zh) 2016-06-01

Similar Documents

Publication Publication Date Title
WO2015184908A1 (zh) 一种反向调试方法、装置及调试器
US20170132111A1 (en) Monitoring mobile application performance
US8572578B2 (en) Script debugging
US9355003B2 (en) Capturing trace information using annotated trace output
US20100223446A1 (en) Contextual tracing
CN105740326A (zh) 浏览器的线程状态监测方法及装置
JP2006260588A5 (zh)
US20140245085A1 (en) Managing error logs in a distributed network fabric
CN111694864B (zh) 单一进程的流式数据计算执行调度任务并避免数据丢失的方法、系统及计算机设备
US8521765B2 (en) Method and system for post processing trace data
US10108474B2 (en) Trace capture of successfully completed transactions for trace debugging of failed transactions
KR102488582B1 (ko) 애플리케이션 실행 상태 검증 방법 및 장치
CN110515821A (zh) 基于埋点的事件处理方法、电子设备及计算机存储介质
CN106201896A (zh) 一种嵌入式环境下基于检查点的调试方法、系统及装置
US20190340052A1 (en) System for monitoring a plurality of distributed devices
CN111309606B (zh) 页面异常处理方法、装置、计算机设备及存储介质
CN116775442A (zh) 一种软件调试系统
CN108241543B (zh) 业务操作断点执行的方法、业务服务器及系统
US7475386B1 (en) Mechanism for disjoint instrumentation providers in a tracing framework
CN109460310B (zh) 基于web接口的信息收集系统、方法、设备及存储介质
US8171345B2 (en) Disablement of an exception generating operation of a client system
US9304844B2 (en) System and method for preserving critical debug data in a portable computing device
US10824532B2 (en) Dump analysis generation
CN112351233A (zh) 教室教学环境录制方法、装置、存储介质及教育一体机
JP2656471B2 (ja) 分散処理システムおよびその情報処理方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15802462

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15802462

Country of ref document: EP

Kind code of ref document: A1