--- a/config.in +++ b/config.in @@ -219,6 +219,10 @@ /* Define to 1 if you have the `w' library (-lw). */ #undef HAVE_LIBW +/* Define to 1 if you have the `babeltrace' library + (-lbabeltrace -lbabeltrace-ctf). */ +#undef HAVE_LIBBABELTRACE + /* Define to 1 if you have the header file. */ #undef HAVE_LINK_H --- a/configure +++ b/configure @@ -13534,6 +13534,337 @@ if test "$enable_gdbserver" = "yes" -a " as_fn_error "Automatic gdbserver build is not supported for this configuration" "$LINENO" 5 fi +# Check whether --enable-ctf-target was given. +if test "${enable_ctf_target+set}" = set; then : + enableval=$enable_ctf_target; case "${enableval}" in + yes| no|auto) ;; + *) as_fn_error "bad value ${enableval} for --enable-ctf-target option" "$LINENO" 5 ;; +esac +else + enable_ctf_target=auto +fi + +if test "$enable_ctf_target" = "yes" || test "$enable_ctf_target" = "auto"; then + pkg_config_args=glib-2.0 + for module in . gmodule + do + case "$module" in + gmodule) + pkg_config_args="$pkg_config_args gmodule-2.0" + ;; + gmodule-no-export) + pkg_config_args="$pkg_config_args gmodule-no-export-2.0" + ;; + gobject) + pkg_config_args="$pkg_config_args gobject-2.0" + ;; + gthread) + pkg_config_args="$pkg_config_args gthread-2.0" + ;; + gio*) + pkg_config_args="$pkg_config_args $module-2.0" + ;; + esac + done + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. + set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } + if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 + else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + for as_dir in $PATH + do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi + done + done + IFS=$as_save_IFS + ;; + esac + fi + PKG_CONFIG=$ac_cv_path_PKG_CONFIG + if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 + $as_echo "$PKG_CONFIG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } + fi + fi + if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. + set dummy pkg-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } + if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 + else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + for as_dir in $PATH + do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi + done + done + IFS=$as_save_IFS + ;; + esac + fi + ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG + if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 + $as_echo "$ac_pt_PKG_CONFIG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } + fi + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in + yes:) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 + $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} + ac_tool_warned=yes ;; + esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi + else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" + fi + fi + + if test "x$PKG_CONFIG" = x ; then + no_glib=yes + PKG_CONFIG=no + fi + + min_glib_version=2.22.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB - version >= $min_glib_version" >&5 + $as_echo_n "checking for GLIB - version >= $min_glib_version... " >&6; } + if test x$PKG_CONFIG != xno ; then + enable_glibtest=yes + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + $as_echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" + enable_glibtest=no + fi + if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then + : + else + no_glib=yes + fi + fi + + if test x"$no_glib" = x ; then + GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` + GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` + GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` + GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable=glib_compile_resources gio-2.0` + + GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` + GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` + glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS -lbabeltrace -lbabeltrace-ctf" + rm -f conf.glibtest + if test "$cross_compiling" = yes; then : + echo $ac_n "cross compiling; assumed OK... $ac_c" + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ + unsigned int major, minor, micro; + char *tmp_version; + + fclose (fopen ("conf.glibtest", "w")); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%u.%u.%u", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } + + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n", + major, minor, micro); + printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} + +_ACEOF + if ac_fn_c_try_run "$LINENO"; then : + + else + no_glib=yes + fi + rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.beam conftest.$ac_ext + fi + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version $glib_config_major_version $glib_config_minor_version.$glib_config_micro_version)" >&5 + $as_echo "yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)" >&6; } + $as_echo "#define HAVE_LIBBABELTRACE 1" >>confdefs.h + LIBS="-lbabeltrace -lbabeltrace-ctf $LIBS" + CPPFLAGS="$CPPFLAGS $GLIB_CFLAGS" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } + if test "$PKG_CONFIG" = "no" ; then + $as_echo "*** A new enough version of pkg-config was not found." + $as_echo "*** See http://www.freedesktop.org/software/pkgconfig/" + else + if test -f conf.glibtest ; then + : + else + $as_echo "*** Could not run GLIB and libbabeltrace test program, checking why..." + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); + ; + return 0; +} +_ACEOF + if ac_fn_c_try_link "$LINENO"; then : + $as_echo "*** The test program compiled, but did not run. This usually means" + $as_echo "*** that the run-time linker is not finding GLIB or finding the wrong" + $as_echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + $as_echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + $as_echo "*** to the installed location Also, make sure you have run ldconfig if that" + $as_echo "*** is required on your system" + $as_echo "***" + $as_echo "*** If you have an old version installed, it is best to remove it, although" + $as_echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" + else + $as_echo "*** The test program failed to compile or link. See the file config.log for the" + $as_echo "*** exact error that occured. This usually means GLIB is incorrectly installed." + fi + rm -f core conftest.err conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + GLIB_GENMARSHAL="" + GOBJECT_QUERY="" + GLIB_MKENUMS="" + GLIB_COMPILE_RESOURCES="" + if test "$enable_ctf_target" = "yes"; then + as_fn_error "glib and libbabeltrace are required in order to enable CTF target" "$LINENO" 5 + else + enable_ctf_target = no + fi + fi + rm -f conf.glibtest +fi +if test "$enable_ctf_target" = "no"; then + : +fi + + # If nativefile (NAT_FILE) is not set in config/*/*.m[ht] files, we link # to an empty version. --- a/ctf.c +++ b/ctf.c @@ -1210,3 +1210,455 @@ Traceframe %d is dropped because type of do_cleanups (old_chain); } + +#ifdef HAVE_LIBBABELTRACE +#include +#include +#include +#include + +static struct bt_context *ctx = NULL; +static struct bt_ctf_iter *iter = NULL; +static int current_tp; +static struct bt_ctf_event *ctf_event; + +static struct target_ops ctf_ops; + +static void +bt_ctf_close (void) +{ + if (iter) + { + bt_ctf_iter_destroy (iter); + iter = NULL; + } + if (ctx) + { + bt_context_put (ctx); + ctx = NULL; + } +} + +static void +bt_ctf_open (char *dirname) +{ + int ret; + struct bt_iter_pos begin_pos; + + ctx = bt_context_create(); + if (!ctx) + error (_("Try to use libbabeltrace got error")); + ret = bt_context_add_trace(ctx, dirname, "ctf", NULL, NULL, NULL); + if (ret < 0) + { + bt_ctf_close (); + error (_("Try to open \"%s\" got error"), dirname); + } + + begin_pos.type = BT_SEEK_BEGIN; + iter = bt_ctf_iter_create(ctx, &begin_pos, NULL); + if (!iter) + { + bt_ctf_close (); + error (_("Try to open \"%s\" got error"), dirname); + } + + current_tp = 0; + ctf_event = bt_ctf_iter_read_event(iter); + if (!ctf_event) + { + bt_ctf_close (); + error (_("Try to open \"%s\" got error"), dirname); + } +} + +static const struct definition * +bt_ctf_find_field (const struct definition *d, const char *name) +{ + struct definition const * const *list_d; + unsigned int list_d_count, i; + + if (bt_ctf_get_field_list (ctf_event, d, &list_d, &list_d_count)) + return NULL; + for (i = 0; i < list_d_count; i++) + { + if (strcmp (bt_ctf_field_name(list_d[i]), name) == 0) + return list_d[i]; + } + + return NULL; +} + +static int +bt_ctf_event_id (int *tpp) +{ + const struct definition *top_d; + struct definition const * const *list_d; + unsigned int list_d_count, i; + const struct definition *d_id = NULL; + const struct definition *d_v = NULL; + + top_d = bt_ctf_get_top_level_scope(ctf_event, BT_STREAM_EVENT_HEADER); + if (!top_d) + return -1; + if (bt_ctf_get_field_list (ctf_event, top_d, &list_d, &list_d_count)) + return -1; + + for (i = 0; i < list_d_count; i++) + { + if (strcmp (bt_ctf_field_name(list_d[i]), "id") == 0) + d_id = list_d[i]; + else if (strcmp (bt_ctf_field_name(list_d[i]), "v") == 0) + d_v = list_d[i]; + if (d_id && d_v) + break; + } + if (!d_id) + return -1; + +getval: + switch (bt_ctf_field_type (bt_ctf_get_decl_from_def (d_id))) + { + case CTF_TYPE_INTEGER: + { + int64_t val; + + if (get_int_signedness(d_id)) + val = bt_ctf_get_int64 (d_id); + else + val = bt_ctf_get_uint64 (d_id); + if (val < INT_MIN || val > INT_MAX) + { + warning (_("tracepoint id is too big or too small.")); + return -1; + } + *tpp = (int) val; + } + break; + + case CTF_TYPE_ENUM: + if (strcmp (bt_ctf_get_enum_str (d_id), "compact") == 0) + d_id = bt_ctf_get_enum_int (d_id); + else + { + if (!d_v) + return -1; + if (bt_ctf_field_type (bt_ctf_get_decl_from_def (d_v)) + != CTF_TYPE_VARIANT) + return -1; + + d_v = bt_ctf_find_field (d_v, "extended"); + if (!d_v) + return -1; + if (bt_ctf_field_type (bt_ctf_get_decl_from_def (d_v)) + != CTF_TYPE_STRUCT) + return -1; + d_id = bt_ctf_find_field (d_v, "id"); + if (!d_id) + return -1; + } + goto getval; + break; + + default: + warning (_("type of tracepoint id is not support.")); + return -1; + break; + } + + return 0; +} + +static struct value * +bt_ctf_def_to_val (const struct definition *def) +{ + struct value *ret = NULL; + + if (!def) + return ret; + + /* XXX: some types are not support. */ + switch (bt_ctf_field_type (bt_ctf_get_decl_from_def (def))) + { + case CTF_TYPE_INTEGER: + if (get_int_signedness(def)) + { + int64_t val; + val = bt_ctf_get_int64 (def); + ret = value_from_longest + (builtin_type (target_gdbarch)->builtin_int64, val); + } + else + { + uint64_t val; + val = bt_ctf_get_uint64 (def); + ret = value_from_longest + (builtin_type (target_gdbarch)->builtin_uint64, val); + } + break; + + case CTF_TYPE_ENUM: + ret = bt_ctf_def_to_val (bt_ctf_get_enum_int (def)); + break; + } + + return ret; +} + +static int +bt_ctf_event_to_internalvar (void) +{ + const struct definition *top_d; + struct definition const * const *list_d; + unsigned int list_d_count, i; + + top_d = bt_ctf_get_top_level_scope(ctf_event, BT_EVENT_FIELDS); + if (!top_d) + return -1; + if (bt_ctf_get_field_list (ctf_event, top_d, &list_d, &list_d_count)) + return -1; + + for (i = 0; i < list_d_count; i++) + { + struct value *val; + const char *name; + + val = bt_ctf_def_to_val (list_d[i]); + name = bt_ctf_field_name (list_d[i]); + if (val) + set_internalvar (lookup_internalvar (name), val); + else + warning (_("$%s is not support."), name); + } + + return 0; +} + +static int +bt_ctf_goto_begin (void) +{ + struct bt_iter_pos pos; + + pos.type = BT_SEEK_BEGIN; + if (bt_iter_set_pos(bt_ctf_get_iter (iter), &pos)) + return -1; + current_tp = 0; + ctf_event = bt_ctf_iter_read_event(iter); + if (!ctf_event) + return -1; + + return 0; +} + +static int +bt_ctf_find_num (int num, int *tpp) +{ + if (num < current_tp) + { + if (bt_ctf_goto_begin ()) + return -1; + } + + while (1) + { + if (current_tp == num) + break; + if (bt_iter_next (bt_ctf_get_iter (iter)) < 0) + return -1; + ctf_event = bt_ctf_iter_read_event(iter); + if (!ctf_event) + { + bt_ctf_goto_begin (); + return -1; + } + ++current_tp; + } + + if (tpp) + { + if (bt_ctf_event_id (tpp)) + { + warning (_("get tracepoint id fail.")); + *tpp = INT_MIN; + } + } + + return current_tp; +} + +static int +bt_ctf_find_tp (int tp) +{ + while (1) + { + int id; + + if (bt_iter_next (bt_ctf_get_iter (iter)) < 0) + return -1; + ctf_event = bt_ctf_iter_read_event(iter); + if (!ctf_event) + { + bt_ctf_goto_begin (); + return -1; + } + ++current_tp; + if (bt_ctf_event_id (&id)) + warning (_("get tracepoint id fail.")); + else if (id == tp) + break; + } + + return current_tp; +} + +static void +ctf_open (char *dirname, int from_tty) +{ + target_preopen (from_tty); + if (!dirname) + error (_("No CTF directory specified.")); + + bt_ctf_open (dirname); + + push_target (&ctf_ops); +} + +static void +ctf_close (int quitting) +{ + bt_ctf_close (); +} + +static int +ctf_trace_find (enum trace_find_type type, int num, + ULONGEST addr1, ULONGEST addr2, int *tpp) +{ + int ret = -1; + + switch (type) + { + case tfind_number: + if (num < 0) + { + if (tpp) + *tpp = -1; + } + else + ret = bt_ctf_find_num (num, tpp); + break; + + case tfind_tp: + ret = bt_ctf_find_tp (num); + break; + } + + if (ret >= 0) + { + if (bt_ctf_event_to_internalvar ()) + warning (_("add internal var of this frame fail.")); + } + + return ret; +} + +static const char * +ctf_get_current_tracepoint_name (void) +{ + if (ctf_event) + return bt_ctf_event_name (ctf_event); + + return NULL; +} + +extern void output_command (char *, int); + +static int +ctf_trace_dump (int from_tty) +{ + const struct definition *top_d; + struct definition const * const *list_d; + unsigned int list_d_count, i; + + if (!ctf_event) + return 1; + + top_d = bt_ctf_get_top_level_scope(ctf_event, BT_EVENT_FIELDS); + if (!top_d) + return 1; + if (bt_ctf_get_field_list (ctf_event, top_d, &list_d, &list_d_count)) + return 1; + + for (i = 0; i < list_d_count; i++) + { + char name[256]; + snprintf (name, 256, "$%s", bt_ctf_field_name (list_d[i])); + printf_filtered ("%s = ", name); + output_command (name, from_tty); + printf_filtered ("\n"); + } + + return 1; +} + +static int +ctf_has_all_memory (struct target_ops *ops) +{ + return 0; +} + +static int +ctf_has_memory (struct target_ops *ops) +{ + return 0; +} + +static int +ctf_has_stack (struct target_ops *ops) +{ + return 0; +} + +static int +ctf_has_registers (struct target_ops *ops) +{ + return 0; +} + +static int +ctf_thread_alive (struct target_ops *ops, ptid_t ptid) +{ + return 1; +} + +static void +init_ctf_ops (void) +{ + ctf_ops.to_shortname = "ctf"; + ctf_ops.to_longname = "CTF file"; + ctf_ops.to_doc = "Use a CTF directory as a target.\n\ +Specify the filename of the CTF directory."; + ctf_ops.to_open = ctf_open; + ctf_ops.to_close = ctf_close; + ctf_ops.to_trace_find = ctf_trace_find; + ctf_ops.to_get_current_tracepoint_name = ctf_get_current_tracepoint_name; + ctf_ops.to_trace_dump = ctf_trace_dump; + ctf_ops.to_stratum = process_stratum; + ctf_ops.to_has_all_memory = ctf_has_all_memory; + ctf_ops.to_has_memory = ctf_has_memory; + ctf_ops.to_has_stack = ctf_has_stack; + ctf_ops.to_has_registers = ctf_has_registers; + ctf_ops.to_thread_alive = ctf_thread_alive; + ctf_ops.to_magic = OPS_MAGIC; +} + +extern void _initialize_ctf (void); + +/* module initialization */ +void +_initialize_ctf (void) +{ + init_ctf_ops (); + + add_target (&ctf_ops); +} +#endif --- a/gdbtypes.c +++ b/gdbtypes.c @@ -1280,7 +1280,7 @@ lookup_union (const char *name, struct b visible in lexical block BLOCK. */ struct type * -lookup_enum (const char *name, struct block *block) +lookup_enum_gdb (const char *name, struct block *block) { struct symbol *sym; --- a/python/py-type.c +++ b/python/py-type.c @@ -723,7 +723,7 @@ typy_lookup_typename (const char *type_n else if (!strncmp (type_name, "union ", 6)) type = lookup_union (type_name + 6, NULL); else if (!strncmp (type_name, "enum ", 5)) - type = lookup_enum (type_name + 5, NULL); + type = lookup_enum_gdb (type_name + 5, NULL); else type = lookup_typename (python_language, python_gdbarch, type_name, block, 0); --- a/symtab.h +++ b/symtab.h @@ -984,7 +984,7 @@ extern struct type *lookup_struct (const extern struct type *lookup_union (const char *, struct block *); -extern struct type *lookup_enum (const char *, struct block *); +extern struct type *lookup_enum_gdb (const char *, struct block *); /* from blockframe.c: */ --- a/target.c +++ b/target.c @@ -694,6 +694,8 @@ update_current_target (void) INHERIT (to_set_disconnected_tracing, t); INHERIT (to_set_circular_trace_buffer, t); INHERIT (to_set_trace_notes, t); + INHERIT (to_get_current_tracepoint_name, t); + INHERIT (to_trace_dump, t); INHERIT (to_get_tib_address, t); INHERIT (to_set_permissions, t); INHERIT (to_static_tracepoint_marker_at, t); @@ -915,6 +917,12 @@ update_current_target (void) de_fault (to_set_trace_notes, (int (*) (char *, char *, char *)) return_zero); + de_fault (to_get_current_tracepoint_name, + (const char *(*) (void)) + return_zero); + de_fault (to_trace_dump, + (int (*) (int)) + return_zero); de_fault (to_get_tib_address, (int (*) (ptid_t, CORE_ADDR *)) tcomplain); --- a/target.h +++ b/target.h @@ -811,6 +811,10 @@ struct target_ops successful, 0 otherwise. */ int (*to_set_trace_notes) (char *user, char *notes, char* stopnotes); + const char *(*to_get_current_tracepoint_name) (void); + + int (*to_trace_dump) (int from_tty); + /* Return the processor core that thread PTID was last seen on. This information is updated only when: - update_thread_list is called @@ -1710,6 +1714,12 @@ extern char *target_fileio_read_stralloc #define target_set_trace_notes(user,notes,stopnotes) \ (*current_target.to_set_trace_notes) ((user), (notes), (stopnotes)) +#define target_get_current_tracepoint_name() \ +(*current_target.to_get_current_tracepoint_name) () + +#define target_trace_dump(from_tty) \ +(*current_target.to_trace_dump) (from_tty) + #define target_get_tib_address(ptid, addr) \ (*current_target.to_get_tib_address) ((ptid), (addr)) --- a/tracepoint.c +++ b/tracepoint.c @@ -2243,7 +2243,7 @@ tfind_1 (enum trace_find_type type, int below (correctly) decide to print out the source location of the trace frame. */ if (!(type == tfind_number && num == -1) - && (has_stack_frames () || traceframe_number >= 0)) + && has_stack_frames ()) old_frame_id = get_frame_id (get_current_frame ()); target_frameno = target_trace_find (type, num, addr1, addr2, @@ -2294,7 +2294,8 @@ tfind_1 (enum trace_find_type type, int tp = get_tracepoint_by_number_on_target (target_tracept); - reinit_frame_cache (); + if (has_stack_frames ()) + reinit_frame_cache (); target_dcache_invalidate (); set_tracepoint_num (tp ? tp->base.number : target_tracept); @@ -2304,10 +2305,13 @@ tfind_1 (enum trace_find_type type, int set_current_traceframe (target_frameno); - if (target_frameno == -1) - set_traceframe_context (NULL); - else - set_traceframe_context (get_current_frame ()); + if (has_stack_frames ()) + { + if (target_frameno == -1) + set_traceframe_context (NULL); + else + set_traceframe_context (get_current_frame ()); + } if (traceframe_number >= 0) { @@ -2341,21 +2345,30 @@ tfind_1 (enum trace_find_type type, int if (from_tty && (has_stack_frames () || traceframe_number >= 0)) { - enum print_what print_what; + const char *tp_name; - /* NOTE: in imitation of the step command, try to determine - whether we have made a transition from one function to - another. If so, we'll print the "stack frame" (ie. the new - function and it's arguments) -- otherwise we'll just show the - new source line. */ + tp_name = target_get_current_tracepoint_name (); + if (tp_name) + printf_filtered ("%s\n", tp_name); - if (frame_id_eq (old_frame_id, - get_frame_id (get_current_frame ()))) - print_what = SRC_LINE; - else - print_what = SRC_AND_LOC; + if (has_stack_frames ()) + { + enum print_what print_what; - print_stack_frame (get_selected_frame (NULL), 1, print_what); + /* NOTE: in imitation of the step command, try to determine + whether we have made a transition from one function to + another. If so, we'll print the "stack frame" (ie. the new + function and it's arguments) -- otherwise we'll just show the + new source line. */ + + if (frame_id_eq (old_frame_id, + get_frame_id (get_current_frame ()))) + print_what = SRC_LINE; + else + print_what = SRC_AND_LOC; + + print_stack_frame (get_selected_frame (NULL), 1, print_what); + } do_displays (); } } @@ -2885,6 +2898,9 @@ trace_dump_command (char *args, int from return; } + if (target_trace_dump (from_tty)) + return; + t = get_tracepoint (tracepoint_number); if (t == NULL)