aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-05-30 11:12:59 -0400
committerPetr Machata <pmachata@redhat.com>2012-08-29 19:03:18 +0200
commit917ef246757d89b74eac58e0664b3fe2146a6fdb (patch)
tree43edc9a5bfb9917af7888c8bce7951f379c57775 /sysdeps
parent789ad44c2fa11ea4e6508fd2feb98025954cf01d (diff)
downloadltrace-917ef246757d89b74eac58e0664b3fe2146a6fdb.tar.gz
Implement arch_type_{sizeof,alignof} for s390
This fixes s390x/s390 tracing scenario.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/linux-gnu/s390/arch.h2
-rw-r--r--sysdeps/linux-gnu/s390/trace.c118
2 files changed, 108 insertions, 12 deletions
diff --git a/sysdeps/linux-gnu/s390/arch.h b/sysdeps/linux-gnu/s390/arch.h
index a8f0a1f..0d412dc 100644
--- a/sysdeps/linux-gnu/s390/arch.h
+++ b/sysdeps/linux-gnu/s390/arch.h
@@ -23,6 +23,8 @@
#define DECR_PC_AFTER_BREAK 2
#define ARCH_ENDIAN_BIG
#define ARCH_HAVE_FETCH_ARG
+#define ARCH_HAVE_SIZEOF
+#define ARCH_HAVE_ALIGNOF
#define LT_ELFCLASS ELFCLASS32
#define LT_ELF_MACHINE EM_S390
diff --git a/sysdeps/linux-gnu/s390/trace.c b/sysdeps/linux-gnu/s390/trace.c
index 3381ccc..03edddb 100644
--- a/sysdeps/linux-gnu/s390/trace.c
+++ b/sysdeps/linux-gnu/s390/trace.c
@@ -1,24 +1,38 @@
/*
-** S390 specific part of trace.c
-**
-** Other routines are in ../trace.c and need to be combined
-** at link time with this code.
-**
-** Copyright (C) 2001,2005 IBM Corp.
-*/
+ * This file is part of ltrace.
+ * Copyright (C) 2012 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2001,2005 IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
#include "config.h"
-#include <errno.h>
-#include <stdlib.h>
+#include <asm/ptrace.h>
+#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <assert.h>
+#include <errno.h>
#include <signal.h>
-#include <sys/ptrace.h>
-#include <asm/ptrace.h>
+#include <stdlib.h>
-#include "proc.h"
#include "common.h"
+#include "proc.h"
+#include "type.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
@@ -201,3 +215,83 @@ gimme_arg(enum tof type, Process *proc, int arg_num, struct arg_type_info *info)
#endif
return ret;
}
+
+size_t
+arch_type_sizeof(struct Process *proc, struct arg_type_info *info)
+{
+ if (proc == NULL)
+ return (size_t)-2;
+
+ switch (info->type) {
+ case ARGTYPE_VOID:
+ return 0;
+
+ case ARGTYPE_CHAR:
+ return 1;
+
+ case ARGTYPE_SHORT:
+ case ARGTYPE_USHORT:
+ return 2;
+
+ case ARGTYPE_INT:
+ case ARGTYPE_UINT:
+ return 4;
+
+ case ARGTYPE_LONG:
+ case ARGTYPE_ULONG:
+ case ARGTYPE_POINTER:
+ return proc->e_class == ELFCLASS64 ? 8 : 4;
+
+ case ARGTYPE_FLOAT:
+ return 4;
+ case ARGTYPE_DOUBLE:
+ return 8;
+
+ case ARGTYPE_ARRAY:
+ case ARGTYPE_STRUCT:
+ /* Use default value. */
+ return (size_t)-2;
+ }
+ assert(info->type != info->type);
+ abort();
+}
+
+size_t
+arch_type_alignof(struct Process *proc, struct arg_type_info *info)
+{
+ if (proc == NULL)
+ return (size_t)-2;
+
+ switch (info->type) {
+ case ARGTYPE_VOID:
+ assert(info->type != ARGTYPE_VOID);
+ break;
+
+ case ARGTYPE_CHAR:
+ return 1;
+
+ case ARGTYPE_SHORT:
+ case ARGTYPE_USHORT:
+ return 2;
+
+ case ARGTYPE_INT:
+ case ARGTYPE_UINT:
+ return 4;
+
+ case ARGTYPE_LONG:
+ case ARGTYPE_ULONG:
+ case ARGTYPE_POINTER:
+ return proc->e_class == ELFCLASS64 ? 8 : 4;
+
+ case ARGTYPE_FLOAT:
+ return 4;
+ case ARGTYPE_DOUBLE:
+ return 8;
+
+ case ARGTYPE_ARRAY:
+ case ARGTYPE_STRUCT:
+ /* Use default value. */
+ return (size_t)-2;
+ }
+ abort();
+}