Method and apparatus for marking emulation analysis states

Abstract: Additional memory (38) for holding marking tags is used for providing additional information regarding states acquired by an emulator during tracing for dequeueing. The marking tags are determined according to a predetermined coding scheme, loaded in a marking memory (38), and acquired during tracing along with the fetched instruction states. The combination of addresses, data, status, and the additional marking tags is converted into a list of states which correspond to the test program executed by the target processor means (52).

Description: Background of the Invention This invention relates to emulation systems (emulators) used for developing microprocessor-based systems, and specifically to techniques and hardware for providing additional marking in memory to emulation analysis states used in emulators for analysis purposes during dequeueing and tracing operations. Emulators aid the development of microprocessor-based systems (target systems) by providing means for designers to load and run software (target programs) before any hardware is built. The emulator may substitute for part or all of the target system. Emulators may be connected to the target system at any point in the system's development. Figure 1 is a block diagram of a generic microprocessor-based system, having microprocessor 10, memory 12, and input/output device 14. Figure 2 is a block diagram of an emulation system, having emulator 18, host computer 20, and user terminal 22. Figure 3 is a block diagram of an emulator connected to a microprocessor-based system. The emulator is plugged into the microprocessor socket 16 in the target system in place of microprocessor 10 shown in Figure 1, and is supported by host computer 20. The emulator provides the microprocessor functions and some of the memory for the target system, since the user may not have any or all the target system memory functioning. As the development approaches completion, functions performed by the emulator are gradually transferred to the target system. During the development, the emulator provides additional microprocessor controls not usually available which are useful for troubleshooting target software problems, including: single stepping, break points for certain memory addresses, break points on improper memory accesses, displaying and modifying internal registers, etc. One particular microprocessor control which is useful is called "instruction analysis". Instruction analysis consists of "tracing", which is the acquisition of a collection of states during execution of a target program; and disassembly, which is the analysis of the acquired collection of states following the execution of the target program by the microprocessor. Instruction analysis attempts to recreate the actual instruction process. The standard method of acquisition examines the instructions fetched prior to execution to acquire state information, which usually includes the address, data and status information of a single microprocessor cycle. However, there may be a significant difference between the instructions that are fetched and the instructions that are executed. The process of attempting to recreate instruction execution from instruction fetches is called "dequeueing". One dequeueing method taught in the prior was called "hardware dequeueing". This method of dequeueing was an attempt to recreate the microprocessor queue with circuitry. This was difficult to accomplish, therefore time consuming and expensive, and not always accurate. Each hardware dequeuer was dependent upon the architecture of the target processor and consequently this difficult task was repeated for every design of a new emulator. Critical information about microprocessor architecture required for design was often not available, and many other processors had queues which could not be recreated in this manner. A second dequeueing method taught in the prior art was known as "software dequeueing". This method of dequeueing would attempt to recreate the microprocessor queue by decoding the instruction fetch information captured in a trace. This method was substantially cheaper to implement than the hardware method of dequeueing, but had severe accuracy problems. A major reason for accuracy degradation was difficulty in dequeueing branch or conditional branch instructions, because branches in a queued microprocessor caused multiple unused instruction fetches, which resulted in the execution of instructions in a different order than the instruction fetch order. Other instructions included single words, double words, or long words (quadruple words), and instructions which had an argument (operand) associated with the instruction (as in an "add constant" instruction). Since decoding of the instruction fetch information typically began at a point chosen within the target program by the user, there was no method of determining that the first word was also the beginning of an instruction. If the first word was not the beginning of an instruction, the dequeuer would regardless interpret it as the beginning of an instruction. The frequent result was that the decoded instruction fetch information bore little resemblance to what was actually being executed by the processor in the target program. Consequently, the "software dequeueing" solution, although much less expensive than the "hardware dequeueing" solution was extremely unreliable. US-A-4205370 discloses a data processing system which includes means that are operative when the system is conditioned for operating in a trace mode during the processing of program instructions, to record the opcode of each instruction designed as executable by the bit contents of a table referenced before beginning instruction execution. When the opcode of an instruction is designed by the table as not being executable, the system traps the instruction and generates a call to the operating system software without recording its opcode. The selective recording and trapping of instruction operation codes facilitates diagnosis of program errors or faults within the system. This is particularly valuable when the system includes emulation apparatus which may not be completely compatible in every detail with the system being emulated. Summary of the Invention The features of the invention are defined by respective Claims 1 and 5. In accordance with the preferred embodiment of the present invention, improved instruction analysis in emulators results from providing additional memory in an emulator which hold marks determined according to a predetermined coding scheme corresponding to instructions from a target program; the marks provide additional state information to the host controller of the emulator during instruction analysis for more accurate conversion of state information generated during target processor execution of the target program into a list of states which correspond to the test program executed by the target processor means. The marking system may be applied to any processor and according to any predetermined coding scheme such that the maximum results may be achieved with a minimum of additional cost. The additional cost of the memory and the necessary software for marking is low, therefore providing an advantage over the relatively high cost prior art hardware dequeueing solution; while the accuracy of the resulting trace information approaches that of the hardware dequeueing solution, providing an advantage over the prior art software dequeueing solution. Brief Description of the Drawings Figure 1 is a block diagram of a generic microprocessor-based system under development (target system). Figure 2 is a block diagram of an emulation system (emulator). Figure 3 is a block diagram which shows an emulation system connected to a microprocessor-based system under development. Figure 4 shows a block diagram of the preferred embodiment of an emulator having marking hardware. Figure 5 shows a flowchart of the marking software options module. Figure 6 shows a flowchart of the marking software syntax module. Figure 7 shows a flowchart of the marking software state machine module. Figure 8 shows a flowchart of the marking software disassembly module. Detailed Description of the Preferred Embodiment Figure 4 shows a block diagram of the preferred embodiment of an emulator having marking hardware. The description of each block is provided below. Host controller decoding block 24. This block receives host controller commands and generates appropriate signals for various blocks in the emulator. For example, if a load mark command is sent to this block, it will generate a write strobe to a dual port access control 34, a mark address block signal to the address selection block 40, and an enable signal to the mark memory block 38. This block also reads status from the control register and status block 28 and can write information to the control register of the same block. ROM module 26 (emulator specific) . This block contains all of the emulator specific software necessary to operate the emulator. For example, all of the marking specific software is present in this ROM, as well as software to generate breaks, read registers, configure the emulator, and so on. Control register and status buffer 28. This block contains the emulator control register, which configures the emulator for various modes of operation. For example, it contains the reset signal, which will place the emulator in a initialized (reset) state when the signal is asserted. This block also contains the status register, which can be read any time by the host controller decoding block 24 to determine what state the emulator is in (for example, running in foreground or reset in background). Analyzer 30. This block receives the addresses, data and status emitted by the processor 52 (80C196) for storage and later examination. It also receives the marks emitted by the mark memory, which provides substantial information on opcode location. Host data buffers/latches 32. This block works in conjunction with the dual port memory access control to allow the host controller to access the same memory that the processor 52, which for this embodiment is a 80C196, can access. It buffers and latches host controller data to the various memory blocks for use at the appropriate time. Dual port access control 34. This block arbitrates the accesses from the host controller and the processor 52 so both can gain access to the various memory blocks, such as the emulation memory 36 and monitor memory 42. It generates the read and write strobes to the memory blocks and also generates the required timing wait signals back to the requesting blocks. Emulation memory 36. This block contains the memory used when the processor is running in foreground emulation memory. Mark memory 38. This block contains the memory used to hold the mark tags. This memory is loaded only by the host controller decoding block 24 (the 80C196 processor 52 cannot write to it) and is read only by the analyzer 30. The host controller decoding block 24 loads the mark tags at specific addresses of the mark memory 38, so when the processor 52 puts out identical addresses, the desired mark tags will be sent to the analyzer 30. Mark memory 38 is initialized to null tag values (unmarked) when the emulator is initialized or if an emulation memory location is modified after being marked. Address selection block 40. This block works in conjunction with the dual port access control 34 to provide valid addresses to the various memory blocks at the appropriate times. It will select the correct memory block to write to and the address appropriate for that block. Monitor memory 42. This block contains the memory used when the processor 52 is running in background emulation memory. This memory contains the monitor code and contains the communication memory area used to communicate with the host controller decoding 24. Monitor mark memory 44. This block contains marks which are used for proper operation of the monitor. Signals in this memory 44 control accesses to foreground memory while in the monitor and also control exit from the monitor (background) state. Coverage memory 46. This memory block contains information about address location access status. It can be reset by the host controller decoding block 24. Processor data buffers/latches 48. This block works in conjunction with the dual port memory access control 34 to allow the 80C196 processor 52 to access the same memory that the host controller decoding 24 can access. It buffers and latches 80C196 processor data to the various memory blocks for use at the appropriate time. Processor strobe generator 50. This block intercepts the processor strobes to generate strobes with more appropriate timing and function for use throughout the emulator, such as timing strobes for the dual port access control 34 and for the analyzer Processor 52 (80C196). This is the target processor which runs the target program as well as the monitor and other functions. Break control 54. This block can cause interruption of execution of the user's code at desired times to perform monitoring of registers and memory or to perform modification of the current state of the 80C196 processor 52. The interruption is carefully done so that restoration of the current state can be accomplished when exiting the monitor (background) state. Port replication 54. This block simulates the operation of the 80C196 processor port pins by duplicating internal functionality of the processor 52. This allows the emulator user probe to functionally act as the 80C196 processor 52 would while other functions are actually going on internally in the emulator. User probe buffers/latches 58. This block does the necessary memory address/data bus control to permit execution of code which is resident on the users target system (the system that the emulator is plugged into). User probe 60. This is the physical unit which plugs into the users target system. The user removes the 80C196 processor from his target system and plugs the user probe 60 of the emulator in its place. The preferred embodiment of the marking hardware uses four distinct software blocks for creating and interpreting marks. An options module is used to define various options for use in creating the marks. Two modules are used in creating the marks: a syntax module for testing for appropriate ranges of addresses; and a state machine module for extracting opcode information, generating marks, and storing the marks in memory at the appropriate locations. A marking software disassembly module is the fourth module and is used for extracting the marks and using it to generate disassembled opcode information. Figure 5 shows a flowchart of the options module. This module is invoked by the inverse assembler prior to disassembling the analysis states to implement the various options chosen by the user. After the user accesses the module (block 62), the options variables are checked to determine if a change has been made to the inverse assembly configuration (block 64). If the options variables are not set, no change is made to the inverse assembly configuration (block 68), and the options module terminates (block 70). If the options variables are set, the variables are then tested to determine if the chosen options are legal (block 66). If the options variables are not legal, then no change is made to the inverse assembly configuration (block 72), an error is indicated to the user, and the options module terminates (block 74). If the options variables are valid, then the appropriate inverse assembler flag variables are changed (block 76) and the options module terminates (block 78). Figure 6 shows a flowchart of the syntax module. If a mark command is implemented, the syntax module is called (block 80). First, the parameters of the command are acquired (block 82), and a check is made for valid address ranges (block 84). If the ranges are not valid, the command is aborted, an error is indicated to the user, and the syntax module terminates (block 86). If the ranges are valid, the marking software state machine module is called (block 88). If the state machine module returns an error condition from a problem within the state machine module, an error is indicated to the user and the command is aborted (block 90). If no error is returned by the state machine, the state machine module returns after placing the appropriate marks in memory for the range of addresses. The syntax module determines if additional ranges of memory are specified to be marked (block 92). If additional ranges of memory are to be marked, the validity of the ranges is determined (block 84). If no additional ranges of memory are to be marked, the syntax module indicates no error to the user, and terminates (block 94). Figure 7 shows a flowchart of the marking software state machine module. After this module is called by the syntax module described above (block 96), the mark pointer is initialized to the beginning address for the range of addresses to be marked, or start address (block 98). The read pointer is also initialized to the start address (block 100). The opcode information is extracted from the location indicated by the read pointer (block 102) and the appropriate mark code is generated by referencing a lookup table (block 104). This lookup table contains a predetermined coding scheme for marking emulation analysis states. For this embodiment, the processor is assumed to use two bytes for a maximum size instruction fetch, and three bits are used for marking with the following definitions: 000 - null (has not been marked or has been affected) 001 - low byte is the only opcode 010 - high byte is the only opcode 011 - both bytes are opcodes 100 - neither byte is an opcode but it is marked (operand) The remaining definitions are not used. If the opcode is not valid, the mark command is aborted and an error is returned to the syntax module (block 106). If the opcode is valid, the referenced mark is loaded into mark memory at the location of the mark pointer (block 108). If the opcode information extracted is a valid non-opcode (operand), then non-opcode mark information is loaded into mark memory at the location of the mark pointer (block 108). The pointers are incremented by the appropriate amount as provided in the lookup table, which is dependent on the byte size of the opcode and operand, if any (block 110). Then the pointers are compared to the address range to determine if the mark command is to be terminated (block 112). If the range is not completed, the state machine module returns to earlier step of extracting the opcode information from the read location specified by the current position of the read pointer (block 102), and continues in the same manner as listed above. If the range is completed, the state machine module indicates successful completion to the user and terminates the mark command and the state machine module, returning to the syntax module (block 114). Figure 8 shows a flowchart of a marking software disassembly module. This module is called by the user when a trace is implemented (block 116). The disassembly module is used to disassemble a single state and is called by a module which would repeatedly call the disassembly module for a series of states. The inverse assembler is first initialized (block 118). The option flag settings are extracted and tested to determine if marking is enabled for this command (block 120). If no marking is enabled, a software dequeueing method (or bus mode disassembly) is applied to determine the opcode or operand (block 122) and the disassembly module is terminated (block 124). If marking is enabled for this address, the mark information is extracted (block 126). If the extracted mark information shows no mark is present for this particular address, then the bus mode disassembly is applied (block 122) as discussed above. If the extracted mark information shows a mark is present for this particular address, then for this particular embodiment the mark is tested to determine if it is a non-opcode mark, a normal opcode mark, or a special opcode mark (block 126). If the mark is a non-opcode mark, then the operand fetch status is shown (block 128) and the module terminates (block 130). If the mark is a special opcode mark, for example a null opcode mark, a special mark disassembly is applied to determine and show the opcode (block 132), and the module is terminated (block 134). If the mark is a standard opcode mark, opcode disassembly is applied, the disassembled opcode is shown (block 136), and the module is terminated (block 138). An example of marking is provided showing the code (written in "C") being traced, then the actual sequence of instructions executed, a trace list display with marking enabled, and a trace list display with marking disabled, similar to the prior art software dequeueing solution. The two trace listings shown are of identical processor steps, the first with marking enabled, and the second with marking disabled. The code that is being traced is as follows: The actual instruction sequence is: EXAMPLE OF TRACE WITH MARKING ENABLED EXAMPLE OF TRACE WITH MARKING DISABLED The trace listing with marking enabled provides a very accurate representation of the actual instructions executed in the proper sequence. The marking tags provide additional state information for use during conversion to a list of states which correspond to the test program executed by the target processor means. In contrast to the trace listing with marking enabled, the trace listing with marking disabled lacks sufficient information to correctly convert the state information to a list of executed instructions. The trace began on a non-opcode fetch at line 4 and disassembled the unexecuted byte as an executed AND command, and misses the first JE (jump if equal) command. Eventually, the trace listing recovers at line 8 and correctly identifies the LDB (load register) command. However, at line 13 and 14 errors occur again. The result is that it is difficult for the user to know when the trace listing is reliable, and when it is not. The use of marking, while not perfect, provides greatly improved reliability.

Claims: Apparatus for use in instruction analysis which employs tracing to acquire state information for respective instructions which are executed in a program under test, and dequeueing to recreate instruction execution from the states acquired by tracing, the apparatus comprising: a memory (38) for storing marks representing the locations of codes associated with respective instructions in said program; a target processor (52) for executing said program; means (30) for receiving traced information from the target processor (52) and marks from the memory (38); and a host controller (24) connected to the means (30) for receiving said traced information and to the memory (38); said host controller (24) being provided for disassembling the traced information, associating marks with the respective instructions and their related state information, and storing the marks in said memory (38); said host controller (24) also performing said dequeueing with the aid of state information associated with marks stored in said memory (38). The apparatus of Claim 1 wherein the state information comprises address, data, and status information. The apparatus of Claim 1 wherein said codes are opcodes. Apparatus according to Claim 2 wherein in each state comprises at least two bytes and wherein said marks provide an indication of the number of bytes constituting a state. A method for use in instruction analysis which employs tracing to acquire state information for respective instructions which are executed in a program under test and dequeueing to recreate instruction execution from the states acquired by tracing, the method comprising the steps of: associating marks representing the locations of codes with respective instructions and their related state information; storing said marks; and performing said tracing during execution of said program; disassembling the traced information; performing said dequeueing with the aid of state information associated with the stored marks. The method of Claim 5, wherein the state information comprises address, data and status information. The method of Claim 5, wherein said codes are opcodes. The method of Claim 6, wherein each state comprises at least two bytes and wherein said marks are generated to provide an indication of the number of bytes constituting a state.

Inventors: MORRISON ROBERT D, MORRISON, ROBERT D.
Applicants: HEWLETT PACKARD CO, HEWLETT-PACKARD COMPANY
Application year: 1989
Main classification: G06F11
IPC codes: G06F11