]> granicus.if.org Git - strace/commitdiff
Issue a warning when strace lacks tracee personality support
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 10 Jan 2018 02:53:54 +0000 (03:53 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 11 Jan 2018 15:54:33 +0000 (15:54 +0000)
* defs.h (HAVE_PERSONALITY_1_MPERS, HAVE_PERSONALITY_2_MPERS): New
macros.
* syscall.c (update_personality): Add need_mpers_warning array
initialized with mpers support data.  Use it for printing the mpers
unavailability warning once per personality.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
defs.h
syscall.c

diff --git a/defs.h b/defs.h
index 377b94a0a9b189832dcb0ada744177d3391bf2e3..2d9793e4cc3d87ceadec34a8a3d0564a35d7c251 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -149,10 +149,12 @@ extern char *stpcpy(char *dst, const char *src);
 # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
 # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
 # define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
+# define HAVE_PERSONALITY_1_MPERS 1
 #else
 # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
 # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
 # define PERSONALITY1_INCLUDE_FUNCS "empty.h"
+# define HAVE_PERSONALITY_1_MPERS 0
 #endif
 
 #if SUPPORTED_PERSONALITIES > 2 && defined HAVE_MX32_MPERS
@@ -160,10 +162,12 @@ extern char *stpcpy(char *dst, const char *src);
 # define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h"
 # define PERSONALITY2_INCLUDE_PRINTERS_DEFS "mx32_printer_defs.h"
 # define MPERS_mx32_IOCTL_MACROS "ioctl_redefs2.h"
+# define HAVE_PERSONALITY_2_MPERS 1
 #else
 # define PERSONALITY2_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
 # define PERSONALITY2_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
 # define PERSONALITY2_INCLUDE_FUNCS "empty.h"
+# define HAVE_PERSONALITY_2_MPERS 0
 #endif
 
 typedef struct ioctlent {
index d36abf2e1e3d2b0ea8b2bdc4430d1357ef363ccd..ee479721f112a39afe2167e561f242f832827110 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -303,6 +303,9 @@ set_personality(int personality)
 static void
 update_personality(struct tcb *tcp, unsigned int personality)
 {
+       static bool need_mpers_warning[] =
+               { false, !HAVE_PERSONALITY_1_MPERS, !HAVE_PERSONALITY_2_MPERS };
+
        if (personality == current_personality)
                return;
        set_personality(personality);
@@ -315,6 +318,13 @@ update_personality(struct tcb *tcp, unsigned int personality)
                error_msg("[ Process PID=%d runs in %s mode. ]",
                          tcp->pid, personality_names[personality]);
        }
+
+       if (need_mpers_warning[personality]) {
+               error_msg("WARNING: Proper structure decoding for this "
+                         "personality is not supported, please consider "
+                         "building strace with mpers support enabled.");
+               need_mpers_warning[personality] = false;
+       }
 }
 #endif