fxos/shell/m.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.1 KiB
C++
Raw Permalink Normal View History

2022-04-14 13:30:43 +02:00
#include "parser.h"
#include "shell.h"
//---
2022-04-15 12:19:32 +02:00
// ms
2022-04-14 13:30:43 +02:00
//---
2022-04-15 22:43:34 +02:00
static FxOS::Symbol parse_ms(Session &session, Parser &parser)
2022-04-14 13:30:43 +02:00
{
FxOS::Symbol s;
2022-04-15 22:43:34 +02:00
if(parser.lookahead().type == T::SYSCALL) {
2022-04-14 13:30:43 +02:00
s.type = FxOS::Symbol::Syscall;
2022-04-15 22:43:34 +02:00
s.value = parser.expect(T::SYSCALL).value.NUM;
}
else {
2022-04-14 13:30:43 +02:00
s.type = FxOS::Symbol::Address;
2022-04-15 22:43:34 +02:00
s.value = parser.expr(session.current_space);
}
2022-04-14 13:30:43 +02:00
s.name = parser.symbol();
parser.end();
2022-04-15 22:43:34 +02:00
2022-04-14 13:30:43 +02:00
return s;
}
2022-04-15 12:19:32 +02:00
void _ms(Session &session, Symbol s)
2022-04-14 13:30:43 +02:00
{
if(!session.current_space)
return;
session.current_space->symbols.add(s);
}
2022-04-15 12:19:32 +02:00
static ShellCommand _ms_cmd(
"ms", [](Session &s, Parser &p) { _ms(s, parse_ms(s, p)); },
[](Session &s, Parser &p) { parse_ms(s, p); }, "Metadata Symbol", R"(
ms <address|syscall> <symbol>
2022-04-14 13:30:43 +02:00
Defines a new symbol at the specified address or syscall number in the current
2022-04-15 12:19:32 +02:00
virtual space. If a syscall number is provided, the address is not resolved;
the same syscall symbol can be used across multiple OS versions regardless of
where the functions are actually located.
2022-04-14 13:30:43 +02:00
)");