1. Field of the Invention
The invention generally relates to computer processors and, more particularly, to debugging software programs executing thereon.
2. Description of the Related Art
Debugging software programs being executed on a processor entails observing the state of processor element(s), system memory, and/or device(s) under test to analyze conditions leading to error in the software execution. Debugging generally refers to the process of identifying (and hopefully fixing) errors or “bugs” in a program.
To facilitate debugging, programmers typically demand the ability to see the state of each processor element, system memory, as well as other devices which are under test so as to analyze the conditions that caused an error. As part of the program error debug, it is essential to be able to observe the contents of the processor cache, as it contains the most recent version of data that is associated with system memory.
Due to complex interaction of the processor and system components, it is a challenge to provide this ability, including observing the contents of the processor cache, without altering processor behavior. Changing processor behavior might have the undesirable effect of changing or even eliminating the error which is being diagnosed.
Accordingly, what is needed is a mechanism for observing and/or modifying system memory, including cached portions, that is non-disruptive to processor operation.
One or more disclosed methods for debugging software being executed by a processor comprise receiving by the processor one or more debug commands through a debug port; and in response to the one or more debug commands, stopping execution of the software, flushing data from cache memory of the processor to one or more data locations external to the processor, accessing one or more data locations external to the processor, and resuming execution of the software.
One or more disclosed processors comprise one or more processing units to execute software; cache memory to store data for the software; a debug port to receive one or more debug commands; and logic to, in response to the one or more debug commands, stop execution of the software, flush data from the cache memory to one or more data locations external to the processor, access one or more data locations external to the processor, and resume execution of the software.
One or more disclosed systems comprise a host to issue one or more debug commands; a memory controller; system memory coupled to the memory controller; and a processor comprising one or more processing units to execute software, cache memory to store data for the software, a debug port coupled to receive one or more debug commands from the host, and logic to, in response to the one or more debug commands, stop execution of the software, flush data from the cache memory to the system memory, access the system memory, and resume execution of the software.
So that the manner in which the above recited features of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings. It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments.
Embodiments of the invention generally provide software debugging support in a processor for a cache flush with access to one or more external data locations, such as a location in system memory for example, through a debug port. Supporting a cache flush to one or more external data location(s) helps allow observation of cache content through a subsequent access of such external data location(s) through the debug port.
Cache content for one or more embodiments may then be observed in a manner transparent to the software being debugged with no or minimal effect on the software's behavior. For one or more embodiments where, for example, a processor helps maintain cache coherence using system software, observation of cache content may be important because the cache may contain the most recent version of data associated with one or more external data locations.
In the following, reference is made to embodiments of the invention. However, it should be understood that the invention is not limited to specific described embodiments. Instead, any combination of the following features and elements, whether related to different embodiments or not, is contemplated to implement and practice the invention. Furthermore, in various embodiments the invention provides numerous advantages over the prior art. However, although embodiments of the invention may achieve advantages over other possible solutions and/or over the prior art, whether or not a particular advantage is achieved by a given embodiment is not limiting of the invention. Thus, the following aspects, features, embodiments and advantages are merely illustrative and are not considered elements or limitations of the appended claims except where explicitly recited in a claim(s). Likewise, reference to “the invention” shall not be construed as a generalization of any inventive subject matter disclosed herein and shall not be considered to be an element or limitation of the appended claims except where explicitly recited in a claim(s).
Host 150 may be coupled to processor 110 through a debug port 112 of processor 110 to help debug software being executed by processor 110. Debug port 112 for one or more embodiments may be, for example, a Joint Team Access Group (JTAG) port. Host 150 for one or more embodiments may execute any suitable software to help control and/or observe the execution of software by processor 110. Host 150 for one or more embodiments may observe, for example, the state of any suitable element(s) of processor 110, system memory 170, and/or any suitable device(s) under test to allow conditions leading to error in software execution to be analyzed.
Processor 110 for one or more embodiments, as illustrated in
Although described in connection with storing data corresponding to one or more addresses corresponding in turn to one or more locations in system memory 170, cache memory 116 for one or more embodiments may store data corresponding to one or more addresses corresponding to any suitable one or more external data locations. Cache memory 116 may, for example, store data corresponding to one or more memory-mapped registers of one or more devices coupled to processor 110.
Processor 110 for one or more embodiments, as illustrated in
For one or more embodiments where, for example, processor 110 helps maintain coherence between cache memory 116 and system memory 170 using system software, observation of content of cache memory 116 may be important because cache memory 116 may contain the most recent version of data associated with system memory 170. Debug control logic 120 for one or more embodiments may also support a cache flush to system memory 170 and subsequent access to system memory 170 through debug port 112 to help modify data to be processed by the software for debug purposes. Modifying data may allow programmers to identify the cause of suspected errors by modifying cached memory locations to contain particular values that are likely to result in the suspected error.
Host 150 and processor 110 for one or more embodiments may help observe or modify content of cache memory 116 as processor 110 executes software in accordance with a flow diagram 200 of
For block 202 of
For block 204 of
Host 150 and processor 110 for one or more embodiments may perform operations for block 204 in accordance with the flow diagram illustrated in
For block 302 of
For block 304, host 150 may write predetermined data to a memory-mapped front side bus (FSB) debug data register 121 of debug control logic 120, may write a predetermined command to a memory-mapped FSB debug command register 122 of debug control logic 120, and/or may write a predetermined address to a memory-mapped FSB debug address register 123 of debug control logic 120. As one example, host 150 may write all 1's in FSB debug data register 121, a write or store command in FSB debug command register 122, and any suitable predetermined address in FSB debug address register 123. Debug control logic 120 may be coupled to FSB logic 130 to then issue one or more commands over FSB 102 to stop issuance of commands to processor 110 by one or more external sources, such as graphics processor 160 for example.
For block 306, host 150 may issue one or more commands to processor 110 to resume processing of any pending commands from one or more external sources. Host 150 for one embodiment may deactivate an Ignore All Commands bit in a memory-mapped register of debug control logic 120, and debug control logic 120 may then resume processing of any pending external commands. Host 150 for one embodiment for block 306 may additionally wait at least a predetermined amount of time to allow any pending external commands to be performed by processor 110.
For block 308, host 150 may wait, if necessary, at least a predetermined amount of time to allow the command(s) issued for block 304 to one or more external sources to be performed.
Host 150 for one or more other embodiments for block 204 of
Host 150 for block 206 issues one or more commands to processor 110 to flush data from cache memory 116 to one or more external data locations, such as one or more locations in system memory 170 for example, and to access such data location(s) to read or modify the flushed data. Debug control logic 120 may comprise any suitable logic coupled to flush data from cache memory 116 to one or more external data locations and to access such data location(s) to read or modify the flushed data in response to such command(s) in any suitable manner.
Host 150 and processor 110 for one or more embodiments may perform operations for block 206 in accordance with the flow diagram illustrated in
For block 402 of
For block 404, host 150 may write a flush command and a desired address of a cache line in cache memory 116 to a memory-mapped debug command register 126 of debug control logic 120. Debug control logic 120 may be coupled to a processor bus to then issue one or more commands over the processor bus to flush the cache line of data corresponding to the desired address in cache memory 116 to one or more external data locations, such as one or more locations in system memory 170 for example.
For block 406, host 150 may wait at least a predetermined amount of time to allow the cache line at the desired address to be flushed for block 404.
For block 408, host 150 may write an access command to FSB debug command register 122 of debug control logic 120 and may write a desired address of an external data location to be accessed to FSB debug address register 123 of debug control logic 120. The desired external data location address may correspond to the memory address evicted from the cache in block 404. Host 150 may optionally write a transaction identifier to FSB debug command register 122. For a read or load access, host 150 may write a load access command to FSB debug command register 122. For a write or store access, host 150 may write a store access command to FSB debug command register 122 and may write the data to be stored to FSB debug data register 121. Debug control logic 120 may be coupled to FSB logic 130 to then issue a corresponding command to access the external data location at the desired address.
For block 410, host 150 may wait at least a predetermined amount of time for a load access for data to be read from the external data location at the desired address. For a store access, host 150 may optionally skip operations for block 410.
For block 412, host 150 may read from trace array 132 data read for a load access. For a store access, host 150 may skip operations for block 412.
For block 414, host 150 may restore trace array 132 to its state prior to configuring trace array 132 for block 402. For a store access, host 150 may skip operations for block 414.
Returning to
For block 210 of
Host 150 and processor 110 for one or more embodiments may perform operations for block 210 in accordance with the flow diagram illustrated in
For block 502 of
For block 212 of
Embodiments of the invention generally providing software debugging support in a processor for a cache flush with access to one or more external data locations, such as a location in system memory for example, through a debug port have therefore been described.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.