stap_LDADD += @READLINE_LIBS@
endif
+if HAVE_JSON_C
+stap_SOURCES += language-server/stap-language-server.cxx language-server/stap-code-completion.cxx language-server/jsonrpc.cxx
+stap_LDADD += $(jsonc_LIBS)
+endif
+
if HAVE_BPF_DECLS
stap_SOURCES += bpf-base.cxx bpf-bitset.cxx bpf-translate.cxx bpf-opt.cxx
endif
{ "interactive", no_argument, NULL, LONG_OPT_INTERACTIVE},
{ "example", no_argument, NULL, LONG_OPT_RUN_EXAMPLE},
{ "no-global-var-display", no_argument, NULL, LONG_OPT_NO_GLOBAL_VAR_DISPLAY},
+ { "language-server", no_argument, NULL, LONG_OPT_LANGUAGE_SERVER},
{ NULL, 0, NULL, 0 }
};
LONG_OPT_INTERACTIVE,
LONG_OPT_RUN_EXAMPLE,
LONG_OPT_NO_GLOBAL_VAR_DISPLAY,
+ LONG_OPT_LANGUAGE_SERVER,
};
// NB: when adding new options, consider very carefully whether they
if test "${have_jsonc}" = "yes" -a "${have_ncurses}" = yes; then
AC_DEFINE([HAVE_MONITOR_LIBS],[1],[Define to 1 if json-c and ncurses libraries are installed])
fi
+if test "${have_jsonc}" = "yes"; then
+ AC_DEFINE([HAVE_JSON_C],[1],[Define to 1 if the json-c library is installed])
+fi
fi
AM_CONDITIONAL([HAVE_MONITOR_LIBS], [test "${have_jsonc}" = "yes" -a "${have_ncurses}" = "yes" -a "$enable_monitor" != "no"])
+AM_CONDITIONAL([HAVE_JSON_C], [test "${have_jsonc}" = "yes"])
AC_CACHE_CHECK([for assembler .section "?" flags support], stap_cv_sectionq, [
old_CFLAGS="$CFLAGS"
#ifdef HAVE_LIBREADLINE
#include "interactive.h"
#endif
+
+#include "language-server/stap-language-server.h"
+
#include "bpf.h"
#if ENABLE_NLS
if (rc != 0)
return rc;
+ #ifdef HAVE_JSON_C
+ if(s.language_server_mode){
+ // The language server commuinicates with the client via stdio, so the systemtap verbosity should be 0
+ // Instead the LS verbosity should be set
+ s.language_server = new language_server(&s, s.verbose);
+ s.verbose = 0;
+ for(int i = 0; i < 5; i++)
+ s.perpass_verbose[i] = 0;
+ }
+ #endif
+
// Create the temp dir.
s.create_tmp_dir();
for (unsigned i = 0; i < targets.size(); ++i)
sessions.insert(targets[i]->get_session());
+ if(s.language_server_mode){
+ #ifdef HAVE_JSON_C
+ int r = s.language_server->run();
+ delete s.language_server;
+ return r;
+ #endif
+ }
+
// FIXME: For now, only attempt local interactive use.
if (s.interactive_mode && fake_remote)
{
This option is used to disable the automatic logging of unused global
variables at the end of a stap session.
+.TP
+.B \-\-language\-server
+Language server mode. Start a language server which will communicate via
+stdio. The language server will respect stap verbosity.
+
.SH ARGUMENTS
Any additional arguments on the command line are passed to the script
timeout = 0;
use_bpf_raw_tracepoint = false;
symbol_resolver = 0;
+ language_server = 0;
+ language_server_mode = false;
// PR12443: put compiled-in / -I paths in front, to be preferred during
// tapset duplicate-file elimination
no_global_var_display = other.no_global_var_display;
pass_1a_complete = other.pass_1a_complete;
timeout = other.timeout;
+ language_server_mode = other.language_server_mode;
+ language_server = other.language_server;
// don't bother copy typequery_memo
include_path = other.include_path;
#endif
#ifdef HAVE_MONITOR_LIBS
<< " MONITOR_LIBS"
+#endif
+#ifdef HAVE_JSON_C
+ << " JSON_C"
#endif
<< endl;
}
#if HAVE_MONITOR_LIBS
" --monitor=INTERVAL\n"
" enables runtime interactive monitoring\n"
+#endif
+#ifdef HAVE_JSON_C
+ " --language-server\n"
+ " starts a systemtap language server\n"
#endif
, compatible.c_str()) << endl
;
no_global_var_display = true;
break;
+ case LONG_OPT_LANGUAGE_SERVER:
+ language_server_mode = true;
+ break;
+
case '?':
// Invalid/unrecognized option given or argument required, but
// not given. In both cases getopt_long() will have printed the
args.push_back (string (argv[i]));
}
- // We don't need a script with --list-servers, --trust-servers, or any dump mode
+ // We don't need a script with --list-servers, --trust-servers, or any dump mode, or a lang-server
bool need_script = server_status_strings.empty () &&
server_trust_spec.empty () &&
- !dump_mode && !interactive_mode;
+ !dump_mode && !interactive_mode && !language_server_mode;
if (benchmark_sdt_loops > 0 || benchmark_sdt_threads > 0)
{
cerr << _("Cannot specify -i with -l/-L/--dump-* switches.") << endl;
usage(1);
}
+ if (dump_mode && language_server_mode)
+ {
+ cerr << _("Cannot specify --language-server with -l/-L/--dump-* switches.") << endl;
+ usage(1);
+ }
if (dump_mode && monitor)
{
cerr << _("Cannot specify --monitor with -l/-L/--dump-* switches.") << endl;
usage(1);
}
// FIXME: we need to think through other options that shouldn't be
- // used with '-i'.
+ // used with '-i' and '--language-server'.
// ignore any -E bits in list modes; their presence could flip the
// process result code even if list results are empty
}
#endif
+#if ! HAVE_JSON_C
+ if (language_server_mode)
+ {
+ print_warning("Language server mode is not supported by this version of systemtap");
+ exit(1);
+ }
+#endif
+
if (runtime_specified && ! specified_servers.empty ())
{
print_warning("Ignoring --use-server due to the use of -R");
struct module_cache;
struct update_visitor;
struct compile_server_cache;
+class language_server;
// XXX: a generalized form of this descriptor could be associated with
// a vardecl instead of out here at the systemtap_session level.
// PR25841, for early probe-derivation-time symbol resolution
symresolution_info* symbol_resolver; // may be NULL
+ bool language_server_mode;
+ class language_server* language_server;
+
// NB: It is very important for all of the above (and below) fields
// to be cleared in the systemtap_session ctor (session.cxx).