URL
https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk
Subversion Repositories riscv_vhdl
Compare Revisions
- This comparison shows the changes necessary to convert path
/riscv_vhdl/trunk/debugger/src/libdbg64g/services/exec
- from Rev 3 to Rev 4
- ↔ Reverse comparison
Rev 3 → Rev 4
/cmd/cmd_br.cpp
19,7 → 19,7
" flags.\n" |
"Response:\n" |
" List of lists [[iii]*] if breakpoint list was requested, where:\n" |
" i - uint64_t address value\n" |
" i|s - uint64_t address value or 'string' symbol name\n" |
" i - uint32_t instruction value\n" |
" i - uint64_t Breakpoint flags: hardware,...\n" |
" Nil in a case of add/rm breakpoint\n" |
27,11 → 27,14
" br" |
" br add <addr>\n" |
" br rm <addr>\n" |
" br rm 'symbol_name'\n" |
" br add <addr> hw\n" |
"Example:\n" |
" br add 0x10000000\n" |
" br add 0x00020040 hw\n" |
" br rm 0x10000000\n"); |
" br add 'func1'\n" |
" br rm 0x10000000\n" |
" br rm 'func1'\n"); |
|
AttributeType lstServ; |
RISCV_get_services_with_iface(IFACE_SOURCE_CODE, &lstServ); |
68,21 → 71,51
flags |= BreakFlag_HW; |
} |
|
Reg64Type instr; |
uint64_t addr = (*args)[2].to_uint64(); |
tap_->read(addr, 4, instr.buf); |
isrc_->registerBreakpoint(addr, instr.buf32[0], flags); |
DsuMapType *pdsu = info_->getpDsu(); |
|
instr.buf32[0] = 0x00100073; // EBREAK instruction |
Reg64Type braddr; |
Reg64Type brinstr; |
AttributeType &bpadr = (*args)[2]; |
if (bpadr.is_integer()) { |
braddr.val = bpadr.to_uint64(); |
} else if (bpadr.is_string()) { |
if (isrc_->symbol2Address(bpadr.to_string(), &braddr.val) < 0) { |
generateError(res, "Symbol not found"); |
return; |
} |
} else { |
generateError(res, "Wrong command format"); |
return; |
} |
|
if ((*args)[1].is_equal("add")) { |
brinstr.val = 0; |
tap_->read(braddr.val, 4, brinstr.buf); |
|
if ((*args)[1].is_equal("add")) { |
tap_->write(addr, 4, instr.buf); |
isrc_->registerBreakpoint(braddr.val, flags, brinstr.val); |
if (flags & BreakFlag_HW) { |
uint64_t dsuaddr = |
reinterpret_cast<uint64_t>(&pdsu->udbg.v.add_breakpoint); |
tap_->write(dsuaddr, 8, braddr.buf); |
} else { |
if ((brinstr.val & 0x3) == 0x3) { |
brinstr.buf32[0] = 0x00100073; // EBREAK instruction |
} else { |
brinstr.buf16[0] = 0x9002; // C.EBREAK instruction |
} |
tap_->write(braddr.val, 4, brinstr.buf); |
} |
return; |
} |
|
if ((*args)[1].is_equal("rm")) { |
if (!isrc_->unregisterBreakpoint(addr, instr.buf32, &flags)) { |
tap_->write(addr, 4, instr.buf); |
isrc_->unregisterBreakpoint(braddr.val, &flags, &brinstr.val); |
if (flags & BreakFlag_HW) { |
uint64_t dsuaddr = |
reinterpret_cast<uint64_t>(&pdsu->udbg.v.remove_breakpoint); |
tap_->write(dsuaddr, 8, braddr.buf); |
} else { |
tap_->write(braddr.val, 4, brinstr.buf); |
} |
} |
} |
/cmd/cmd_busutil.cpp
16,7 → 16,8
CmdBusUtil::CmdBusUtil(ITap *tap, ISocInfo *info) |
: ICommand ("busutil", tap, info) { |
|
briefDescr_.make_string("Compute Clocks Per Instruction (CPI) rate"); |
briefDescr_.make_string("Read per master bus utilization in percentage " |
"of time"); |
detailedDescr_.make_string( |
"Description:\n" |
" Read and normalize per master bus utilization statistic\n" |
46,7 → 47,7
} |
|
void CmdBusUtil::exec(AttributeType *args, AttributeType *res) { |
unsigned mst_total = info_->getMastersTotal(); |
unsigned mst_total = 4;//info_->getMastersTotal(); |
res->make_list(mst_total); |
if (!isValid(args)) { |
generateError(res, "Wrong argument list"); |
/cmd/cmd_csr.cpp
45,7 → 45,7
uint64_t addr; |
if (arg1.is_string()) { |
const char *csrname = arg1.to_string(); |
addr = info_->csr2addr(csrname); |
addr = 0;//!!!info_->csr2addr(csrname); |
if (addr == REG_ADDR_ERROR) { |
char tstr[128]; |
RISCV_sprintf(tstr, sizeof(tstr), "%s not found", csrname); |
74,7 → 74,7
char tstr[256]; |
int tstrsz; |
uint64_t csr = res->to_uint64(); |
uint64_t addr = info_->csr2addr((*args)[1].to_string()); |
uint64_t addr = 0;//info_->csr2addr((*args)[1].to_string()); |
|
tstr[0] = '\0'; |
if (addr == static_cast<uint64_t>(-1)) { |
/cmd/cmd_disas.cpp
61,8 → 61,7
AttributeType *mem_data, *asm_data; |
AttributeType membuf, asmbuf; |
if ((*args)[2].is_integer()) { |
// 4-bytes alignment |
uint32_t sz = ((*args)[2].to_uint32() + 3) & ~0x3; |
uint32_t sz = (*args)[2].to_uint32(); |
membuf.make_data(sz); |
mem_data = &membuf; |
if (tap_->read(addr, sz, membuf.data()) == TAP_ERROR) { |
/cmd/cmd_halt.cpp
41,7 → 41,7
|
Reg64Type t1; |
DsuMapType *dsu = info_->getpDsu(); |
DsuMapType::udbg_type::debug_region_type::control_reg ctrl; |
GenericCpuControlType ctrl; |
uint64_t addr_run_ctrl = reinterpret_cast<uint64_t>(&dsu->udbg.v.control); |
ctrl.val = 0; |
ctrl.bits.halt = 1; |
/cmd/cmd_isrunning.cpp
35,7 → 35,7
} |
|
Reg64Type t1; |
DsuMapType::udbg_type::debug_region_type::control_reg ctrl; |
GenericCpuControlType ctrl; |
DsuMapType *pdsu = info_->getpDsu(); |
uint64_t addr = reinterpret_cast<uint64_t>(&pdsu->udbg.v.control); |
tap_->read(addr, 8, t1.buf); |
/cmd/cmd_loadelf.cpp
71,10 → 71,12
uint64_t addr = reinterpret_cast<uint64_t>(&dsu->ulocal.v.soft_reset); |
tap_->write(addr, 8, reinterpret_cast<uint8_t *>(&soft_reset)); |
|
uint64_t sec_addr; |
int sec_sz; |
for (unsigned i = 0; i < elf->loadableSectionTotal(); i++) { |
tap_->write(elf->sectionAddress(i), |
static_cast<int>(elf->sectionSize(i)), |
elf->sectionData(i)); |
sec_addr = elf->sectionAddress(i); |
sec_sz = static_cast<int>(elf->sectionSize(i)); |
tap_->write(sec_addr, sec_sz, elf->sectionData(i)); |
} |
|
soft_reset = 0; |
/cmd/cmd_memdump.cpp
1,8 → 1,17
/** |
* @file |
* @copyright Copyright 2016 GNSS Sensor Ltd. All right reserved. |
* @author Sergey Khabarov - sergeykhbr@gmail.com |
* @brief Dump memory range into file. |
/* |
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
|
#include "cmd_memdump.h" |
41,7 → 50,7
} |
|
const char *filename = (*args)[3].to_string(); |
FILE *fd = fopen(filename, "w"); |
FILE *fd = fopen(filename, "wb"); |
if (fd == NULL) { |
char tst[256]; |
RISCV_sprintf(tst, sizeof(tst), "Can't open '%s' file", filename); |
/cmd/cmd_reg.cpp
1,8 → 1,17
/** |
* @file |
* @copyright Copyright 2016 GNSS Sensor Ltd. All right reserved. |
* @author Sergey Khabarov - sergeykhbr@gmail.com |
* @brief Read/write register value. |
/* |
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
|
#include "cmd_reg.h" |
/cmd/cmd_regs.cpp
65,12 → 65,18
} t1; |
DsuMapType *dsu = info_->getpDsu(); |
uint64_t addr = reinterpret_cast<uint64_t>(dsu->ureg.v.iregs); |
addr &= 0xFFFFFFFFul; |
tap_->read(addr, 8 * soclst.size(), t1.buf); |
|
uint64_t idx; |
res->make_dict(); |
for (unsigned i = 0; i < soclst.size(); i++) { |
const char *name = soclst[i].to_string(); |
(*res)[name].make_uint64(t1.regarr.reg[i].val); |
if (strlen(name) == 0) { |
continue; |
} |
idx = (info_->reg2addr(name) - addr) / sizeof(uint64_t); |
(*res)[name].make_uint64(t1.regarr.reg[idx].val); |
} |
} |
|
/cmd/cmd_run.cpp
53,7 → 53,7
runctrl.val = (*args)[1].to_uint64(); |
tap_->write(addr_step_cnt, 8, runctrl.buf); |
|
DsuMapType::udbg_type::debug_region_type::control_reg ctrl; |
GenericCpuControlType ctrl; |
ctrl.val = 0; |
ctrl.bits.stepping = 1; |
runctrl.val = ctrl.val; |
/cmd/cmd_stack.cpp
7,7 → 7,7
|
#include "cmd_stack.h" |
#include "iservice.h" |
#include "coreservices/ielfreader.h" |
#include "coreservices/isrccode.h" |
|
namespace debugger { |
|
60,15 → 60,16
|
AttributeType tbuf, lstServ; |
uint64_t *p_data; |
IElfReader *elf = 0; |
ISourceCode *isrc = 0; |
uint64_t from_addr, to_addr; |
tbuf.make_data(16*trace_sz); |
tap_->read(addr, tbuf.size(), tbuf.data()); |
|
RISCV_get_services_with_iface(IFACE_ELFREADER, &lstServ); |
RISCV_get_services_with_iface(IFACE_SOURCE_CODE, &lstServ); |
if (lstServ.size() >= 0) { |
IService *iserv = static_cast<IService *>(lstServ[0u].to_iface()); |
elf = static_cast<IElfReader *>(iserv->getInterface(IFACE_ELFREADER)); |
isrc = static_cast<ISourceCode *>( |
iserv->getInterface(IFACE_SOURCE_CODE)); |
} |
|
res->make_list(t1.buf32[0]); |
81,9 → 82,9
item.make_list(4); |
item[0u].make_uint64(from_addr); |
item[2].make_uint64(to_addr); |
if (elf) { |
elf->addressToSymbol(from_addr, &item[1]); |
elf->addressToSymbol(to_addr, &item[3]); |
if (isrc) { |
isrc->addressToSymbol(from_addr, &item[1]); |
isrc->addressToSymbol(to_addr, &item[3]); |
} |
} |
} |
/cmd/cmd_status.cpp
1,8 → 1,17
/** |
* @file |
* @copyright Copyright 2017 GNSS Sensor Ltd. All right reserved. |
* @author Sergey Khabarov - sergeykhbr@gmail.com |
* @brief Read target's status register. |
/* |
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
|
#include "cmd_status.h" |
/cmd/cmd_symb.cpp
7,7 → 7,7
|
#include "iservice.h" |
#include "cmd_symb.h" |
#include "coreservices/ielfreader.h" |
#include "coreservices/isrccode.h" |
|
namespace debugger { |
|
42,21 → 42,21
} |
|
AttributeType lstServ; |
RISCV_get_services_with_iface(IFACE_ELFREADER, &lstServ); |
RISCV_get_services_with_iface(IFACE_SOURCE_CODE, &lstServ); |
if (lstServ.size() == 0) { |
generateError(res, "Elf-service not found"); |
generateError(res, "SourceCode service not found"); |
return; |
} |
IService *iserv = static_cast<IService *>(lstServ[0u].to_iface()); |
IElfReader *elf = static_cast<IElfReader *>( |
iserv->getInterface(IFACE_ELFREADER)); |
ISourceCode *isrc = static_cast<ISourceCode *>( |
iserv->getInterface(IFACE_SOURCE_CODE)); |
|
if (args->size() == 2 && (*args)[1].is_string()) { |
AttributeType allSymb; |
elf->getSymbols(&allSymb); |
isrc->getSymbols(&allSymb); |
applyFilter((*args)[1].to_string(), &allSymb, res); |
} else { |
elf->getSymbols(res); |
isrc->getSymbols(res); |
} |
} |
|
/cmdexec.cpp
10,6 → 10,7
#include "cmd/cmd_regs.h" |
#include "cmd/cmd_reg.h" |
#include "cmd/cmd_loadelf.h" |
#include "cmd/cmd_loadsrec.h" |
#include "cmd/cmd_log.h" |
#include "cmd/cmd_isrunning.h" |
#include "cmd/cmd_read.h" |
27,6 → 28,7
#include "cmd/cmd_busutil.h" |
#include "cmd/cmd_symb.h" |
#include "cmd/cmd_stack.h" |
#include "cmd/cmd_loadbin.h" |
|
namespace debugger { |
|
75,7 → 77,9
registerCommand(new CmdExit(itap_, info_)); |
registerCommand(new CmdHalt(itap_, info_)); |
registerCommand(new CmdIsRunning(itap_, info_)); |
registerCommand(new CmdLoadBin(itap_, info_)); |
registerCommand(new CmdLoadElf(itap_, info_)); |
registerCommand(new CmdLoadSrec(itap_, info_)); |
registerCommand(new CmdLog(itap_, info_)); |
registerCommand(new CmdMemDump(itap_, info_)); |
registerCommand(new CmdRead(itap_, info_)); |
175,7 → 179,7
if (icmd) { |
RISCV_printf0("\n%s", icmd->detailedDescr()); |
} else { |
RISCV_error("Command '%s' not found", helpcmd); |
RISCV_error("Command \\'%s\\' not found", helpcmd); |
} |
} |
return; |
184,14 → 188,14
AttributeType u; |
icmd = getICommand(cmd); |
if (!icmd) { |
RISCV_error("Command '%s' not found. Use 'help' to list commands", |
(*cmd)[0u].to_string()); |
RISCV_error("Command \\'%s\\' not found. " |
"Use \\'help\\' to list commands", (*cmd)[0u].to_string()); |
return; |
} |
icmd->exec(cmd, res); |
|
if (cmdIsError(res)) { |
RISCV_error("Command '%s' error: '%s'", |
RISCV_error("Command \\'%s\\' error: \\'%s\\'", |
(*res)[1].to_string(), (*res)[2].to_string()); |
} |
} |
/cmdexec.h
1,8 → 1,17
/** |
* @file |
* @copyright Copyright 2016 GNSS Sensor Ltd. All right reserved. |
* @author Sergey Khabarov - sergeykhbr@gmail.com |
* @brief Command Executor declaration. |
/* |
* Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
|
#ifndef __DEBUGGER_CMDEXECUTOR_H__ |