Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions tools/lkl/include/lkl.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,18 +835,6 @@ lkl_netdev_wintap_create(const char *ifparams)
}
#endif


/*
* lkl_register_dbg_handler- register a signal handler that loads a debug lib.
*
* The signal handler is triggered by Ctrl-Z. It creates a new pthread which
* call dbg_entrance().
*
* If you run the program from shell script, make sure you ignore SIGTSTP by
* "trap '' TSTP" in the shell script.
*/
void lkl_register_dbg_handler(void);

/**
* lkl_add_neighbor - add a permanent arp entry
* @ifindex - the ifindex of the interface
Expand Down
2 changes: 0 additions & 2 deletions tools/lkl/lib/Build
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ liblkl-$(LKL_HOST_CONFIG_NT) += nt-host.o
liblkl-y += utils.o
liblkl-y += virtio_blk.o
liblkl-y += virtio.o
liblkl-y += dbg.o
liblkl-y += dbg_handler.o
liblkl-$(LKL_HOST_CONFIG_VIRTIO_NET) += virtio_net.o
liblkl-$(LKL_HOST_CONFIG_VIRTIO_NET_FD) += virtio_net_fd.o
liblkl-$(LKL_HOST_CONFIG_VIRTIO_NET_FD) += virtio_net_tap.o
Expand Down
39 changes: 0 additions & 39 deletions tools/lkl/lib/dbg_handler.c

This file was deleted.

2 changes: 2 additions & 0 deletions tools/lkl/lib/hijack/Build
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ liblkl-hijack-y += preload.o
liblkl-hijack-y += hijack.o
liblkl-hijack-y += init.o
liblkl-hijack-y += xlate.o
liblkl-hijack-y += dbg_handler.o

liblkl-zpoline-y += zpoline.o
liblkl-zpoline-y += hijack.o
Comment thread
ddiss marked this conversation as resolved.
liblkl-zpoline-y += init.o
liblkl-zpoline-y += xlate.o
liblkl-zpoline-y += dbg_handler.o
40 changes: 38 additions & 2 deletions tools/lkl/lib/dbg.c → tools/lkl/lib/hijack/dbg_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include <lkl.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <lkl_host.h>

static int dbg_running = 0;
static const char* PROMOTE = "$";
#define str(x) #x
#define xstr(s) str(s)
Expand Down Expand Up @@ -248,7 +250,7 @@ static void run_cmd() {
}
}

void dbg_entrance() {
static void dbg_entrance() {
char input[MAX_BUF + 1];
int ret;
int c;
Expand All @@ -272,3 +274,37 @@ void dbg_entrance() {
run_cmd();
} while(1);
}

static void dbg_thread(void* arg) {
lkl_host_ops.thread_detach();
printf("======Enter Debug======\n");
dbg_entrance();
printf("======Exit Debug======\n");
dbg_running = 0;
}

void dbg_handler(int signum) {
/* We don't care about the possible race on dbg_running. */
if (dbg_running) {
fprintf(stderr, "A debug lib is running\n");
return;
}
dbg_running = 1;
lkl_host_ops.thread_create(&dbg_thread, NULL);
}

#ifndef __MINGW32__
#include <signal.h>
void lkl_register_dbg_handler() {
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_handler = dbg_handler;
if (sigaction(SIGTSTP, &sa, NULL) == -1) {
perror("sigaction");
}
}
#else
void lkl_register_dbg_handler() {
fprintf(stderr, "lkl_register_dbg_handler is not implemented.\n");
}
#endif
11 changes: 11 additions & 0 deletions tools/lkl/lib/hijack/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ extern int dual_fds[];
void __hijack_init(void);
void __hijack_fini(void);

/*
* lkl_register_dbg_handler- register a signal handler that loads a debug lib.
*
* The signal handler is triggered by Ctrl-Z. It creates a new pthread which
* call dbg_entrance().
*
* If you run the program from shell script, make sure you ignore SIGTSTP by
* "trap '' TSTP" in the shell script.
*/
void lkl_register_dbg_handler(void);

#endif /*_LKL_HIJACK_INIT_H */
Loading