File tree Expand file tree Collapse file tree 6 files changed +51
-55
lines changed
Expand file tree Collapse file tree 6 files changed +51
-55
lines changed Original file line number Diff line number Diff line change @@ -835,18 +835,6 @@ lkl_netdev_wintap_create(const char *ifparams)
835835}
836836#endif
837837
838-
839- /*
840- * lkl_register_dbg_handler- register a signal handler that loads a debug lib.
841- *
842- * The signal handler is triggered by Ctrl-Z. It creates a new pthread which
843- * call dbg_entrance().
844- *
845- * If you run the program from shell script, make sure you ignore SIGTSTP by
846- * "trap '' TSTP" in the shell script.
847- */
848- void lkl_register_dbg_handler (void );
849-
850838/**
851839 * lkl_add_neighbor - add a permanent arp entry
852840 * @ifindex - the ifindex of the interface
Original file line number Diff line number Diff line change @@ -11,8 +11,6 @@ liblkl-$(LKL_HOST_CONFIG_NT) += nt-host.o
1111liblkl-y += utils.o
1212liblkl-y += virtio_blk.o
1313liblkl-y += virtio.o
14- liblkl-y += dbg.o
15- liblkl-y += dbg_handler.o
1614liblkl-$(LKL_HOST_CONFIG_VIRTIO_NET) += virtio_net.o
1715liblkl-$(LKL_HOST_CONFIG_VIRTIO_NET_FD) += virtio_net_fd.o
1816liblkl-$(LKL_HOST_CONFIG_VIRTIO_NET_FD) += virtio_net_tap.o
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ liblkl-hijack-y += preload.o
22liblkl-hijack-y += hijack.o
33liblkl-hijack-y += init.o
44liblkl-hijack-y += xlate.o
5+ liblkl-hijack-y += dbg_handler.o
56
67liblkl-zpoline-y += zpoline.o
78liblkl-zpoline-y += hijack.o
89liblkl-zpoline-y += init.o
910liblkl-zpoline-y += xlate.o
11+ liblkl-zpoline-y += dbg_handler.o
Original file line number Diff line number Diff line change 22#include <lkl.h>
33#include <limits.h>
44#include <string.h>
5- #include <stdio.h>
65#include <stdlib.h>
6+ #include <stdio.h>
7+ #include <lkl_host.h>
78
9+ static int dbg_running = 0 ;
810static const char * PROMOTE = "$" ;
911#define str (x ) #x
1012#define xstr (s ) str(s)
@@ -248,7 +250,7 @@ static void run_cmd() {
248250 }
249251}
250252
251- void dbg_entrance () {
253+ static void dbg_entrance () {
252254 char input [MAX_BUF + 1 ];
253255 int ret ;
254256 int c ;
@@ -272,3 +274,37 @@ void dbg_entrance() {
272274 run_cmd ();
273275 } while (1 );
274276}
277+
278+ static void dbg_thread (void * arg ) {
279+ lkl_host_ops .thread_detach ();
280+ printf ("======Enter Debug======\n" );
281+ dbg_entrance ();
282+ printf ("======Exit Debug======\n" );
283+ dbg_running = 0 ;
284+ }
285+
286+ void dbg_handler (int signum ) {
287+ /* We don't care about the possible race on dbg_running. */
288+ if (dbg_running ) {
289+ fprintf (stderr , "A debug lib is running\n" );
290+ return ;
291+ }
292+ dbg_running = 1 ;
293+ lkl_host_ops .thread_create (& dbg_thread , NULL );
294+ }
295+
296+ #ifndef __MINGW32__
297+ #include <signal.h>
298+ void lkl_register_dbg_handler () {
299+ struct sigaction sa ;
300+ sigemptyset (& sa .sa_mask );
301+ sa .sa_handler = dbg_handler ;
302+ if (sigaction (SIGTSTP , & sa , NULL ) == -1 ) {
303+ perror ("sigaction" );
304+ }
305+ }
306+ #else
307+ void lkl_register_dbg_handler () {
308+ fprintf (stderr , "lkl_register_dbg_handler is not implemented.\n" );
309+ }
310+ #endif
Original file line number Diff line number Diff line change @@ -7,4 +7,15 @@ extern int dual_fds[];
77void __hijack_init (void );
88void __hijack_fini (void );
99
10+ /*
11+ * lkl_register_dbg_handler- register a signal handler that loads a debug lib.
12+ *
13+ * The signal handler is triggered by Ctrl-Z. It creates a new pthread which
14+ * call dbg_entrance().
15+ *
16+ * If you run the program from shell script, make sure you ignore SIGTSTP by
17+ * "trap '' TSTP" in the shell script.
18+ */
19+ void lkl_register_dbg_handler (void );
20+
1021#endif /*_LKL_HIJACK_INIT_H */
You can’t perform that action at this time.
0 commit comments