libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
memory.cxx
1// clues
2#include <clues/syscalls/memory.hxx>
3
4namespace clues {
5
6bool MmapSystemCall::implementsOldMmap() const {
7 switch (abi()) {
8 case ABI::I386: return true;
9 default: return false;
10 }
11}
12
14 /*
15 * setup parameters for legacy / new variant of mmap()
16 */
17 if (callNr() == SystemCallNr::MMAP2 || !implementsOldMmap()) {
18 old_args.reset();
19 setParameters(hint, length, protection, flags, fd, offset);
20 } else {
21 old_args.emplace(item::OldMmapArgs{});
22 setParameters(*old_args);
23 }
24}
25
27 /*
28 * we use this callback not for rearranging the parameters, but for
29 * synchronizing the regular mmap arguments with the legacy struct
30 * mmap data.
31 */
32 if (isOldMmap()) {
33 const auto &args = *old_args;
34 hint.fill(proc, Word{cosmos::to_integral(args.addr())});
35 length.fill(proc, Word{args.length()});
36 protection.fill(proc, Word{static_cast<elf_greg_t>(args.prot().raw())});
37 flags.fill(proc, Word{static_cast<elf_greg_t>(cosmos::to_integral(args.type()) | args.flags().raw())});
38 fd.fill(proc, Word{static_cast<elf_greg_t>(cosmos::to_integral(args.fd()))});
39 offset.fill(proc, Word{args.offset()});
40 }
41 return false;
42}
43
44} // end ns
ABI abi() const
Returns the system call ABi seen during system call entry.
SystemCallNr callNr() const
Returns the system call table number for this system call.
Base class for traced processes.
Definition Tracee.hxx:39
Combined mmap() arguments for the old variant of mmap() on 32-bit ABIs like I386.
Definition mmap.hxx:76
Word
An integer that is able to hold a word for the current architecture.
Definition types.hxx:38
bool check2ndPass(const Tracee &) override
Check whether a second pass needs to be made processing parameters.
Definition memory.cxx:26
void prepareNewSystemCall() override
Perform any necessary actions before processing a new system call entry event.
Definition memory.cxx:13