Skip to content

Commit 9169133

Browse files
committed
Respond to user feedback:
- Rename Target::SectionLoadListIsEmpty() to Target::HasLoadedSections() and invert all call sites - Change Target::HasLoadedSections() to not be const and avoid the const cast.
1 parent dab763a commit 9169133

File tree

20 files changed

+32
-33
lines changed

20 files changed

+32
-33
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,7 @@ class Target : public std::enable_shared_from_this<Target>,
11511151
Address &pointer_addr,
11521152
bool force_live_memory = false);
11531153

1154-
1155-
bool SectionLoadListIsEmpty() const;
1154+
bool HasLoadedSections();
11561155

11571156
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp);
11581157

lldb/source/Commands/CommandObjectDisassemble.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ CommandObjectDisassemble::GetContainingAddressRanges() {
269269
};
270270

271271
Target &target = GetTarget();
272-
if (!target.SectionLoadListIsEmpty()) {
272+
if (target.HasLoadedSections()) {
273273
Address symbol_containing_address;
274-
if (target.ResolveLoadAddress(m_options.symbol_containing_addr,
274+
if (target.ResolveLoadAddress(m_options.symbol_containing_addr,
275275
symbol_containing_address)) {
276276
get_range(symbol_containing_address);
277277
}

lldb/source/Commands/CommandObjectRegister.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class CommandObjectRegisterRead : public CommandObjectParsed {
9595
addr_t reg_addr = reg_value.GetAsUInt64(LLDB_INVALID_ADDRESS);
9696
if (reg_addr != LLDB_INVALID_ADDRESS) {
9797
Address so_reg_addr;
98-
if (exe_ctx.GetTargetRef().ResolveLoadAddress(reg_addr,
98+
if (exe_ctx.GetTargetRef().ResolveLoadAddress(reg_addr,
9999
so_reg_addr)) {
100100
strm.PutCString(" ");
101101
so_reg_addr.Dump(&strm, exe_ctx.GetBestExecutionContextScope(),

lldb/source/Commands/CommandObjectSource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
302302
size_t num_matches = 0;
303303
assert(module_list.GetSize() > 0);
304304
Target &target = GetTarget();
305-
if (target.SectionLoadListIsEmpty()) {
305+
if (!target.HasLoadedSections()) {
306306
// The target isn't loaded yet, we need to lookup the file address in all
307307
// modules. Note: the module list option does not apply to addresses.
308308
const size_t num_modules = module_list.GetSize();
@@ -959,7 +959,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
959959
StreamString error_strm;
960960
SymbolContextList sc_list;
961961

962-
if (target.SectionLoadListIsEmpty()) {
962+
if (!target.HasLoadedSections()) {
963963
// The target isn't loaded yet, we need to lookup the file address in
964964
// all modules
965965
const ModuleList &module_list = target.GetImages();

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ static bool LookupAddressInModule(CommandInterpreter &interpreter, Stream &strm,
15221522
Address so_addr;
15231523
SymbolContext sc;
15241524
Target *target = interpreter.GetExecutionContext().GetTargetPtr();
1525-
if (target && !target->SectionLoadListIsEmpty()) {
1525+
if (target && target->HasLoadedSections()) {
15261526
if (!target->ResolveLoadAddress(addr, so_addr))
15271527
return false;
15281528
else if (so_addr.GetModule().get() != module)
@@ -2974,7 +2974,7 @@ class CommandObjectTargetModulesLoad
29742974
sect_name);
29752975
break;
29762976
} else {
2977-
if (target.SetSectionLoadAddress(section_sp,
2977+
if (target.SetSectionLoadAddress(section_sp,
29782978
load_addr))
29792979
changed = true;
29802980
result.AppendMessageWithFormat(
@@ -3329,7 +3329,7 @@ class CommandObjectTargetModulesList : public CommandObjectParsed {
33293329
if (objfile) {
33303330
Address base_addr(objfile->GetBaseAddress());
33313331
if (base_addr.IsValid()) {
3332-
if (!target.SectionLoadListIsEmpty()) {
3332+
if (target.HasLoadedSections()) {
33333333
lldb::addr_t load_addr = base_addr.GetLoadAddress(&target);
33343334
if (load_addr == LLDB_INVALID_ADDRESS) {
33353335
base_addr.Dump(&strm, &target,

lldb/source/Core/Address.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static bool ReadAddress(ExecutionContextScope *exe_scope,
138138
// If we have any sections that are loaded, try and resolve using the
139139
// section load list
140140
Target *target = exe_ctx.GetTargetPtr();
141-
if (target && !target->SectionLoadListIsEmpty()) {
141+
if (target && target->HasLoadedSections()) {
142142
if (target->ResolveLoadAddress(deref_addr, deref_so_addr))
143143
return true;
144144
} else {

lldb/source/Core/Disassembler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ static Address ResolveAddress(Target &target, const Address &addr) {
107107
Address resolved_addr;
108108
// If we weren't passed in a section offset address range, try and resolve
109109
// it to something
110-
bool is_resolved = target.SectionLoadListIsEmpty() ? target.GetImages().ResolveFileAddress(addr.GetOffset(), resolved_addr) : target.ResolveLoadAddress(addr.GetOffset(), resolved_addr);
110+
bool is_resolved =
111+
target.HasLoadedSections()
112+
? target.ResolveLoadAddress(addr.GetOffset(), resolved_addr)
113+
: target.GetImages().ResolveFileAddress(addr.GetOffset(),
114+
resolved_addr);
111115

112116
// We weren't able to resolve the address, just treat it as a raw address
113117
if (is_resolved && resolved_addr.IsValid())

lldb/source/Core/DumpDataExtractor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static lldb::offset_t DumpInstructions(const DataExtractor &DE, Stream *s,
139139
if (target_sp->ResolveLoadAddress(addr, so_addr)) {
140140
data_from_file = false;
141141
} else {
142-
if (target_sp->SectionLoadListIsEmpty() ||
142+
if (!target_sp->HasLoadedSections() ||
143143
!target_sp->GetImages().ResolveFileAddress(addr, so_addr))
144144
so_addr.SetRawAddress(addr);
145145
}

lldb/source/Core/FormatEntity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc,
412412
Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
413413

414414
addr_t vaddr = LLDB_INVALID_ADDRESS;
415-
if (target && !target->SectionLoadListIsEmpty())
415+
if (target && target->HasLoadedSections())
416416
vaddr = addr.GetLoadAddress(target);
417417
if (vaddr == LLDB_INVALID_ADDRESS)
418418
vaddr = addr.GetFileAddress();

lldb/source/Core/Section.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,7 @@ bool SectionList::ContainsSection(user_id_t sect_id) const {
637637

638638
void SectionList::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
639639
bool show_header, uint32_t depth) const {
640-
bool target_has_loaded_sections =
641-
target && !target->SectionLoadListIsEmpty();
640+
bool target_has_loaded_sections = target && target->HasLoadedSections();
642641
if (show_header && !m_sections.empty()) {
643642
s.indent(indent);
644643
s << llvm::formatv(

0 commit comments

Comments
 (0)