mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
SymbolServer+bt: Symbolicate kernel addresses if /boot/Kernel available
The /boot directory is only accessible to root by default, but anyone wanting access to kernel symbols for development can get them by making /boot/Kernel accessible to the "symbol" user.
This commit is contained in:
parent
3ff7b0ebfe
commit
a5d89ca5df
Notes:
sideshowbarker
2024-07-18 22:35:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a5d89ca5dfa
@ -49,6 +49,14 @@ int main(int, char**)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// NOTE: Developers can opt into kernel symbolication by making /boot/Kernel accessible to the "symbol" user.
|
||||
if (access("/boot/Kernel", F_OK) == 0) {
|
||||
if (unveil("/boot/Kernel", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
|
@ -70,11 +70,18 @@ int main(int argc, char** argv)
|
||||
FlatPtr base { 0 };
|
||||
size_t size { 0 };
|
||||
String path;
|
||||
bool is_relative { true };
|
||||
};
|
||||
|
||||
Vector<FlatPtr> stack;
|
||||
Vector<RegionWithSymbols> regions;
|
||||
|
||||
regions.append(RegionWithSymbols {
|
||||
.base = 0xc0000000,
|
||||
.size = 0x3fffffff,
|
||||
.path = "/boot/Kernel",
|
||||
.is_relative = false });
|
||||
|
||||
{
|
||||
// FIXME: Support multiple threads in the same process!
|
||||
auto stack_path = String::formatted("/proc/{}/stacks/{}", pid, pid);
|
||||
@ -141,7 +148,6 @@ int main(int argc, char** argv)
|
||||
auto client = SymbolClient::Client::construct();
|
||||
|
||||
for (auto address : stack) {
|
||||
|
||||
const RegionWithSymbols* found_region = nullptr;
|
||||
for (auto& region : regions) {
|
||||
if (address >= region.base && address < (region.base + region.size)) {
|
||||
@ -156,7 +162,10 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
Vector<FlatPtr> addresses;
|
||||
addresses.append(address - found_region->base);
|
||||
if (found_region->is_relative)
|
||||
addresses.append(address - found_region->base);
|
||||
else
|
||||
addresses.append(address);
|
||||
|
||||
auto symbols = client->symbolicate(found_region->path, addresses);
|
||||
if (symbols.is_empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user