Skip to content

Commit 2bc1e68

Browse files
committed
Better symbol status, address range in modules view.
1 parent dbf75a6 commit 2bc1e68

3 files changed

Lines changed: 58 additions & 17 deletions

File tree

extension/modulesView.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,22 @@ export class ModuleTreeDataProvider extends DisposableSubscriber
8080
let module = element as Module;
8181
let props = [];
8282
if (module.path)
83-
props.push(new ModuleProperty('path', module.path));
83+
props.push(new ModuleProperty('Path', module.path));
8484
if (module.version)
85-
props.push(new ModuleProperty('version', module.version));
85+
props.push(new ModuleProperty('Version', module.version));
86+
if (module.addressRange)
87+
props.push(new ModuleProperty('Address range', module.addressRange));
8688
if (module.symbolStatus)
87-
props.push(new ModuleProperty('symbols', module.symbolStatus));
89+
props.push(new ModuleProperty('Symbols', module.symbolStatus));
8890
if (module.symbolFilePath)
89-
props.push(new ModuleProperty('symbol file path', module.symbolFilePath));
90-
if (module.addressRange)
91-
props.push(new ModuleProperty('load address', module.addressRange));
91+
props.push(new ModuleProperty('Symbol file', module.symbolFilePath));
9292
return props;
9393
}
9494
}
9595

9696
getTreeItem(element: Element): TreeItem {
9797
if (element instanceof ModuleProperty) {
98-
let item = new TreeItem(`${element.key}: ${element.value}`);
98+
let item = new TreeItem(`${element.key}: ${element.value}`);
9999
item.contextValue = 'lldb.moduleProperty';
100100
return item;
101101
} else {

src/codelldb/src/debug_session.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,27 +1623,45 @@ impl DebugSession {
16231623
}
16241624

16251625
fn make_module_detail(&self, module: &SBModule) -> Module {
1626-
let mut msg = Module {
1626+
let mut mod_info = Module {
16271627
id: ModuleId::String(self.module_id(&module)),
16281628
name: module.file_spec().filename().display().to_string(),
16291629
path: Some(module.file_spec().path().display().to_string()),
16301630
..Default::default()
16311631
};
16321632

1633-
let header_addr = module.object_header_address();
1634-
if header_addr.is_valid() {
1635-
msg.address_range = Some(format!("{:X}", header_addr.load_address(&self.target)));
1633+
let version = module.version();
1634+
if !version.is_empty() {
1635+
let version_str = version.iter().map(u32::to_string).collect::<Vec<_>>().join(".");
1636+
mod_info.version = Some(version_str);
16361637
}
16371638

1638-
let symbols = module.symbol_file_spec();
1639-
if symbols.is_valid() {
1640-
msg.symbol_status = Some("Symbols loaded.".into());
1641-
msg.symbol_file_path = Some(module.symbol_file_spec().path().display().to_string());
1639+
let range_start = module.object_header_address().load_address(&self.target);
1640+
let mut range_end = range_start;
1641+
for section in module.sections() {
1642+
let sec_start = section.load_address(&self.target);
1643+
if sec_start != INVALID_ADDRESS {
1644+
let sec_end = sec_start + section.byte_size() as Address;
1645+
range_end = cmp::max(range_end, sec_end);
1646+
}
1647+
}
1648+
mod_info.address_range = Some(format!("{:X} - {:X}", range_start, range_end));
1649+
1650+
let symbol_status = if module.num_compile_units() > 0 {
1651+
"Source debug info"
1652+
} else if module.num_symbols() > 0 {
1653+
"Public symbols only"
16421654
} else {
1643-
msg.symbol_status = Some("Symbols not found".into())
1655+
"No symbols"
1656+
};
1657+
mod_info.symbol_status = Some(symbol_status.into());
1658+
1659+
let symbol_file = module.symbol_file_spec();
1660+
if symbol_file.is_valid() {
1661+
mod_info.symbol_file_path = Some(module.symbol_file_spec().path().display().to_string());
16441662
}
16451663

1646-
msg
1664+
mod_info
16471665
}
16481666

16491667
fn handle_thread_event(&mut self, event: &SBThreadEvent) {

src/lldb/src/sb/sbmodule.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ impl SBModule {
1515
unsafe { Some(get_str(ptr)) }
1616
}
1717
}
18+
pub fn version(&self) -> Vec<u32> {
19+
let mut versions = [0; 16];
20+
let ptr = versions.as_mut_ptr();
21+
let len = versions.len();
22+
let count = cpp!(unsafe [self as "SBModule*", ptr as "uint32_t*", len as "size_t"] -> u32 as "uint32_t" {
23+
return self->GetVersion(ptr, len);
24+
});
25+
let count = std::cmp::min(count as usize, versions.len());
26+
Vec::from(&versions[..count])
27+
}
1828
pub fn file_spec(&self) -> SBFileSpec {
1929
cpp!(unsafe [self as "SBModule*"] -> SBFileSpec as "SBFileSpec" {
2030
return self->GetFileSpec();
@@ -66,6 +76,19 @@ impl SBModule {
6676
pub fn compile_units<'a>(&'a self) -> impl Iterator<Item = SBCompileUnit> + 'a {
6777
SBIterator::new(self.num_compile_units(), move |index| self.compile_unit_at_index(index))
6878
}
79+
pub fn num_sections(&self) -> u32 {
80+
cpp!(unsafe [self as "SBModule*"] -> u32 as "uint32_t" {
81+
return self->GetNumSections();
82+
})
83+
}
84+
pub fn section_at_index(&self, index: u32) -> SBSection {
85+
cpp!(unsafe [self as "SBModule*", index as "uint32_t"] -> SBSection as "SBSection" {
86+
return self->GetSectionAtIndex(index);
87+
})
88+
}
89+
pub fn sections<'a>(&'a self) -> impl Iterator<Item = SBSection> + 'a {
90+
SBIterator::new(self.num_sections(), move |index| self.section_at_index(index))
91+
}
6992
}
7093

7194
impl IsValid for SBModule {

0 commit comments

Comments
 (0)