Skip to content

Commit 233e567

Browse files
committed
WFI: Reacquire control of the core in the debugger after it executes a WFI instruction.
A new gdb_stop_evt event was added, triggered when the debugger issues a stop request.
1 parent 2298db9 commit 233e567

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

src/iss/arch_if.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ class arch_if {
211211

212212
using unknown_instr_cb_t = std::tuple<bool, uint64_t>(arch_if* core, uint64_t addr, size_t len, uint8_t const*);
213213

214+
/**
215+
* @brief trigger gdb stop event to resume fetch instruction thread
216+
*/
217+
virtual void trigger_debugger_stop_event() {}
218+
214219
protected:
215220
using rd_func_sig = iss::status(const addr_t&, unsigned, uint8_t*);
216221
util::delegate<rd_func_sig> rd_func;

src/iss/debugger/cmdhandler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ std::string cmd_handler::threads(std::string const& in_buf) {
121121
}
122122
}
123123

124+
int cmd_handler::send_stop_event(){
125+
CLOG(TRACE, connection) << "executing " << __FUNCTION__;
126+
int ret = t->trigger_debugger_stop_event();
127+
return ret;
128+
}
129+
124130
std::string cmd_handler::read_registers(std::string const& in_buf) {
125131
CLOG(TRACE, connection) << "executing " << __FUNCTION__;
126132
int ret;

src/iss/debugger/cmdhandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class cmd_handler {
111111
std::string detach(std::string const& in_buf);
112112
std::string query(std::string const& in_buf);
113113
std::string set(std::string const& in_buf);
114+
int send_stop_event();
114115
boost::optional<std::string> handle_extended(std::string const& in_buf);
115116
std::string breakpoint(std::string const& in_buf);
116117
int rcmd(const char* const in_buf, out_func of, data_func df);

src/iss/debugger/gdb_session.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ void gdb_session::receive_completed(const boost::system::error_code& e, std::str
197197
} else if(msg->at(0) == 3 || (msg->at(0) == -1 && msg->at(1) == -13)) {
198198
CLOG(TRACE, connection) << "Received BREAK, interrupting target";
199199
handler.t->stop();
200+
handler.send_stop_event();
200201
respond("+");
201202
} else {
202203
CLOG(TRACE, connection) << "Received packet '" << *msg << "', processing it";

src/iss/debugger/target_adapter_if.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ class target_adapter_if {
158158
avail buf is 1 */
159159
virtual iss::status read_registers(std::vector<uint8_t>& data_buf, std::vector<uint8_t>& avail_buf) = 0;
160160

161+
/* Send gdb stop event to core*/
162+
virtual iss::status trigger_debugger_stop_event() = 0;
163+
161164
/* Write all registers. buf is 4-byte aligned and it is in target
162165
byte order */
163166
virtual iss::status write_registers(const std::vector<uint8_t>& buf) = 0;

0 commit comments

Comments
 (0)