mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-10 06:36:02 +00:00
linux: Add FindMappingWithName to MemoryMap
Bug: crashpad:30 Change-Id: I5e03dc14e3cd1e09ac45cba97922499ec48ea389 Reviewed-on: https://chromium-review.googlesource.com/532753 Commit-Queue: Joshua Peraza <jperaza@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
8e2e805fa5
commit
1c0c305bc9
@ -255,4 +255,16 @@ const MemoryMap::Mapping* MemoryMap::FindMapping(LinuxVMAddress address) const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MemoryMap::Mapping* MemoryMap::FindMappingWithName(
|
||||||
|
const std::string& name) const {
|
||||||
|
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
|
||||||
|
|
||||||
|
for (const auto& mapping : mappings_) {
|
||||||
|
if (mapping.name == name) {
|
||||||
|
return &mapping;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace crashpad
|
} // namespace crashpad
|
||||||
|
@ -63,11 +63,17 @@ class MemoryMap {
|
|||||||
//! \return `true` on success, `false` on failure with a message logged.
|
//! \return `true` on success, `false` on failure with a message logged.
|
||||||
bool Initialize(pid_t pid);
|
bool Initialize(pid_t pid);
|
||||||
|
|
||||||
//! \return The Mapping containing \a address. The caller does not take
|
//! \return The Mapping containing \a address or `nullptr` if no match is
|
||||||
//! ownership of this object. It is scoped to the lifetime of the
|
//! found. The caller does not take ownership of this object. It is scoped
|
||||||
//! MemoryMap object that it was obtained from.
|
//! to the lifetime of the MemoryMap object that it was obtained from.
|
||||||
const Mapping* FindMapping(LinuxVMAddress address) const;
|
const Mapping* FindMapping(LinuxVMAddress address) const;
|
||||||
|
|
||||||
|
//! \return The Mapping with the lowest base address whose name is \a name or
|
||||||
|
//! `nullptr` if no match is found. The caller does not take ownership of
|
||||||
|
//! this object. It is scoped to the lifetime of the MemoryMap object that
|
||||||
|
//! it was obtained from.
|
||||||
|
const Mapping* FindMappingWithName(const std::string& name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Mapping> mappings_;
|
std::vector<Mapping> mappings_;
|
||||||
InitializationStateDcheck initialized_;
|
InitializationStateDcheck initialized_;
|
||||||
|
@ -149,6 +149,7 @@ class MapChildTest : public Multiprocess {
|
|||||||
<< ErrnoMessage("stat");
|
<< ErrnoMessage("stat");
|
||||||
EXPECT_EQ(mapping->device, file_stat.st_dev);
|
EXPECT_EQ(mapping->device, file_stat.st_dev);
|
||||||
EXPECT_EQ(mapping->inode, file_stat.st_ino);
|
EXPECT_EQ(mapping->inode, file_stat.st_ino);
|
||||||
|
EXPECT_EQ(map.FindMappingWithName(mapping->name), mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiprocessChild() override {
|
void MultiprocessChild() override {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user