forked from Lephenixnoir/fxos
Compare commits
2 Commits
5a3de5aa17
...
b494a30404
Author | SHA1 | Date |
---|---|---|
Dr-Carlos | b494a30404 | |
Dr-Carlos | f16ecc370c |
|
@ -34,6 +34,11 @@ struct Symbol
|
|||
|
||||
/* Symbol name, no particular conventions */
|
||||
std::string name;
|
||||
|
||||
bool operator<(const FxOS::Symbol &right) const
|
||||
{
|
||||
return (type < right.type) || (value < right.value);
|
||||
}
|
||||
};
|
||||
|
||||
/* A symbol table, usually the set of symbols of a virtual space */
|
||||
|
|
|
@ -49,14 +49,15 @@ static _e_args parse_e(Session &session, Parser &parser)
|
|||
void _e(Session &, std::string, std::vector<long> const &values)
|
||||
{
|
||||
for(long value: values) {
|
||||
long print_val = labs(value);
|
||||
|
||||
/* Hexa format */
|
||||
int length = (labs(value) <= (1ll << 32) ? 8 : 16) + 2 + (value < 0);
|
||||
int length = (print_val <= (1ll << 32) ? 8 : 16) + 2 + (value < 0);
|
||||
std::string format = fmt::format("{{:#0{}x}}", length);
|
||||
fmt::print(format, value);
|
||||
|
||||
long a = abs(value);
|
||||
if(a <= 100 || a % 100 <= 1 || a % 100 >= 99)
|
||||
fmt::print(" = {}", a);
|
||||
if(print_val <= 100 || print_val % 100 <= 1 || print_val % 100 >= 99)
|
||||
fmt::print(" = {}", print_val);
|
||||
|
||||
fmt::print("\n");
|
||||
}
|
||||
|
|
16
shell/i.cpp
16
shell/i.cpp
|
@ -249,6 +249,7 @@ struct _is_args
|
|||
{
|
||||
std::string vspace_name;
|
||||
std::optional<FxOS::Symbol> symbol;
|
||||
bool sort;
|
||||
};
|
||||
|
||||
static struct _is_args parse_is(Session &session, Parser &parser)
|
||||
|
@ -258,6 +259,9 @@ static struct _is_args parse_is(Session &session, Parser &parser)
|
|||
parser.option("vspace",
|
||||
[&args](std::string const &value) { args.vspace_name = value; });
|
||||
|
||||
parser.option("sort",
|
||||
[&args](std::string const &value) { args.sort = (value == "true"); });
|
||||
|
||||
parser.accept_options();
|
||||
|
||||
FxOS::Symbol s;
|
||||
|
@ -296,7 +300,7 @@ static struct _is_args parse_is(Session &session, Parser &parser)
|
|||
}
|
||||
|
||||
void _is(Session &session, std::string vspace_name,
|
||||
std::optional<FxOS::Symbol> symbol)
|
||||
std::optional<FxOS::Symbol> symbol, bool sort)
|
||||
{
|
||||
VirtualSpace *space = session.current_space;
|
||||
if(!space) {
|
||||
|
@ -351,6 +355,9 @@ void _is(Session &session, std::string vspace_name,
|
|||
symbols = {s};
|
||||
}
|
||||
|
||||
if(sort)
|
||||
std::sort(&symbols[0], &symbols[symbols.size()]);
|
||||
|
||||
for(auto const &s: symbols) {
|
||||
if(s.type == FxOS::Symbol::Syscall) {
|
||||
fmt::print(theme(10), " %{:04x}", s.value);
|
||||
|
@ -404,12 +411,13 @@ static ShellCommand _is_cmd(
|
|||
"is",
|
||||
[](Session &s, Parser &p) {
|
||||
auto args = parse_is(s, p);
|
||||
_is(s, args.vspace_name, args.symbol);
|
||||
_is(s, args.vspace_name, args.symbol, args.sort);
|
||||
},
|
||||
[](Session &s, Parser &p) { parse_is(s, p); }, "Info Symbols", R"(
|
||||
is [vspace=<virtual_space>] [<address|syscall>]
|
||||
is [sort=true] [vspace=<virtual_space>] [<address|syscall>]
|
||||
|
||||
Lists symbols in the specified virtual space (defaults to the current
|
||||
one). By default, all symbols are listed, but if an address or syscall is
|
||||
provided, the symbol associated with it will be printed instead.
|
||||
provided, the symbol associated with it will be printed instead. If sort=true,
|
||||
symbols will be sorted by syscall number and then address.
|
||||
)");
|
||||
|
|
Loading…
Reference in New Issue