Skip to content

Commit

Permalink
canal cleanups
Browse files Browse the repository at this point in the history
Add a "fileEnd" to segments; relax restriction on values being congruent
to 0 mod 4.
  • Loading branch information
peadar committed Oct 27, 2023
1 parent 9490d48 commit 516b96d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions canal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ mainExcept(int argc, char *argv[])
for (auto &segment : as ) {
if (verbose) {
IOFlagSave _(*debug);
*debug << "scan " << hex << segment.start << " to " << segment.start + segment.end;
*debug << "scan " << hex << segment.start << " to " << segment.start + segment.fileEnd;
}
if (findstr != "") {
std::vector<char> corestr;
corestr.resize(std::max(size_t(4096UL), findstr.size() * 4));
for (size_t in, memPos = segment.start, corestrPos = 0; memPos < segment.end; memPos += in) {
size_t freeCorestr = corestr.size() - corestrPos;
size_t remainingSegment = segment.end - memPos;
size_t remainingSegment = segment.fileEnd - memPos;
size_t readsize = std::min(remainingSegment, freeCorestr);
in = process->io->read(memPos, readsize, corestr.data() + corestrPos);
assert(in == readsize);
Expand All @@ -307,7 +307,7 @@ mainExcept(int argc, char *argv[])
const size_t step = sizeof(Elf::Off);
const size_t chunk_size = 1'048'576;
Elf::Addr loc=segment.start;
const Elf::Addr end_loc = segment.end;
const Elf::Addr end_loc = segment.fileEnd;
while (loc < end_loc) {
size_t read_size = std::min(chunk_size, end_loc - loc);
data.resize(read_size/step);
Expand All @@ -328,7 +328,7 @@ mainExcept(int argc, char *argv[])
const auto & p=*it;
if (searchaddrs.size()) {
for (auto range = searchaddrs.begin(); range != searchaddrs.end(); ++range) {
if (p >= range->first && p < range->second && (p % 4 == 0)) {
if (p >= range->first && p < range->second) {
IOFlagSave _(cout);
cout << "0x" << hex << loc << dec << "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion dead.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ CoreProcess::addressSpace() const {
if (ub->first >= hdr.p_vaddr && ub->second.second.end <= hdr.p_vaddr + hdr.p_memsz)
name = ub->second.first;
}
rv.push_back({hdr.p_vaddr, hdr.p_vaddr + hdr.p_memsz, 0, {0, 0, 0, name}, {}});
rv.push_back({hdr.p_vaddr, hdr.p_vaddr + hdr.p_memsz, hdr.p_vaddr + hdr.p_filesz, 0, {0, 0, 0, name}, {}});
}
return rv;
}
Expand Down
1 change: 1 addition & 0 deletions libpstack/proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct DevNode {
struct AddressRange {
Elf::Addr start;
Elf::Addr end;
Elf::Addr fileEnd;
off_t offset;
DevNode backing;

Expand Down
2 changes: 1 addition & 1 deletion live.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Process::procAddressSpace(const std::string &fn) {
if (c != '-')
flags.insert(flagmap.at(c));
}
rv.push_back({start, end, offset, {major, minor, inode, path}, flags });
rv.push_back({start, end, end, offset, {major, minor, inode, path}, flags });
}
return rv;
}
Expand Down

0 comments on commit 516b96d

Please sign in to comment.