-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
219 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <fcntl.h> | ||
#include <ft_printf.h> | ||
#include <macros.h> | ||
#include <fcntl.h> | ||
#include "param_log.h" | ||
|
||
static const flag_str_t advice_flags[] = { | ||
FLAG_STR(POSIX_FADV_NORMAL), | ||
FLAG_STR(POSIX_FADV_RANDOM), | ||
FLAG_STR(POSIX_FADV_SEQUENTIAL), | ||
FLAG_STR(POSIX_FADV_WILLNEED), | ||
FLAG_STR(POSIX_FADV_DONTNEED), | ||
FLAG_STR(POSIX_FADV_NOREUSE), | ||
}; | ||
|
||
int log_ADVISE(uint64_t value) | ||
{ | ||
return option_log(value, advice_flags, ELEM_COUNT(advice_flags), "POSIX_FADV_???"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "param_log.h" | ||
#include <ft_printf.h> | ||
#include <macros.h> | ||
#include <sys/epoll.h> | ||
|
||
static const flag_str_t epoll_ctl_cmd_options[] = { | ||
FLAG_STR(EPOLL_CTL_ADD), | ||
FLAG_STR(EPOLL_CTL_DEL), | ||
FLAG_STR(EPOLL_CTL_MOD), | ||
}; | ||
|
||
int log_EPOLL_CTL_CMD(uint64_t value) | ||
{ | ||
return option_log(value, epoll_ctl_cmd_options, ELEM_COUNT(epoll_ctl_cmd_options), | ||
"EPOLL_CTL_???"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "param_log.h" | ||
#include <ft_printf.h> | ||
#include <macros.h> | ||
#include <sys/epoll.h> | ||
|
||
static const flag_str_t events_flags[] = { | ||
FLAG_STR(EPOLLIN), FLAG_STR(EPOLLPRI), FLAG_STR(EPOLLOUT), FLAG_STR(EPOLLRDNORM), | ||
FLAG_STR(EPOLLRDBAND), FLAG_STR(EPOLLWRNORM), FLAG_STR(EPOLLWRBAND), FLAG_STR(EPOLLMSG), | ||
FLAG_STR(EPOLLERR), FLAG_STR(EPOLLHUP), FLAG_STR(EPOLLRDHUP), FLAG_STR(EPOLLEXCLUSIVE), | ||
FLAG_STR(EPOLLWAKEUP), FLAG_STR(EPOLLONESHOT), FLAG_STR(EPOLLET), | ||
}; | ||
|
||
int log_local_epoll_event_struct(struct epoll_event *event) | ||
{ | ||
int size_written = ft_dprintf(STDERR_FILENO, "{.events="); | ||
size_written += flags_log(event->events, events_flags, ELEM_COUNT(events_flags)); | ||
size_written += ft_dprintf(STDERR_FILENO, ", .data="); | ||
if (event->events & EPOLLIN || event->events & EPOLLPRI || event->events & EPOLLRDNORM || | ||
event->events & EPOLLRDBAND) | ||
size_written += ft_dprintf(STDERR_FILENO, "%d", event->data.fd); | ||
else | ||
size_written += ft_dprintf(STDERR_FILENO, "%lu", event->data.u64); | ||
size_written += ft_dprintf(STDERR_FILENO, "}"); | ||
return size_written; | ||
} | ||
|
||
int log_EPOLL_EVENT_STRUCT(uint64_t value, syscall_log_param_t *context) | ||
{ | ||
STRUCT_HANDLE(struct epoll_event, event); | ||
if (context->is_return_log && event.events == 0 && event.data.u64 == 0) | ||
return ft_dprintf(STDERR_FILENO, "(Timeout)"); | ||
return log_local_epoll_event_struct(&event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "param_log.h" | ||
#include <ft_printf.h> | ||
#include <sys/epoll.h> | ||
#include <macros.h> | ||
|
||
int log_EPOLL_EVENT_STRUCT_ARRAY(uint64_t value, syscall_log_param_t *context) | ||
{ | ||
int size_written = 0; | ||
void *remote_ptr = handle_ptr(value, context, &size_written); | ||
if (remote_ptr == NULL) | ||
return size_written; | ||
long event_count = registers_get_return(context->regs, context->type); | ||
struct epoll_event *events = malloc(sizeof(struct epoll_event) * event_count); | ||
if (events == NULL) | ||
{ | ||
log_error("log_EPOLL_EPOLL_EVENT_STRUCT_ARRAY", "malloc failed", true); | ||
return size_written; | ||
} | ||
if (remote_memcpy(events, context->pid, remote_ptr, sizeof(struct epoll_event) * event_count) < 0) | ||
{ | ||
log_error("log_EPOLL_EPOLL_EVENT_STRUCT_ARRAY", "remote_memcpy failed", true); | ||
free(events); | ||
return size_written; | ||
} | ||
size_written += ft_dprintf(STDERR_FILENO, "["); | ||
bool_t first = true; | ||
for (long i = 0; i < event_count; i++) | ||
{ | ||
if (!first) | ||
size_written += ft_dprintf(STDERR_FILENO, ", "); | ||
first = false; | ||
size_written += log_local_epoll_event_struct(&events[i]); | ||
} | ||
size_written += ft_dprintf(STDERR_FILENO, "]"); | ||
free(events); | ||
return size_written; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "param_log.h" | ||
#include <ft_printf.h> | ||
#include <libaio.h> | ||
|
||
int log_IO_EVENT_STRUCT(uint64_t value, syscall_log_param_t *context) | ||
{ | ||
int size_written = 0; | ||
void *remote_ptr = handle_ptr(value, context, &size_written); | ||
if (remote_ptr == NULL) | ||
return size_written; | ||
long event_count = registers_get_return(context->regs, context->type); | ||
struct io_event *events = malloc(sizeof(struct io_event) * event_count); | ||
if (events == NULL) | ||
{ | ||
log_error("log_IO_EVENT_STRUCT", "malloc failed", true); | ||
return size_written; | ||
} | ||
if (remote_memcpy(events, context->pid, remote_ptr, sizeof(struct io_event) * event_count) < 0) | ||
{ | ||
log_error("log_IO_EVENT_STRUCT", "remote_memcpy failed", true); | ||
free(events); | ||
return size_written; | ||
} | ||
size_written += ft_dprintf(STDERR_FILENO, "["); | ||
bool_t first = true; | ||
for (long i = 0; i < event_count; i++) | ||
{ | ||
if (!first) | ||
size_written += ft_dprintf(STDERR_FILENO, ", "); | ||
first = false; | ||
size_written += ft_dprintf(STDERR_FILENO, "{.data=%lu, .obj=%lu, .res=%ld, .res2=%ld}", | ||
events[i].data, events[i].obj, events[i].res, events[i].res2); | ||
} | ||
size_written += ft_dprintf(STDERR_FILENO, "]"); | ||
free(events); | ||
return size_written; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <time.h> | ||
|
||
#include "param_log.h" | ||
#include <ft_printf.h> | ||
|
||
int log_TIME_T(uint64_t value, syscall_log_param_t *context) | ||
{ | ||
STRUCT_HANDLE(time_t, tv); | ||
return ft_dprintf(STDERR_FILENO, "%ld", tv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters