base,sim: Adding monitor function to GDB
The remote protocol provides a monitor query. This query allows to provide a implementation defined behavior in the stub. I proposed to use this command as a way to quit simulation with a message provided by the GDB client. Thus calling "monitor my_message" in the client will exit the simulation with the exit message "GDB_MONITOR:my_message". This is implemented through a derived class based on GlobalSimLoopExitEvent and a small addition to the based class that adds a clean method that will be called when returning siumation after the Event. Change-Id: Ib5fda569edcf6733cbcc6240ef6d2ec4dc6502ec Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63538 Maintainer: Bobby Bruce <bbruce@ucdavis.edu> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "base/debug.hh"
|
||||
#include "base/flags.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "base/types.hh"
|
||||
#include "base/uncontended_mutex.hh"
|
||||
#include "debug/Event.hh"
|
||||
|
||||
@@ -68,8 +68,11 @@ class GlobalSimLoopExitEvent : public GlobalEvent
|
||||
const std::string getCause() const { return cause; }
|
||||
int getCode() const { return code; }
|
||||
|
||||
void process(); // process event
|
||||
|
||||
virtual void process();// process event
|
||||
virtual void clean(){};//cleaning event
|
||||
~GlobalSimLoopExitEvent (){
|
||||
DPRINTF(Event,"GlobalSimLoopExitEvent destructed\n");
|
||||
};
|
||||
virtual const char *description() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -184,9 +184,12 @@ struct DescheduleDeleter
|
||||
* terminate the loop. Exported to Python.
|
||||
* @return The SimLoopExitEvent that caused the loop to exit.
|
||||
*/
|
||||
GlobalSimLoopExitEvent *global_exit_event= nullptr;
|
||||
GlobalSimLoopExitEvent *
|
||||
simulate(Tick num_cycles)
|
||||
{
|
||||
if (global_exit_event)//cleaning last global exit event
|
||||
global_exit_event->clean();
|
||||
std::unique_ptr<GlobalSyncEvent, DescheduleDeleter> quantum_event;
|
||||
const Tick exit_tick = num_cycles < MaxTick - curTick() ?
|
||||
curTick() + num_cycles : MaxTick;
|
||||
@@ -224,7 +227,7 @@ simulate(Tick num_cycles)
|
||||
BaseGlobalEvent *global_event = local_event->globalEvent();
|
||||
assert(global_event);
|
||||
|
||||
GlobalSimLoopExitEvent *global_exit_event =
|
||||
global_exit_event =
|
||||
dynamic_cast<GlobalSimLoopExitEvent *>(global_event);
|
||||
assert(global_exit_event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user