Skip to content

Commit

Permalink
Merge pull request #55 from yonhan3/umbrella-pid-feature
Browse files Browse the repository at this point in the history
Initial commit of bomtrace3 to improve performance
  • Loading branch information
edwarnicke authored Jan 10, 2024
2 parents 7f22f93 + 4ef7d11 commit c9aab01
Show file tree
Hide file tree
Showing 14 changed files with 4,065 additions and 12 deletions.
13 changes: 10 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
WORKDIR /home/vscode
RUN git clone https://github.com/strace/strace.git
WORKDIR /home/vscode/strace
RUN ./bootstrap && ./configure --enable-mpers=check && make
COPY ./patches/bomtrace2.patch ./
COPY ./patches/bomtrace2.patch ./patches/bomtrace3.patch ./
COPY ./src/*.[ch] src/

FROM strace as bomtrace2
WORKDIR /home/vscode/strace
RUN patch -p1 < bomtrace2.patch
RUN make
RUN ./bootstrap && ./configure --enable-mpers=check && make

FROM strace as bomtrace3
WORKDIR /home/vscode/strace
RUN patch -p1 < bomtrace3.patch
RUN ./bootstrap && ./configure --enable-mpers=check && make

FROM base as copy
WORKDIR /in
COPY --from=bomtrace2 /home/vscode/strace/src/strace ./bomtrace2
COPY --from=bomtrace3 /home/vscode/strace/src/strace ./bomtrace3
CMD cp * /out
90 changes: 90 additions & 0 deletions .devcontainer/patches/bomtrace3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
diff --git a/src/Makefile.am b/src/Makefile.am
index 44398cc2b..ff62c9a2f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,6 +63,8 @@ libstrace_a_SOURCES = \
bind.c \
bjm.c \
block.c \
+ bomsh_config.c \
+ bomsh_hook.c \
bpf.c \
bpf_attr.h \
bpf_filter.c \
@@ -334,6 +336,8 @@ libstrace_a_SOURCES = \
sendfile.c \
sg_io_v3.c \
sg_io_v4.c \
+ sha1.c \
+ sha256.c \
shutdown.c \
sigaltstack.c \
sigevent.h \
diff --git a/src/execve.c b/src/execve.c
index a9224543b..c09d2d1d7 100644
--- a/src/execve.c
+++ b/src/execve.c
@@ -13,6 +13,8 @@
*/

#include "defs.h"
+#include "bomsh_config.h"
+#include "bomsh_hook.h"

static void
printargv(struct tcb *const tcp, kernel_ulong_t addr)
@@ -96,6 +98,9 @@ printargc(struct tcb *const tcp, kernel_ulong_t addr)
static void
decode_execve(struct tcb *tcp, const unsigned int index)
{
+ /* record this command and run some prehook analysis */
+ (void)bomsh_record_command(tcp, index);
+
/* pathname */
printpath(tcp, tcp->u_arg[index + 0]);
tprint_arg_next();
diff --git a/src/strace.c b/src/strace.c
index 780e51e91..4067b11e2 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -43,6 +43,8 @@
#include "delay.h"
#include "wait.h"
#include "secontext.h"
+#include "bomsh_config.h"
+#include "bomsh_hook.h"

/* In some libc, these aren't declared. Do it ourself: */
extern char **environ;
@@ -3988,6 +3990,8 @@ dispatch_event(const struct tcb_wait_data *wd)
break;

case TE_EXITED:
+ /* Run the hook program to do analysis */
+ bomsh_hook_program(current_tcp->pid);
print_exited(current_tcp, current_tcp->pid, status);
droptcb(current_tcp);
return true;
@@ -4185,11 +4189,21 @@ terminate(void)
exit(exit_code);
}

+void strace_set_outfname(const char *fname)
+{
+ outfname = fname;
+}
+
+void strace_init(int argc, char *argv[]) {
+ init(argc, argv);
+}
+
int
main(int argc, char *argv[])
{
setlocale(LC_ALL, "");
- init(argc, argv);
+ bomsh_init(argc, argv);
+ //init(argc, argv);

exit_code = !nprocs;

Loading

0 comments on commit c9aab01

Please sign in to comment.