Skip to content

Commit cf0d78f

Browse files
joevtdingusdev
authored andcommitted
debugger: add regions command.
To dump the list of memory regions.
1 parent 8aede43 commit cf0d78f

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

debugger/debugger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void show_help() {
8989
cout << " setmem X=V.T -- set memory at address X to value V of size T" << endl;
9090
cout << " T can be b(byte), w(word), d(double)," << endl;
9191
cout << " q(quad) or c(character)." << endl;
92+
cout << " regions -- dump memory regions" << endl;
9293
cout << " profile C N -- run subcommand C on profile N" << endl;
9394
cout << " supported subcommands:" << endl;
9495
cout << " 'show' - show profile report" << endl;
@@ -881,6 +882,10 @@ void DppcDebugger::enter_debugger() {
881882
cout << "Unknown debugging context: " << expr_str << endl;
882883
}
883884
#endif
885+
} else if (cmd == "regions") {
886+
cmd = "";
887+
if (mem_ctrl_instance)
888+
mem_ctrl_instance->dump_regions();
884889
} else if (cmd == "printenv") {
885890
cmd = "";
886891
if (ofnvram->init())

devices/memctrl/memctrlbase.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,3 +372,13 @@ uint8_t *MemCtrlBase::get_region_hostmem_ptr(const uint32_t addr) {
372372
else
373373
return (addr - reg_desc->start) + reg_desc->mem_ptr;
374374
}
375+
376+
377+
void MemCtrlBase::dump_regions()
378+
{
379+
int i = 0;
380+
for (auto& entry : address_map) {
381+
printf("%2d: %s\n", i, get_entry_str(entry).c_str());
382+
i++;
383+
}
384+
}

devices/memctrl/memctrlbase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class MemCtrlBase {
8888

8989
uint8_t *get_region_hostmem_ptr(const uint32_t addr);
9090

91+
void dump_regions();
92+
9193
protected:
9294
bool add_mem_region(
9395
uint32_t start_addr, uint32_t size, uint32_t dest_addr, uint32_t type,

0 commit comments

Comments
 (0)