]> granicus.if.org Git - strace/blobdiff - defs.h
Introduce generic STRINGIFY and STRINGIFY_VAL macros
[strace] / defs.h
diff --git a/defs.h b/defs.h
index 3b60d3d4dc30dd834a967bac76e08f3b8060b058..b3a315f338c782186b4769dbc75d67d66c0b34f6 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -54,8 +54,9 @@
 #include <sys/time.h>
 
 #include "kernel_types.h"
-#include "mpers_type.h"
 #include "gcc_compat.h"
+#include "macros.h"
+#include "mpers_type.h"
 #include "sysent.h"
 
 #ifndef HAVE_STRERROR
@@ -75,8 +76,6 @@ extern char *stpcpy(char *dst, const char *src);
        (offsetof(type, member) + sizeof(((type *)NULL)->member))
 #endif
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + MUST_BE_ARRAY(a))
-
 /* macros */
 #ifndef MAX
 # define MAX(a, b)             (((a) > (b)) ? (a) : (b))
@@ -106,7 +105,7 @@ extern char *stpcpy(char *dst, const char *src);
  *
  * Make sure that all entries in all syscallent.h files have nargs <= MAX_ARGS!
  * linux/<ARCH>/syscallent*.h:
- *     all have nargs <= 6 except mips o32 which has nargs <= 7.
+ *     all have nargs <= 6 except mips o32 which has nargs <= 7.
  */
 #ifndef MAX_ARGS
 # ifdef LINUX_MIPSO32
@@ -234,11 +233,11 @@ struct tcb {
        struct timeval etime;   /* Syscall entry time */
 
 #ifdef USE_LIBUNWIND
-       struct UPT_infolibunwind_ui;
-       struct mmap_cache_tmmap_cache;
+       struct UPT_info *libunwind_ui;
+       struct mmap_cache_t *mmap_cache;
        unsigned int mmap_cache_size;
        unsigned int mmap_cache_generation;
-       struct queue_tqueue;
+       struct queue_t *queue;
 #endif
 };
 
@@ -291,7 +290,9 @@ extern const struct xlat addrfams[];
 extern const struct xlat at_flags[];
 extern const struct xlat clocknames[];
 extern const struct xlat dirent_types[];
+extern const struct xlat ethernet_protocols[];
 extern const struct xlat evdev_abs[];
+extern const struct xlat inet_protocols[];
 extern const struct xlat msg_flags[];
 extern const struct xlat netlink_protocols[];
 extern const struct xlat open_access_modes[];
@@ -381,7 +382,7 @@ extern unsigned ptrace_setoptions;
 extern unsigned max_strlen;
 extern unsigned os_release;
 #undef KERNEL_VERSION
-#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
 
 void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
 void perror_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
@@ -391,7 +392,6 @@ void error_msg_and_help(const char *fmt, ...)
        ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
 void perror_msg_and_die(const char *fmt, ...)
        ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
-void die_out_of_memory(void) ATTRIBUTE_NORETURN;
 
 void *xmalloc(size_t size) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1));
 void *xcalloc(size_t nmemb, size_t size)
@@ -399,6 +399,7 @@ void *xcalloc(size_t nmemb, size_t size)
 void *xreallocarray(void *ptr, size_t nmemb, size_t size)
        ATTRIBUTE_ALLOC_SIZE((2, 3));
 char *xstrdup(const char *str) ATTRIBUTE_MALLOC;
+char *xstrndup(const char *str, size_t n) ATTRIBUTE_MALLOC;
 
 extern int read_int_from_file(const char *, int *);
 
@@ -451,28 +452,28 @@ static inline int set_tcb_priv_ulong(struct tcb *tcp, unsigned long val)
 }
 
 extern int
-umoven(struct tcb *tcp, kernel_ulong_t addr, unsigned int len, void *laddr);
+umoven(struct tcb *, kernel_ulong_t addr, unsigned int len, void *laddr);
 #define umove(pid, addr, objp) \
        umoven((pid), (addr), sizeof(*(objp)), (void *) (objp))
 
 extern int
-umoven_or_printaddr(struct tcb *tcp, kernel_ulong_t addr,
+umoven_or_printaddr(struct tcb *, kernel_ulong_t addr,
                    unsigned int len, void *laddr);
 #define umove_or_printaddr(pid, addr, objp)    \
        umoven_or_printaddr((pid), (addr), sizeof(*(objp)), (void *) (objp))
 
 extern int
-umoven_or_printaddr_ignore_syserror(struct tcb *tcp, kernel_ulong_t addr,
+umoven_or_printaddr_ignore_syserror(struct tcb *, kernel_ulong_t addr,
                                    unsigned int len, void *laddr);
 
 extern int
-umovestr(struct tcb *tcp, kernel_ulong_t addr, unsigned int len, char *laddr);
+umovestr(struct tcb *, kernel_ulong_t addr, unsigned int len, char *laddr);
 
 extern int upeek(int pid, unsigned long, kernel_ulong_t *);
 extern int upoke(int pid, unsigned long, kernel_ulong_t);
 
 extern bool
-print_array(struct tcb *tcp,
+print_array(struct tcb *,
            kernel_ulong_t start_addr,
            size_t nmemb,
            void *elem_buf,
@@ -505,6 +506,14 @@ extern enum sock_proto getfdproto(struct tcb *, int);
 extern const char *xlookup(const struct xlat *, const uint64_t);
 extern const char *xlat_search(const struct xlat *, const size_t, const uint64_t);
 
+struct dyxlat;
+struct dyxlat *dyxlat_alloc(size_t nmemb);
+void dyxlat_free(struct dyxlat *);
+const struct xlat *dyxlat_get(const struct dyxlat *);
+void dyxlat_add_pair(struct dyxlat *, uint64_t val, const char *str, size_t len);
+
+const struct xlat *genl_families_xlat(void);
+
 extern unsigned long get_pagesize(void);
 extern int
 string_to_uint_ex(const char *str, char **endptr,
@@ -531,10 +540,10 @@ str_strip_prefix_len(const char *str, const char *prefix, size_t prefix_len)
 #define STR_STRIP_PREFIX(str, prefix)  \
        str_strip_prefix_len((str), (prefix), sizeof(prefix) - 1)
 
-#define QUOTE_0_TERMINATED                      0x01
-#define QUOTE_OMIT_LEADING_TRAILING_QUOTES      0x02
-#define QUOTE_OMIT_TRAILING_0                   0x08
-#define QUOTE_FORCE_HEX                         0x10
+#define QUOTE_0_TERMINATED                     0x01
+#define QUOTE_OMIT_LEADING_TRAILING_QUOTES     0x02
+#define QUOTE_OMIT_TRAILING_0                  0x08
+#define QUOTE_FORCE_HEX                                0x10
 
 extern int string_quote(const char *, char *, unsigned int, unsigned int);
 extern int print_quoted_string(const char *, unsigned int, unsigned int);
@@ -543,10 +552,10 @@ extern int print_quoted_string(const char *, unsigned int, unsigned int);
  * b refers to the higher numbered u_arg
  */
 #ifdef WORDS_BIGENDIAN
-# define ULONG_LONG(a,b) \
+# define ULONG_LONG(a, b) \
        ((unsigned long long)(unsigned)(b) | ((unsigned long long)(a)<<32))
 #else
-# define ULONG_LONG(a,b) \
+# define ULONG_LONG(a, b) \
        ((unsigned long long)(unsigned)(a) | ((unsigned long long)(b)<<32))
 #endif
 extern int getllval(struct tcb *, unsigned long long *, int);
@@ -602,7 +611,9 @@ printpath(struct tcb *, kernel_ulong_t addr);
 #define TIMESPEC_TEXT_BUFSIZE \
                (sizeof(long long) * 3 * 2 + sizeof("{tv_sec=-, tv_nsec=}"))
 extern void printfd(struct tcb *, int);
-extern void print_sockaddr(struct tcb *tcp, const void *, int);
+extern void print_sockaddr(struct tcb *, const void *sa, int len);
+extern bool
+print_inet_addr(int af, const void *addr, unsigned int len, const char *var_name);
 extern const char *get_sockaddr_by_inode(struct tcb *, int fd, unsigned long inode);
 extern bool print_sockaddr_by_inode(struct tcb *, int fd, unsigned long inode);
 extern void print_dirfd(struct tcb *, int);
@@ -639,7 +650,7 @@ extern void
 print_seccomp_fprog(struct tcb *, kernel_ulong_t addr, unsigned short len);
 
 struct strace_stat;
-extern void print_struct_stat(struct tcb *tcp, const struct strace_stat *const st);
+extern void print_struct_stat(struct tcb *, const struct strace_stat *const st);
 
 struct strace_statfs;
 
@@ -697,11 +708,11 @@ extern void tv_div(struct timeval *, const struct timeval *, int);
 
 #ifdef USE_LIBUNWIND
 extern void unwind_init(void);
-extern void unwind_tcb_init(struct tcb *tcp);
-extern void unwind_tcb_fin(struct tcb *tcp);
-extern void unwind_cache_invalidate(struct tcb* tcp);
-extern void unwind_print_stacktrace(struct tcb* tcp);
-extern void unwind_capture_stacktrace(struct tcb* tcp);
+extern void unwind_tcb_init(struct tcb *);
+extern void unwind_tcb_fin(struct tcb *);
+extern void unwind_cache_invalidate(struct tcb *);
+extern void unwind_print_stacktrace(struct tcb *);
+extern void unwind_capture_stacktrace(struct tcb *);
 #endif
 
 static inline void
@@ -754,10 +765,10 @@ typedef struct {
 
 extern void print_timeval32_t(const timeval32_t *);
 extern void printrusage32(struct tcb *, kernel_ulong_t);
-extern const char *sprint_timeval32(struct tcb *tcp, kernel_ulong_t);
-extern void print_timeval32(struct tcb *tcp, kernel_ulong_t);
-extern void print_timeval32_utimes(struct tcb *tcp, kernel_ulong_t);
-extern void print_itimerval32(struct tcb *tcp, kernel_ulong_t);
+extern const char *sprint_timeval32(struct tcb *, kernel_ulong_t addr);
+extern void print_timeval32(struct tcb *, kernel_ulong_t addr);
+extern void print_timeval32_utimes(struct tcb *, kernel_ulong_t addr);
+extern void print_itimerval32(struct tcb *, kernel_ulong_t addr);
 #endif
 
 #ifdef HAVE_STRUCT_USER_DESC