mirror of
https://github.com/ksherlock/mpw.git
synced 2025-02-16 12:30:53 +00:00
RootDirForPath
This commit is contained in:
parent
e571c7066d
commit
81ce611bfc
@ -46,7 +46,7 @@ namespace {
|
||||
AddressMap wbrkMap; // write breaks.
|
||||
ToolMap tbrkMap; // tool breaks.
|
||||
|
||||
std::unordered_map<std::string, uint16_t> toolMap;
|
||||
std::unordered_map<std::string, uint32_t> envMap;
|
||||
|
||||
|
||||
void hexdump(const uint8_t *data, ssize_t size, uint32_t address = 0)
|
||||
@ -760,19 +760,13 @@ void SetXRegister(unsigned reg, uint32_t value)
|
||||
}
|
||||
|
||||
|
||||
uint16_t TrapNumber(const std::string &s)
|
||||
uint32_t EnvLookup(const std::string &s)
|
||||
{
|
||||
auto iter = toolMap.find(s);
|
||||
if (iter == toolMap.end()) return 0;
|
||||
auto iter = envMap.find(s);
|
||||
if (iter == envMap.end()) return 0;
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
uint16_t TrapNumber(const char *cp)
|
||||
{
|
||||
if (!cp || !*cp) return 0;
|
||||
std::string s(cp);
|
||||
return TrapNumber(s);
|
||||
}
|
||||
|
||||
|
||||
// TODO -- RUN command - reload, re-initialize, re-execute
|
||||
@ -783,12 +777,7 @@ void Shell()
|
||||
|
||||
add_history("!Andy, it still has history!");
|
||||
|
||||
{
|
||||
// load the tool trap file.
|
||||
std::string path = MPW::RootDir();
|
||||
path += "/Traps.text";
|
||||
toolMap = LoadTrapFile(path);
|
||||
}
|
||||
envMap = LoadTrapFile(MPW::RootDirPathForFile("Traps.text"));
|
||||
|
||||
// start it up
|
||||
printf("MPW Debugger shell\n\n");
|
||||
|
@ -28,10 +28,9 @@ struct Command {
|
||||
|
||||
bool ParseLine(const char *iter, Command *command);
|
||||
|
||||
std::unordered_map<std::string, uint16_t> LoadTrapFile(const std::string &path);
|
||||
std::unordered_map<std::string, uint32_t> LoadTrapFile(const std::string &path);
|
||||
|
||||
uint16_t TrapNumber(const std::string &);
|
||||
uint16_t TrapNumber(const char *);
|
||||
uint32_t EnvLookup(const std::string &);
|
||||
|
||||
|
||||
void Shell();
|
||||
|
15
mpw/mpw.cpp
15
mpw/mpw.cpp
@ -100,6 +100,15 @@ namespace MPW
|
||||
return S_ISDIR(st.st_mode);
|
||||
}
|
||||
|
||||
std::string RootDirPathForFile(const std::string &file)
|
||||
{
|
||||
std::string dir(RootDir());
|
||||
if (dir.length() && dir.back() != '/') dir.push_back('/');
|
||||
dir.append(file);
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
const std::string RootDir()
|
||||
{
|
||||
static bool initialized = false;
|
||||
@ -305,10 +314,8 @@ namespace MPW
|
||||
|
||||
void LoadEnvironment(std::string &envfile, std::unordered_map<std::string, std::string> &env);
|
||||
|
||||
if (m.back() != '/') m.push_back('/');
|
||||
m.append("Environment");
|
||||
|
||||
LoadEnvironment(m, env);
|
||||
std::string path(RootDirPathForFile("Environment.text"));
|
||||
LoadEnvironment(path, env);
|
||||
}
|
||||
|
||||
std::deque<std::string> e;
|
||||
|
Loading…
x
Reference in New Issue
Block a user