Commit Graph

8 Commits

Author SHA1 Message Date
42bedfc093 Replace fopen_for_input and fopen_for_output with fopen_stream
* largefile_wrappers.h (fopen_for_input, fopen_for_output): Replace
with fopen_stream.
* mmap_cache.c (fopen_for_input) Likewise.
* strace.c (fopen_for_output): Likewise.
2018-02-27 13:14:38 +00:00
fd4c976cf9 Move definitions of fopen_for_input to largefile_wrappers.h
* largefile_wrappers.h (fopen_for_input): Define along with
fopen_for_output.
* mmap_cache.c: Include "largefile_wrappers.h".
(fopen_for_input): Remove.
2018-02-26 23:22:24 +00:00
bbeee0be62 Introduce mmap_cache.h
Let's avoid bloating defs.h and introduce a separate header for
mmap_cache.

* defs.h (struct mmap_cache_t, enum mmap_cache_protection,
enum mmap_cache_rebuild_result, mmap_cache_enable, mmap_cache_is_enabled,
mmap_cache_invalidate, mmap_cache_delete, mmap_cache_rebuild_if_invalid,
mmap_cache_search): Move ...
* mmap_cache.h: ... to this new file.
* Makefile.am (strace_SOURCES): Add mmap_cache.h.
* mmap_cache.c: Include mmap_cache.h.
* strace.c: Likewise.
* syscall.c: Likewise.
* unwind.c: Likewise.
2018-02-26 23:22:24 +00:00
Masatake YAMATO
12f7d721e2 mmap_cache: record device major and minor numbers
* defs.h (struct mmap_cache_t): Add major and minor fields.
* mmap_cache.c (build_mmap_cache): Record device major and minor numbers.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-02-26 23:22:24 +00:00
Masatake YAMATO
c4e4ca97bc mmap_cache: add function to enable mmap_cache
mmap_cache was enabled indirectly via unwind feature.  As now mmap_cache
can be used by other part of strace, a way to enable mmap_cache directly
is needed.

* defs.h (mmap_cache_enable, mmap_cache_is_enabled): New function
prototypes.
* mmap_cache.c (use_mmap_cache): New file local variable.
(mmap_cache_enable, mmap_cache_is_enabled): New functions.
* syscall.c (syscall_exiting_decode): Use mmap_cache_is_enabled()
instead of stack_trace_enabled.
* unwind.c (unwind_init): Invoke mmap_cache_enable.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-02-26 23:22:24 +00:00
Masatake YAMATO
71d33e5e3e mmap_cache: record protection bits
To make mmap_cache reusable, records protection bits of mmap entries.

* defs.h (mmap_cache_protection): New enum.
* mmap_cache.c (build_mmpa_cache): Don't ignore entries that are not
executable, just record the protection bits here.
* unwind.c (print_stack_frame): Ignore entries that are not executable.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-02-26 23:22:24 +00:00
Masatake YAMATO
2bb35360c2 mmap_cache: move code for searching a mmap cache from unwind
print_stack_frame function in unwind.c searches a mmap entry in mmap
cache.  The found entry is then used for unwinding.  However, a function
searching for a mmap entry may be useful for other purposes than
unwinding.

This change re-factors the function; code for searching an entry is
now defined as a stand-alone function named mmap_cache_search.

* defs.h (mmap_cache_search): New function prototype.
print_stack_frame.
* mmap_cached.c (mmap_cache_search): New function derived from
print_stack_frame.
* unwind.c (print_stack_frame): Use it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-02-26 23:22:24 +00:00
Masatake YAMATO
8fd4ef9bef mmap_cache: new subsystem derived from unwind.c
For making mmap cache code reusable from other areas in strace than
unwind, mmap cache related code and unwind related code should be
separated.

This change moves the most of mmap cache code from unwind.c
to mmap_cache.c, a new file.

* unwind.c: Move mmap_cache implementation ...
* mmap_cache.c: ... to this new file.
* Makefile.am (strace_SOURCES): add mmap_cache.c.
* defs.h (struct tcb): Move mmap_cache, mmap_cache_size, and
mmap_cache_generation fields out of [USE_LIBUNWIND] condition.
(mmap_cache_invalidate, mmap_cache_delete,
mmap_cache_rebuild_if_invalid): New function prototypes.
(struct mmap_cache_t, enum mmap_cache_rebuild_result): Move from
unwind.c.
* syscall.c (syscall_exiting_decode): Replace unwind_cache_invalidate
with mmap_cache_invalidate.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-02-26 23:22:24 +00:00