EP1125199A1 - Method of debugging a program thread - Google Patents

Method of debugging a program thread

Info

Publication number
EP1125199A1
EP1125199A1 EP00962354A EP00962354A EP1125199A1 EP 1125199 A1 EP1125199 A1 EP 1125199A1 EP 00962354 A EP00962354 A EP 00962354A EP 00962354 A EP00962354 A EP 00962354A EP 1125199 A1 EP1125199 A1 EP 1125199A1
Authority
EP
European Patent Office
Prior art keywords
thread
opcode
register
running
processor
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
EP00962354A
Other languages
German (de)
French (fr)
Other versions
EP1125199B1 (en
Inventor
Winthrop L. Saville
Kevin Ross
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Koninklijke Philips NV
Original Assignee
Koninklijke Philips Electronics NV
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 Koninklijke Philips Electronics NV filed Critical Koninklijke Philips Electronics NV
Publication of EP1125199A1 publication Critical patent/EP1125199A1/en
Application granted granted Critical
Publication of EP1125199B1 publication Critical patent/EP1125199B1/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/28Error detection; Error correction; Monitoring by checking the correct order of processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging

Definitions

  • the invention relates to the debugging of computer programs and, in particular, to the capability of debugging multiple threads.
  • One common technique is to stop the running of a program thread (i.e. a sequence of instructions) upon the occurrence of a predetermined event and to examine the contents of various memory locations, e.g. registers, addresses in RAM, etc.
  • a very useful device for stopping a thread in this manner is the breakpoint.
  • Breakpoints for stopping execution of a currently-running thread can be set to occur in a variety of ways. Examples include breakpoints that occur when a specific instruction is executed and breakpoints that occur when a specific memory location is accessed. A representative example of using a specific-instruction type of breakpoint is illustrated in Figures 1 A through IF.
  • Figure 1A illustrates a sequence of instructions in a thread to be debugged.
  • Each of the instructions includes an opcode followed by any parameters (e.g. operands, addresses, data etc.) that are associated with the respective instruction.
  • each opcode is one byte long.
  • the sequence includes three instructions, i.e.:
  • Instruction A comprising opcode A followed by two associated paramaters Al and A2;
  • Instruction B comprising opcode B followed by one associated parameter Bl
  • Instruction C comprising opcode C followed by two associated parameters Cl and C2.
  • Figure IB shows how a breakpoint is set in the thread to be debugged. Specifically, a HALT opcode is substituted by the debugger in place of opcode B.
  • Figure 1 C depicts the instant when the processor has executed Instruction A and has incremented the value PC in the program counter to the address where the HALT opcode is stored.
  • the processor stops running the thread and directly or indirectly notifies the debugger that the breakpoint has been reached. This can be done in a variety of ways, e.g. by the processor activating an interrupt to the debugger or by the debugger periodically polling the state of the processor to detect that the processor has reached a HALT opcode.
  • the debugger responds to notification of the
  • HALT opcode by reading the value PC for the halted thread to determine which one (of possibly many) breakpoints has been reached. The debugger then writes the corresponding opcode (i.e. "opcode B", for which the HALT opcode had been substituted in Figure IB) into the memory 20 and commands the processor to execute the next instruction. In executing this instruction, the processor will read the newly- written opcode B and increment the program counter to indicate the location of the associated single-byte parameter Bl.
  • the processor then reads the associated parameter Bl and increments the program counter to the address of opcode C.
  • the debugger re-substitutes the HALT opcode for opcode B in the program stream. This is necessary to retain the breakpoint in the thread.
  • a method of debugging a program thread having a sequence of instructions to be run by a processor, includes: substituting a breakpoint indicator for a selected part of at least one of the instructions; saving the selected part in a predetermined memory location; sequencing through the instructions until the breakpoint indicator is reached; reading the selected part from the predetermined memory location without overwriting the breakpoint indicator; performing at least one of a plurality of predetermined debugging operations.
  • a method of facilitating selective debugging of a plurality of program threads capable of being run by a processor includes: providing a running status indicator in a respective context for each of said threads; running each thread for which the status indicator is in a first state; not running each thread for which the status indicator is in a second state.
  • memory is intended to be interpreted as generally as is consistent with the manner in which it is used and includes volatile and nonvolatile devices of various types including, without limitation, RAMs, DRAMs, ROMs, registers and combinations of such devices.
  • a "dedicated" memory means that the memory has one or more specific locations which are known to the processor.
  • points need not be fixed, but may be changed under the control of the processor.
  • pointer means any value that identifies a memory location.
  • accessing means obtaining data from, or placing data into, a memory.
  • Figure 2 is a block diagram illustrating an exemplary processing system that is useful in explaining preferred embodiments of the invention.
  • FIGS. 3 A through 3E illustrate a breakpoint technique in accordance with an embodiment of the invention.
  • the processing system of Figure 2 includes a processor 10 and a memory 20.
  • the exemplary processor 10 is a hardware-accelerated unit, which utilizes clock pulses to sequence through instructions identified by a program counter register.
  • the program counter register contains the memory location of the next instruction to be read and acted upon by the processor.
  • the processor includes a context register set 12, an instruction decoder 14, an arithmetic logic unit 16, an SS OPCODE register 17, an SS TC PTR register 18, and a register 19 containing an OPCODE IS VALID flag.
  • the memory 20, in this exemplary embodiment, comprises a RAM having a multiplicity of memory locations for storing, inter alia, a plurality of thread contexts.
  • the processor 10 and the memory 20 are connected to a common bus 30 for communicating with each other and with other hardware that is connected to the bus.
  • the bus includes respective lines for carrying information such as addresses, interrupts, data, read strobes, write strobes and device-select strobes.
  • this is a high-speed bus which is at least partially formed on a common silicon substrate with the processor and the memory.
  • the context register set 12 comprises a plurality of registers for containing the context of the thread currently being run by the processor 10.
  • the register set 12 includes: a program counter register 121 containing a value PC which the processor continually updates to identify the address of the next instruction in the memory 20 to be accessed; a register 122 for holding a pointer TC PTR indicating a memory address where the context for the thread currently being run by the processor is to be stored; a register 123 for holding STATUS information associated with the thread currently being run by the processor; and one or more additional registers 125 for holding, inter alia, additional thread- context information and data which is either read from the memory 20 or produced by the arithmetic logic unit 16.
  • the instruction decoder 14 is a conventional hardware component, such as a sequencer or micro-sequencer, for converting the instructions read from the memory 20 to lower-level operation codes.
  • the arithmetic logic unit 16 is also a conventional hardware component.
  • FLAG register 19 are provided for holding information particularly relevant to breakpoint debugging. Specifically, register 17 holds an opcode from a thread that is being debugged (a debugee thread), register 18 holds a pointer SS TC PTR associated with the debugee thread, and register 19 holds a flag associated with register 17.
  • the processor runs one thread at a time (the current thread), but can be switched to any other thread by a variety of means, e.g. by an internal timer interrupt, by an external interrupt, or by an instruction in the current thread itself. As is well known in the art, this is typically done by storing the current thread context (held in context register set 12) into the memory address indicated by the pointer TC PTR contained in register 122. The processor then reads into the context register set 12 the respective context for the next thread to be run.
  • Figures 3 A through 3E generally illustrate an example of breakpoint debugging in accordance with an embodiment of the invention.
  • the same sequence of instructions that were utilized in the known technique illustrated in Figures 1A through IF are used in this example to facilitate comparison.
  • Figures 3 A through 3C are identical to Figures 1A through lC. That is, Figure 3 A illustrates the sequence before insertion of a breakpoint opcode; Figure 3B shows that the debugger has substituted the breakpoint opcode HALT; and Figure 3C depicts the instant when the processor has incremented the value PC in the program counter register 121 to the address where the HALT opcode is stored. At this time, the processor also stops running the thread and notifies the debugger that the breakpoint has been reached.
  • the debugger responds to notification of the HALT opcode by reading the value PC for the halted thread. Rather than writing opcode B (for which the HALT opcode had been substituted) over the HALT opcode, however, the processor writes opcode B into the SS OPCODE register 17, leaving the HALT opcode in the thread, and sets the OPCODE IS VALID flag. The processor then increments the program counter to indicate the location of the associated single-byte parameter Bl.
  • the processor reads the associated parameter Bl, increments the program counter to the address of opcode C, and executes the just-read instruction B.
  • breakpoint debugging is carried out depending on the options provided to the debugger and the number of threads that the processor is running.
  • the debugger is provided with the following options, all of which are available regardless of whether one or more threads is running: stop a running thread; single-step from a breakpoint or from a point other than a breakpoint; resume running from a breakpoint or from a point other than a breakpoint.
  • flags and commands are provided for use by the debugger and the processor, including: a RUNNING flag, contained in the STATUS information for each thread, which indicates whether the respective thread is running or stopped; an OPCODE IS VALID flag, contained in register 19 which: when set, indicates that an opcode awaiting execution has been loaded into the SS OPCODE register 17; when reset, indicates that the next instruction should be taken from the program stream; a SINGLE-STEP command, which will cause the processor to execute the next instruction only in a stopped thread; a RESUME command, which will cause the processor to resume running of a stopped thread.
  • each thread being debugged will stop upon the occurrence of a HALT opcode and the RUNNING flag for that thread will be reset.
  • the processor will continue to alternately process all threads, but each time it accesses the context for a stopped thread it will detect the reset state of the RUNNING flag in that thread's context and then do nothing until an interrupt occurs, causing the processor to switch to the next thread in sequence.
  • the debugger may be debugging one or more threads, each having one or more breakpoints set. To respond to the occurrence of a HALT at a breakpoint, the debugger must be able to locate the opcode for which the HALT opcode was substituted.
  • the debugger does this by having the processor notify it of the thread context address for the thread which processed the HALT instruction or by accessing the status register in the thread context for each debugee thread to sense the state of the RUNNING flags.
  • a reset i.e. stopped, state may exist for more than one debugee thread at a time. Stop a Running Thread
  • the debugger may choose to stop any thread which is running. To do this, the debugger will instruct the processor to load the SS TC PTR register 18 with a pointer identifying the memory location holding the context for the running debugee thread.
  • the debugger will then issue the HALT command, causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to facilitate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set 12 the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122); reset the RUNNING flag; save in memory the current context for the debugee thread that has just been stopped; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the pointer TC PTR in register 122.
  • the processor continues to cycle through all of the threads it is processing, but each time it reaches the context of the debugee thread it notes that the RUNNING flag in the STATUS information is still reset and does not run the debugee thread.
  • the debugger may choose to single step any thread which is stopped. To do this, the debugger will instruct the processor to load the SS TC PTR register 18 with a pointer identifying the memory location holding the context for the stopped debugee thread. The debugger will then read the program counter for the debugee thread to determine whether it was stopped at a breakpoint. If at a breakpoint, it will load into the SS OPCODE register 17 the opcode for which the HALT opcode had been substituted (e.g. opcode B in Fig. 3D) and will set the OPCODE IS VALID flag. If not at a breakpoint, the OPCODE IS VALID flag will have already been reset.
  • the opcode for which the HALT opcode had been substituted e.g. opcode B in Fig. 3D
  • the debugger will then issue the SINGLE-STEP command, causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to facilitate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set 12 the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122), which context includes the value PC for the breakpoint at which the HALT opcode resides; examine the OPCODE IS VALID flag to determine the source of the opcode to be used, i.e.
  • the saved context includes the value PC for the next instruction to be executed in the debugee thread and the RUNNING flag, which is still reset.
  • the processor continues to cycle through all of the threads it is processing, but each time it reaches the context of the debugee thread it notes that the RUNNING flag in the STATUS information is still reset and does not run the debugee thread.
  • the debugger may choose to resume the running of any thread which is stopped. To do this, the debugger will instruct the processor to load the SS TC PTR register 18 with a pointer identifying the memory location holding the context for the stopped debugee thread.
  • the debugger will then read the program counter for the debugee thread to determine whether it was stopped at a breakpoint.
  • the debugger will then issue the RESUME command, causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to facilitate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122), which context includes the value PC for the breakpoint at which the HALT opcode resides; examine the OPCODE IS VALID flag to determine the source of the opcode to be used, i.e.
  • opcode C in Figure 3E save in memory the current context for the debugee thread; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the pointer TC PTR in register 122.
  • the OPCODE IS VALID flag will have already been reset.
  • the debugger will then issue the RESUME command causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to faciliate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122), which context includes the value PC for the next opcode in the thread; set the RUNNING flag in the STATUS information contained in register 123 ; save in memory the current context for the debugee thread; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the
  • the saved context includes the value PC for the next instruction to be executed in the debugee thread and the RUNNING flag (which is now set).
  • the processor continues to cycle through all of the threads it is processing, and each time it reaches the context of the debugee thread it notes that the RUNNING flag in the STATUS information is set and runs the debugee thread.

Abstract

A method is provided for debugging a program thread without overwriting a breakpoint indicator that is substituted in the thread for an opcode of the thread. After reaching the breakpoint, the opcode is read into a dedicated register for utilization. A method is also provided for facilitating debugging of a thread while allowing at least one other thread to continue running.

Description

Thread-oriented debugging
BACKGROUND OF THE INVENTION
1. Field of the Invention
The invention relates to the debugging of computer programs and, in particular, to the capability of debugging multiple threads.
2. Description of Related Art
Many different techniques are used for facilitating the debugging of computer programs. One common technique is to stop the running of a program thread (i.e. a sequence of instructions) upon the occurrence of a predetermined event and to examine the contents of various memory locations, e.g. registers, addresses in RAM, etc. A very useful device for stopping a thread in this manner is the breakpoint.
Breakpoints for stopping execution of a currently-running thread can be set to occur in a variety of ways. Examples include breakpoints that occur when a specific instruction is executed and breakpoints that occur when a specific memory location is accessed. A representative example of using a specific-instruction type of breakpoint is illustrated in Figures 1 A through IF.
Figure 1A illustrates a sequence of instructions in a thread to be debugged. Each of the instructions includes an opcode followed by any parameters (e.g. operands, addresses, data etc.) that are associated with the respective instruction. Typically, each opcode is one byte long. In this example, the sequence includes three instructions, i.e.:
Instruction A, comprising opcode A followed by two associated paramaters Al and A2;
Instruction B, comprising opcode B followed by one associated parameter Bl; and Instruction C, comprising opcode C followed by two associated parameters Cl and C2.
Conventionally, each of these instructions is read and executed in the sequence shown under the control of a program counter in a processor. Figure IB shows how a breakpoint is set in the thread to be debugged. Specifically, a HALT opcode is substituted by the debugger in place of opcode B.
Figure 1 C depicts the instant when the processor has executed Instruction A and has incremented the value PC in the program counter to the address where the HALT opcode is stored. At this time, the processor stops running the thread and directly or indirectly notifies the debugger that the breakpoint has been reached. This can be done in a variety of ways, e.g. by the processor activating an interrupt to the debugger or by the debugger periodically polling the state of the processor to detect that the processor has reached a HALT opcode. As is depicted in Figure ID, the debugger responds to notification of the
HALT opcode by reading the value PC for the halted thread to determine which one (of possibly many) breakpoints has been reached. The debugger then writes the corresponding opcode (i.e. "opcode B", for which the HALT opcode had been substituted in Figure IB) into the memory 20 and commands the processor to execute the next instruction. In executing this instruction, the processor will read the newly- written opcode B and increment the program counter to indicate the location of the associated single-byte parameter Bl.
As is depicted in Figure IE, the processor then reads the associated parameter Bl and increments the program counter to the address of opcode C. On completion of instruction B, the processor stops and the debugger regains control. As is depicted in Figure IF, after the processor executes Instruction B, but before it reads opcode C, the debugger re-substitutes the HALT opcode for opcode B in the program stream. This is necessary to retain the breakpoint in the thread.
From the example shown in Figure 1 , it can be seen that breakpoint debugging of even a single thread can be a complicated and time consuming process.
SUMMARY OF THE INVENTION
It is an object of the invention to provide a method of breakpoint debugging that is simpler and less and time consuming than known breakpoint debugging techniques.
It is yet another object of the invention to provide a method of debugging which, in a multi -threaded software environment, facilitates debugging of one thread while allowing other threads to continue running.
In accordance with one form of the invention, a method of debugging a program thread, having a sequence of instructions to be run by a processor, includes: substituting a breakpoint indicator for a selected part of at least one of the instructions; saving the selected part in a predetermined memory location; sequencing through the instructions until the breakpoint indicator is reached; reading the selected part from the predetermined memory location without overwriting the breakpoint indicator; performing at least one of a plurality of predetermined debugging operations.
In accordance with another form of the invention, a method of facilitating selective debugging of a plurality of program threads capable of being run by a processor includes: providing a running status indicator in a respective context for each of said threads; running each thread for which the status indicator is in a first state; not running each thread for which the status indicator is in a second state. Note that the word "memory", as used herein, is intended to be interpreted as generally as is consistent with the manner in which it is used and includes volatile and nonvolatile devices of various types including, without limitation, RAMs, DRAMs, ROMs, registers and combinations of such devices. A "dedicated" memory means that the memory has one or more specific locations which are known to the processor. However, these locations need not be fixed, but may be changed under the control of the processor. Also, as used herein, the word "pointer" means any value that identifies a memory location. Additionally, "accessing" data means obtaining data from, or placing data into, a memory.
BRIEF DESCRIPTION OF THE DRAWING Figures 1 A through IF illustrate a known breakpoint technique.
Figure 2 is a block diagram illustrating an exemplary processing system that is useful in explaining preferred embodiments of the invention.
Figures 3 A through 3E illustrate a breakpoint technique in accordance with an embodiment of the invention.
DESCRIPTION OF THE PREFERRED EMBODIMENTS
The processing system of Figure 2 includes a processor 10 and a memory 20. The exemplary processor 10 is a hardware-accelerated unit, which utilizes clock pulses to sequence through instructions identified by a program counter register. Typically, the program counter register contains the memory location of the next instruction to be read and acted upon by the processor.
The processor includes a context register set 12, an instruction decoder 14, an arithmetic logic unit 16, an SS OPCODE register 17, an SS TC PTR register 18, and a register 19 containing an OPCODE IS VALID flag. The memory 20, in this exemplary embodiment, comprises a RAM having a multiplicity of memory locations for storing, inter alia, a plurality of thread contexts.
The processor 10 and the memory 20 are connected to a common bus 30 for communicating with each other and with other hardware that is connected to the bus. The bus includes respective lines for carrying information such as addresses, interrupts, data, read strobes, write strobes and device-select strobes. Preferably, this is a high-speed bus which is at least partially formed on a common silicon substrate with the processor and the memory.
The context register set 12 comprises a plurality of registers for containing the context of the thread currently being run by the processor 10. In the preferred embodiment, the register set 12 includes: a program counter register 121 containing a value PC which the processor continually updates to identify the address of the next instruction in the memory 20 to be accessed; a register 122 for holding a pointer TC PTR indicating a memory address where the context for the thread currently being run by the processor is to be stored; a register 123 for holding STATUS information associated with the thread currently being run by the processor; and one or more additional registers 125 for holding, inter alia, additional thread- context information and data which is either read from the memory 20 or produced by the arithmetic logic unit 16.
The instruction decoder 14 is a conventional hardware component, such as a sequencer or micro-sequencer, for converting the instructions read from the memory 20 to lower-level operation codes. The arithmetic logic unit 16 is also a conventional hardware component. The SS OPCODE register 17, the SS TC PTR register 18, and the SS OP
FLAG register 19 are provided for holding information particularly relevant to breakpoint debugging. Specifically, register 17 holds an opcode from a thread that is being debugged (a debugee thread), register 18 holds a pointer SS TC PTR associated with the debugee thread, and register 19 holds a flag associated with register 17. In operation, the processor runs one thread at a time (the current thread), but can be switched to any other thread by a variety of means, e.g. by an internal timer interrupt, by an external interrupt, or by an instruction in the current thread itself. As is well known in the art, this is typically done by storing the current thread context (held in context register set 12) into the memory address indicated by the pointer TC PTR contained in register 122. The processor then reads into the context register set 12 the respective context for the next thread to be run.
Figures 3 A through 3E generally illustrate an example of breakpoint debugging in accordance with an embodiment of the invention. The same sequence of instructions that were utilized in the known technique illustrated in Figures 1A through IF are used in this example to facilitate comparison.
Figures 3 A through 3C are identical to Figures 1A through lC. That is, Figure 3 A illustrates the sequence before insertion of a breakpoint opcode; Figure 3B shows that the debugger has substituted the breakpoint opcode HALT; and Figure 3C depicts the instant when the processor has incremented the value PC in the program counter register 121 to the address where the HALT opcode is stored. At this time, the processor also stops running the thread and notifies the debugger that the breakpoint has been reached.
As is depicted in Figure 3D, the debugger responds to notification of the HALT opcode by reading the value PC for the halted thread. Rather than writing opcode B (for which the HALT opcode had been substituted) over the HALT opcode, however, the processor writes opcode B into the SS OPCODE register 17, leaving the HALT opcode in the thread, and sets the OPCODE IS VALID flag. The processor then increments the program counter to indicate the location of the associated single-byte parameter Bl.
As is depicted in Figure 3E, the processor reads the associated parameter Bl, increments the program counter to the address of opcode C, and executes the just-read instruction B.
All of the steps which would have been needed to re-substitute the HALT opcode for opcode B are thus eliminated. This typically includes halting the processor on completion of instruction B, over-writing opcode B with the HALT opcode, and then resuming running of the stopped thread or a different thread.
The specific manner in which breakpoint debugging is carried out will depend on the options provided to the debugger and the number of threads that the processor is running. In accordance with a preferred embodiment of the invention, the debugger is provided with the following options, all of which are available regardless of whether one or more threads is running: stop a running thread; single-step from a breakpoint or from a point other than a breakpoint; resume running from a breakpoint or from a point other than a breakpoint.
In order to facilitate these options, flags and commands are provided for use by the debugger and the processor, including: a RUNNING flag, contained in the STATUS information for each thread, which indicates whether the respective thread is running or stopped; an OPCODE IS VALID flag, contained in register 19 which: when set, indicates that an opcode awaiting execution has been loaded into the SS OPCODE register 17; when reset, indicates that the next instruction should be taken from the program stream; a SINGLE-STEP command, which will cause the processor to execute the next instruction only in a stopped thread; a RESUME command, which will cause the processor to resume running of a stopped thread.
If more than one thread is running, each thread being debugged will stop upon the occurrence of a HALT opcode and the RUNNING flag for that thread will be reset. The processor will continue to alternately process all threads, but each time it accesses the context for a stopped thread it will detect the reset state of the RUNNING flag in that thread's context and then do nothing until an interrupt occurs, causing the processor to switch to the next thread in sequence. The debugger may be debugging one or more threads, each having one or more breakpoints set. To respond to the occurrence of a HALT at a breakpoint, the debugger must be able to locate the opcode for which the HALT opcode was substituted. Preferably the debugger does this by having the processor notify it of the thread context address for the thread which processed the HALT instruction or by accessing the status register in the thread context for each debugee thread to sense the state of the RUNNING flags. Note that a reset, i.e. stopped, state may exist for more than one debugee thread at a time. Stop a Running Thread The debugger may choose to stop any thread which is running. To do this, the debugger will instruct the processor to load the SS TC PTR register 18 with a pointer identifying the memory location holding the context for the running debugee thread. The debugger will then issue the HALT command, causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to facilitate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set 12 the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122); reset the RUNNING flag; save in memory the current context for the debugee thread that has just been stopped; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the pointer TC PTR in register 122. Note that the saved context in the debugee thread has the RUNNING flag reset. Thus the processor continues to cycle through all of the threads it is processing, but each time it reaches the context of the debugee thread it notes that the RUNNING flag in the STATUS information is still reset and does not run the debugee thread.
Single-step
The debugger may choose to single step any thread which is stopped. To do this, the debugger will instruct the processor to load the SS TC PTR register 18 with a pointer identifying the memory location holding the context for the stopped debugee thread. The debugger will then read the program counter for the debugee thread to determine whether it was stopped at a breakpoint. If at a breakpoint, it will load into the SS OPCODE register 17 the opcode for which the HALT opcode had been substituted (e.g. opcode B in Fig. 3D) and will set the OPCODE IS VALID flag. If not at a breakpoint, the OPCODE IS VALID flag will have already been reset. The debugger will then issue the SINGLE-STEP command, causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to facilitate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set 12 the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122), which context includes the value PC for the breakpoint at which the HALT opcode resides; examine the OPCODE IS VALID flag to determine the source of the opcode to be used, i.e. from register 17 if the flag is set or from the program stream if the flag is reset; reset the OPCODE IS VALID flag to indicate that no opcode awaiting execution is in register 17; increment the value PC in register 121 (e.g. to the address of parameter Bl in Fig. 3D); read the parameter(s), if any, at the incremented value PC (e.g. the parameter Bl); repeat the last two steps as necessary to read any additional parameter(s) associated with the opcode read from register 17; execute the complete instruction formed from the just-read opcode, and any parameter(s) associated with it, and then increment the value PC to the next opcode (e.g. opcode C in Figure 3E); save in memory the current context for the debugee thread that has just been single stepped; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the pointer TC PTR in register 122.
Note that the saved context includes the value PC for the next instruction to be executed in the debugee thread and the RUNNING flag, which is still reset. Thus the processor continues to cycle through all of the threads it is processing, but each time it reaches the context of the debugee thread it notes that the RUNNING flag in the STATUS information is still reset and does not run the debugee thread.
Resume Running The debugger may choose to resume the running of any thread which is stopped. To do this, the debugger will instruct the processor to load the SS TC PTR register 18 with a pointer identifying the memory location holding the context for the stopped debugee thread.
The debugger will then read the program counter for the debugee thread to determine whether it was stopped at a breakpoint.
If at a breakpoint, it will load into the SS OPCODE register 17 the opcode for which the HALT opcode had been substituted (e.g. opcode B in Fig. 3D) and will set the OPCODE IS VALID flag.
The debugger will then issue the RESUME command, causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to facilitate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122), which context includes the value PC for the breakpoint at which the HALT opcode resides; examine the OPCODE IS VALID flag to determine the source of the opcode to be used, i.e. from register 17 if the flag is set or from the program stream if the flag is reset; reset the OPCODE IS VALID flag to indicate that no opcode awaiting execution is in register 17; increment the value PC in register 121 (e.g. to the address of parameter Bl in Fig. 3D); read any parameter(s) at the incremented value PC (e.g. the parameter Bl); repeat the last two steps as necessary to read any additional parameter(s) associated with the opcode read from register 17; set the RUNNING flag in the STATUS information contained in register 123; execute the complete instruction formed from the just-read opcode, and any parameter(s) associated with it, and then increment the value PC to the next opcode (e.g. opcode C in Figure 3E); save in memory the current context for the debugee thread; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the pointer TC PTR in register 122.
Alternatively, if not at a breakpoint, the OPCODE IS VALID flag will have already been reset. The debugger will then issue the RESUME command causing the processor to: save the context of any currently-running thread in the memory address indicated by the pointer TC PTR which is currently in register 122; copy the contents of register 122 into register 18 (to faciliate later re- installation of the just-running thread) and copy the contents of register 18 (the pointer SS TC PTR) into register 122; read into the context register set the debugee context located at the memory address identified by the pointer SS TC PTR (now in register 122), which context includes the value PC for the next opcode in the thread; set the RUNNING flag in the STATUS information contained in register 123 ; save in memory the current context for the debugee thread; copy the contents of register 18 into register 122, to effect re-installation of the previously-running thread; read into the context register set 12 the thread context located at the memory address identified by the pointer TC PTR in register 122.
Note that the saved context includes the value PC for the next instruction to be executed in the debugee thread and the RUNNING flag (which is now set). Thus the processor continues to cycle through all of the threads it is processing, and each time it reaches the context of the debugee thread it notes that the RUNNING flag in the STATUS information is set and runs the debugee thread.

Claims

CLAIMS:
1. A method of debugging a program thread comprising a sequence of instructions to be run by a processor (10), said method comprising: a. substituting a breakpoint indicator (HALT) for a selected part (opcode B) of at least one of the instructions; b. saving the selected part (opcode B)in memory; c. sequencing through the instructions until the breakpoint indicator (HALT) is reached; d. reading the selected part (opcode B) from memory without overwriting the breakpoint indicator (HALT); e. performing at least one of a plurality of predetermined debugging operations.
2. A method as in claim 1 where the selected part is saved in and read from a predetermined memory location.
3. A method as in claim 1 where the selected part comprises an opcode.
4. A method as in claim 1 where the selected part comprises a HALT opcode for stopping running of the thread.
5. A method as in claim 1 where the predetermined debugging operations include: a. halting the running of the program thread at the breakpoint; b. single-stepping a halted thread; c. resuming running of a halted thread.
6. A method as in claim 1 where a flag is provided to indicate whether the selected part has been read into the dedicated memory and is awaiting utilization.
7. A method of facilitating selective debugging of a plurality of program threads capable of being run by a processor, said method comprising: a. providing a running status indicator in a respective context for each of said threads; b. running each thread for which the status indicator is in a first state; c. not running each thread for which the status indicator is in a second state.
8. A method as in claim 7 where a debugger utilizes the running status indicator to select a thread for debugging while allowing at least one other thread to continue running.
EP00962354A 1999-09-07 2000-08-21 Method of debugging a program thread Expired - Lifetime EP1125199B1 (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
US39085399A 1999-09-07 1999-09-07
US390853 1999-09-07
PCT/EP2000/008183 WO2001018651A1 (en) 1999-09-07 2000-08-21 Thread-oriented debugging

Publications (2)

Publication Number Publication Date
EP1125199A1 true EP1125199A1 (en) 2001-08-22
EP1125199B1 EP1125199B1 (en) 2004-05-19

Family

ID=23544212

Family Applications (1)

Application Number Title Priority Date Filing Date
EP00962354A Expired - Lifetime EP1125199B1 (en) 1999-09-07 2000-08-21 Method of debugging a program thread

Country Status (7)

Country Link
EP (1) EP1125199B1 (en)
JP (1) JP2003508864A (en)
KR (1) KR20010085997A (en)
CN (1) CN1148656C (en)
DE (1) DE60010847T2 (en)
TW (1) TW518460B (en)
WO (1) WO2001018651A1 (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100952762B1 (en) * 2003-02-27 2010-04-14 엘지전자 주식회사 Real-time debugging method of digital signal processor
GB0420442D0 (en) * 2004-09-14 2004-10-20 Ignios Ltd Debug in a multicore architecture
CN100389565C (en) * 2005-03-08 2008-05-21 华为技术有限公司 Analytic method of expression type
US8370806B2 (en) * 2006-11-15 2013-02-05 Qualcomm Incorporated Non-intrusive, thread-selective, debugging method and system for a multi-thread digital signal processor
US7657791B2 (en) 2006-11-15 2010-02-02 Qualcomm Incorporated Method and system for a digital signal processor debugging during power transitions
US8341604B2 (en) * 2006-11-15 2012-12-25 Qualcomm Incorporated Embedded trace macrocell for enhanced digital signal processor debugging operations
US8484516B2 (en) 2007-04-11 2013-07-09 Qualcomm Incorporated Inter-thread trace alignment method and system for a multi-threaded processor
CN101295279B (en) * 2007-04-29 2012-05-09 国际商业机器公司 Method and system for debugging program in multi-threading surroundings
GB2489000B (en) * 2011-03-14 2019-09-11 Advanced Risc Mach Ltd Diagnosing code using single step execution
CN107818043A (en) * 2016-09-13 2018-03-20 东华软件股份公司 Method and apparatus for program debugging
CN110489294B (en) * 2019-08-23 2023-12-19 上海光电医用电子仪器有限公司 Real-time single-step debugging method and device based on log

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See references of WO0118651A1 *

Also Published As

Publication number Publication date
DE60010847D1 (en) 2004-06-24
WO2001018651A1 (en) 2001-03-15
CN1148656C (en) 2004-05-05
CN1335962A (en) 2002-02-13
EP1125199B1 (en) 2004-05-19
DE60010847T2 (en) 2005-06-16
TW518460B (en) 2003-01-21
KR20010085997A (en) 2001-09-07
JP2003508864A (en) 2003-03-04

Similar Documents

Publication Publication Date Title
US6539500B1 (en) System and method for tracing
KR100350568B1 (en) Data processing system and method for performing debug functions
US5964893A (en) Data processing system for performing a trace function and method therefor
US6915416B2 (en) Apparatus and method for microcontroller debugging
US5704034A (en) Method and circuit for initializing a data processing system
US6026501A (en) Data processing system for controlling execution of a debug function and method thereof
KR0168656B1 (en) Data processing system
KR960011613A (en) Data processing device
EP0702297B1 (en) A data processor with breakpoint circuit
US20070226740A1 (en) Method and apparatus for global breakpoint for parallel debugging on multiprocessor systems
KR100309615B1 (en) High Speed Programmable Logic Controllers (PLC)
US7793160B1 (en) Systems and methods for tracing errors
EP1125199B1 (en) Method of debugging a program thread
KR900004291B1 (en) A method and apparatus for coordinating exceution of an instruction by a processor
US6347368B1 (en) Microcomputing device for exchanging data while executing an application
US7831979B2 (en) Processor with instruction-based interrupt handling
EP0720087A1 (en) Apparatus and method for a memory extension stack in a data processing system
US8352714B2 (en) Executing watchpoint instruction in pipeline stages with temporary registers for storing intermediate values and halting processing before updating permanent registers
JPH0283749A (en) Internal interruption control system for microprocessor
JPH0581087A (en) Processor monitoring system
JP2675506B2 (en) Microprocessor device
JP2711159B2 (en) Processor operation state adjustment method
JPH04199336A (en) Microcomputer
JPH0795288B2 (en) Microcomputer
GB2380831A (en) Debug exception handler and registers

Legal Events

Date Code Title Description
PUAI Public reference made under article 153(3) epc to a published international application that has entered the european phase

Free format text: ORIGINAL CODE: 0009012

AK Designated contracting states

Kind code of ref document: A1

Designated state(s): AT BE CH CY DE DK ES FI FR GB GR IE IT LI LU MC NL PT SE

AX Request for extension of the european patent

Free format text: AL;LT;LV;MK;RO;SI

17P Request for examination filed

Effective date: 20010917

17Q First examination report despatched

Effective date: 20030124

RTI1 Title (correction)

Free format text: METHOD OF DEBUGGING A PROGRAM THREAD

GRAP Despatch of communication of intention to grant a patent

Free format text: ORIGINAL CODE: EPIDOSNIGR1

GRAS Grant fee paid

Free format text: ORIGINAL CODE: EPIDOSNIGR3

GRAA (expected) grant

Free format text: ORIGINAL CODE: 0009210

AK Designated contracting states

Kind code of ref document: B1

Designated state(s): DE FR GB

REG Reference to a national code

Ref country code: GB

Ref legal event code: FG4D

REG Reference to a national code

Ref country code: IE

Ref legal event code: FG4D

REF Corresponds to:

Ref document number: 60010847

Country of ref document: DE

Date of ref document: 20040624

Kind code of ref document: P

PGFP Annual fee paid to national office [announced via postgrant information from national office to epo]

Ref country code: GB

Payment date: 20040826

Year of fee payment: 5

PGFP Annual fee paid to national office [announced via postgrant information from national office to epo]

Ref country code: FR

Payment date: 20040830

Year of fee payment: 5

PGFP Annual fee paid to national office [announced via postgrant information from national office to epo]

Ref country code: DE

Payment date: 20041015

Year of fee payment: 5

LTIE Lt: invalidation of european patent or patent extension

Effective date: 20040519

ET Fr: translation filed
PLBE No opposition filed within time limit

Free format text: ORIGINAL CODE: 0009261

STAA Information on the status of an ep patent application or granted ep patent

Free format text: STATUS: NO OPPOSITION FILED WITHIN TIME LIMIT

26N No opposition filed

Effective date: 20050222

REG Reference to a national code

Ref country code: IE

Ref legal event code: MM4A

PG25 Lapsed in a contracting state [announced via postgrant information from national office to epo]

Ref country code: GB

Free format text: LAPSE BECAUSE OF NON-PAYMENT OF DUE FEES

Effective date: 20050821

PG25 Lapsed in a contracting state [announced via postgrant information from national office to epo]

Ref country code: DE

Free format text: LAPSE BECAUSE OF NON-PAYMENT OF DUE FEES

Effective date: 20060301

GBPC Gb: european patent ceased through non-payment of renewal fee

Effective date: 20050821

PG25 Lapsed in a contracting state [announced via postgrant information from national office to epo]

Ref country code: FR

Free format text: LAPSE BECAUSE OF NON-PAYMENT OF DUE FEES

Effective date: 20050831

REG Reference to a national code

Ref country code: FR

Ref legal event code: ST

Effective date: 20111007