diff options
author | midipix <writeonce@midipix.org> | 2016-07-08 23:10:44 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-07-21 03:47:26 -0400 |
commit | e9e742b0e892ca72576c745ac389eabb56c978a1 (patch) | |
tree | 82e016aa916a48ec1cee970d41dded1c86ac6159 | |
parent | 2de078329160a245dc95ab1cec99653e297e257b (diff) | |
download | ptycon-e9e742b0e892ca72576c745ac389eabb56c978a1.tar.bz2 ptycon-e9e742b0e892ca72576c745ac389eabb56c978a1.tar.xz |
driver: added --wait support for slightly more convenient debug sessions.
-rw-r--r-- | include/ptycon/ptycon.h | 1 | ||||
-rw-r--r-- | src/driver/ptyc_driver_ctx.c | 4 | ||||
-rw-r--r-- | src/internal/ptycon_driver_impl.h | 1 | ||||
-rw-r--r-- | src/ptycon.c | 16 | ||||
-rw-r--r-- | src/skin/ptyc_skin_default.c | 7 |
5 files changed, 29 insertions, 0 deletions
diff --git a/include/ptycon/ptycon.h b/include/ptycon/ptycon.h index e725ad7..d91238a 100644 --- a/include/ptycon/ptycon.h +++ b/include/ptycon/ptycon.h @@ -37,6 +37,7 @@ extern "C" { #define PTYC_DRIVER_DBG_EVENT 0x0040 #define PTYC_DRIVER_DBG_OVEN 0x0080 #define PTYC_DRIVER_DBG_RAW 0x0100 +#define PTYC_DRIVER_DBG_WAIT 0x0200 struct ptyc_source_version { int major; diff --git a/src/driver/ptyc_driver_ctx.c b/src/driver/ptyc_driver_ctx.c index c6070e4..cf9b170 100644 --- a/src/driver/ptyc_driver_ctx.c +++ b/src/driver/ptyc_driver_ctx.c @@ -221,6 +221,10 @@ int ptyc_get_driver_ctx( case TAG_CAT: nunits++; break; + + case TAG_WAIT: + cctx.drvflags |= PTYC_DRIVER_DBG_WAIT; + break; } } } diff --git a/src/internal/ptycon_driver_impl.h b/src/internal/ptycon_driver_impl.h index 009ac8e..22b4409 100644 --- a/src/internal/ptycon_driver_impl.h +++ b/src/internal/ptycon_driver_impl.h @@ -25,6 +25,7 @@ enum app_tags { TAG_VERSION, TAG_DEBUG, TAG_CAT, + TAG_WAIT, }; struct ptyc_term_ctx { diff --git a/src/ptycon.c b/src/ptycon.c index dd483b8..18cba4e 100644 --- a/src/ptycon.c +++ b/src/ptycon.c @@ -25,6 +25,19 @@ static void ptycon_exit(int code) code); } +static int ptycon_dbg_helper(int32_t status) +{ + return status ? -1 : 0; +} + +static int ptycon_dbg_init(char ** argv) +{ + if (argv[1] && !(ntapi->tt_strcmp_multibyte(argv[1],"--wait"))) + return ptycon_dbg_helper( + ntapi->tt_wait_for_dummy_event()); + return 0; +} + static int32_t ptycon_start(int argc, char ** argv, char ** envp) { int32_t status; @@ -44,6 +57,9 @@ static int32_t ptycon_start(int argc, char ** argv, char ** envp) envp = rtdata->envp; } + /* early debug (optional) */ + ptycon_dbg_init(argv); + /* no tty session? */ if (!rtdata->srv_keys[0]) return ptyc_main(argc,argv,envp); diff --git a/src/skin/ptyc_skin_default.c b/src/skin/ptyc_skin_default.c index fcf22ce..49033cc 100644 --- a/src/skin/ptyc_skin_default.c +++ b/src/skin/ptyc_skin_default.c @@ -18,5 +18,12 @@ const struct argv_option ptyc_default_options[] = { {"cat", 'c',TAG_CAT,ARGV_OPTARG_REQUIRED,0,0,"<file>", "send %s to the terminal via the pty layer."}, + {"wait", 0,TAG_WAIT,ARGV_OPTARG_NONE,0,0,0, + "wait on a dummy event upon invocation of ptycon_start(); " + "this option has the sole purpose of rendering debub " + "sessions with foreign debuggers more convenient, " + "and must be the first command-line argument " + "passed to the utility."}, + {0,0,0,0,0,0,0,0} }; |