mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibELF: Skip DynamicObject::dump() if logging isn't enabled
I noticed that we were populating this StringBuilder and then throwing away the result while profiling `true` with UserSpace emulator. Before: courage:~ $ time -n 1000 true Timing report: 3454 ms ============== Command: true Average time: 3.45 ms (median: 3, stddev: 3.42, min: 0, max:11) Excluding first: 3.45 ms (median: 3, stddev: 3.42, min: 0, max:11) After: courage:~ $ time -n 1000 true Timing report: 3308 ms ============== Command: true Average time: 3.30 ms (median: 3, stddev: 3.28, min: 0, max:12) Excluding first: 3.30 ms (median: 3, stddev: 3.29, min: 0, max:12)
This commit is contained in:
parent
1577bac6a5
commit
39f924a731
Notes:
sideshowbarker
2024-07-17 16:26:28 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/39f924a731 Pull-request: https://github.com/SerenityOS/serenity/pull/13372
1 changed files with 18 additions and 16 deletions
|
@ -39,25 +39,27 @@ DynamicObject::~DynamicObject()
|
|||
|
||||
void DynamicObject::dump() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("\nd_tag tag_name value\n");
|
||||
size_t num_dynamic_sections = 0;
|
||||
if constexpr (DYNAMIC_LOAD_DEBUG) {
|
||||
StringBuilder builder;
|
||||
builder.append("\nd_tag tag_name value\n");
|
||||
size_t num_dynamic_sections = 0;
|
||||
|
||||
for_each_dynamic_entry([&](const DynamicObject::DynamicEntry& entry) {
|
||||
String name_field = String::formatted("({})", name_for_dtag(entry.tag()));
|
||||
builder.appendff("{:#08x} {:17} {:#08x}\n", entry.tag(), name_field, entry.val());
|
||||
num_dynamic_sections++;
|
||||
});
|
||||
for_each_dynamic_entry([&](const DynamicObject::DynamicEntry& entry) {
|
||||
String name_field = String::formatted("({})", name_for_dtag(entry.tag()));
|
||||
builder.appendff("{:#08x} {:17} {:#08x}\n", entry.tag(), name_field, entry.val());
|
||||
num_dynamic_sections++;
|
||||
});
|
||||
|
||||
if (m_has_soname)
|
||||
builder.appendff("DT_SONAME: {}\n", soname()); // FIXME: Validate that this string is null terminated?
|
||||
if (m_has_rpath)
|
||||
builder.appendff("DT_RPATH: {}\n", rpath());
|
||||
if (m_has_runpath)
|
||||
builder.appendff("DT_RUNPATH: {}\n", runpath());
|
||||
if (m_has_soname)
|
||||
builder.appendff("DT_SONAME: {}\n", soname()); // FIXME: Validate that this string is null terminated?
|
||||
if (m_has_rpath)
|
||||
builder.appendff("DT_RPATH: {}\n", rpath());
|
||||
if (m_has_runpath)
|
||||
builder.appendff("DT_RUNPATH: {}\n", runpath());
|
||||
|
||||
dbgln_if(DYNAMIC_LOAD_DEBUG, "Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections);
|
||||
dbgln_if(DYNAMIC_LOAD_DEBUG, "{}", builder.string_view());
|
||||
dbgln("Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections);
|
||||
dbgln("{}", builder.string_view());
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicObject::parse()
|
||||
|
|
Loading…
Reference in a new issue