process.c: move getgroups* and setgroups* parsers to a separate file

* groups.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c: Move sys_setgroups, sys_getgroups, sys_setgroups32,
sys_getgroups32, and related code to groups.c.
diff --git a/Makefile.am b/Makefile.am
index c344338..52f7f46 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,6 +39,7 @@
 	get_robust_list.c \
 	getcpu.c	\
 	getcwd.c	\
+	groups.c	\
 	inotify.c	\
 	io.c		\
 	ioctl.c		\
diff --git a/groups.c b/groups.c
new file mode 100644
index 0000000..2b4350c
--- /dev/null
+++ b/groups.c
@@ -0,0 +1,237 @@
+#include "defs.h"
+
+#include <asm/posix_types.h>
+#undef GETGROUPS_T
+#define GETGROUPS_T __kernel_gid_t
+#undef GETGROUPS32_T
+#define GETGROUPS32_T __kernel_gid32_t
+
+int
+sys_setgroups(struct tcb *tcp)
+{
+	if (entering(tcp)) {
+		unsigned long len, size, start, cur, end, abbrev_end;
+		GETGROUPS_T gid;
+		int failed = 0;
+
+		len = tcp->u_arg[0];
+		tprintf("%lu, ", len);
+		if (len == 0) {
+			tprints("[]");
+			return 0;
+		}
+		start = tcp->u_arg[1];
+		if (start == 0) {
+			tprints("NULL");
+			return 0;
+		}
+		size = len * sizeof(gid);
+		end = start + size;
+		if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
+			tprintf("%#lx", start);
+			return 0;
+		}
+		if (abbrev(tcp)) {
+			abbrev_end = start + max_strlen * sizeof(gid);
+			if (abbrev_end < start)
+				abbrev_end = end;
+		} else {
+			abbrev_end = end;
+		}
+		tprints("[");
+		for (cur = start; cur < end; cur += sizeof(gid)) {
+			if (cur > start)
+				tprints(", ");
+			if (cur >= abbrev_end) {
+				tprints("...");
+				break;
+			}
+			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
+				tprints("?");
+				failed = 1;
+				break;
+			}
+			tprintf("%lu", (unsigned long) gid);
+		}
+		tprints("]");
+		if (failed)
+			tprintf(" %#lx", tcp->u_arg[1]);
+	}
+	return 0;
+}
+
+int
+sys_getgroups(struct tcb *tcp)
+{
+	unsigned long len;
+
+	if (entering(tcp)) {
+		len = tcp->u_arg[0];
+		tprintf("%lu, ", len);
+	} else {
+		unsigned long size, start, cur, end, abbrev_end;
+		GETGROUPS_T gid;
+		int failed = 0;
+
+		len = tcp->u_rval;
+		if (len == 0) {
+			tprints("[]");
+			return 0;
+		}
+		start = tcp->u_arg[1];
+		if (start == 0) {
+			tprints("NULL");
+			return 0;
+		}
+		if (tcp->u_arg[0] == 0) {
+			tprintf("%#lx", start);
+			return 0;
+		}
+		size = len * sizeof(gid);
+		end = start + size;
+		if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
+		    size / sizeof(gid) != len || end < start) {
+			tprintf("%#lx", start);
+			return 0;
+		}
+		if (abbrev(tcp)) {
+			abbrev_end = start + max_strlen * sizeof(gid);
+			if (abbrev_end < start)
+				abbrev_end = end;
+		} else {
+			abbrev_end = end;
+		}
+		tprints("[");
+		for (cur = start; cur < end; cur += sizeof(gid)) {
+			if (cur > start)
+				tprints(", ");
+			if (cur >= abbrev_end) {
+				tprints("...");
+				break;
+			}
+			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
+				tprints("?");
+				failed = 1;
+				break;
+			}
+			tprintf("%lu", (unsigned long) gid);
+		}
+		tprints("]");
+		if (failed)
+			tprintf(" %#lx", tcp->u_arg[1]);
+	}
+	return 0;
+}
+
+int
+sys_setgroups32(struct tcb *tcp)
+{
+	if (entering(tcp)) {
+		unsigned long len, size, start, cur, end, abbrev_end;
+		GETGROUPS32_T gid;
+		int failed = 0;
+
+		len = tcp->u_arg[0];
+		tprintf("%lu, ", len);
+		if (len == 0) {
+			tprints("[]");
+			return 0;
+		}
+		start = tcp->u_arg[1];
+		if (start == 0) {
+			tprints("NULL");
+			return 0;
+		}
+		size = len * sizeof(gid);
+		end = start + size;
+		if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
+			tprintf("%#lx", start);
+			return 0;
+		}
+		if (abbrev(tcp)) {
+			abbrev_end = start + max_strlen * sizeof(gid);
+			if (abbrev_end < start)
+				abbrev_end = end;
+		} else {
+			abbrev_end = end;
+		}
+		tprints("[");
+		for (cur = start; cur < end; cur += sizeof(gid)) {
+			if (cur > start)
+				tprints(", ");
+			if (cur >= abbrev_end) {
+				tprints("...");
+				break;
+			}
+			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
+				tprints("?");
+				failed = 1;
+				break;
+			}
+			tprintf("%lu", (unsigned long) gid);
+		}
+		tprints("]");
+		if (failed)
+			tprintf(" %#lx", tcp->u_arg[1]);
+	}
+	return 0;
+}
+
+int
+sys_getgroups32(struct tcb *tcp)
+{
+	unsigned long len;
+
+	if (entering(tcp)) {
+		len = tcp->u_arg[0];
+		tprintf("%lu, ", len);
+	} else {
+		unsigned long size, start, cur, end, abbrev_end;
+		GETGROUPS32_T gid;
+		int failed = 0;
+
+		len = tcp->u_rval;
+		if (len == 0) {
+			tprints("[]");
+			return 0;
+		}
+		start = tcp->u_arg[1];
+		if (start == 0) {
+			tprints("NULL");
+			return 0;
+		}
+		size = len * sizeof(gid);
+		end = start + size;
+		if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
+		    size / sizeof(gid) != len || end < start) {
+			tprintf("%#lx", start);
+			return 0;
+		}
+		if (abbrev(tcp)) {
+			abbrev_end = start + max_strlen * sizeof(gid);
+			if (abbrev_end < start)
+				abbrev_end = end;
+		} else {
+			abbrev_end = end;
+		}
+		tprints("[");
+		for (cur = start; cur < end; cur += sizeof(gid)) {
+			if (cur > start)
+				tprints(", ");
+			if (cur >= abbrev_end) {
+				tprints("...");
+				break;
+			}
+			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
+				tprints("?");
+				failed = 1;
+				break;
+			}
+			tprintf("%lu", (unsigned long) gid);
+		}
+		tprints("]");
+		if (failed)
+			tprintf(" %#lx", tcp->u_arg[1]);
+	}
+	return 0;
+}
diff --git a/process.c b/process.c
index cd0c516..720559d 100644
--- a/process.c
+++ b/process.c
@@ -72,10 +72,6 @@
 #endif
 
 #include <asm/posix_types.h>
-#undef GETGROUPS_T
-#define GETGROUPS_T __kernel_gid_t
-#undef GETGROUPS32_T
-#define GETGROUPS32_T __kernel_gid32_t
 
 #if defined(IA64)
 # include <asm/ptrace_offsets.h>
@@ -344,236 +340,6 @@
 	return 0;
 }
 
-int
-sys_setgroups(struct tcb *tcp)
-{
-	if (entering(tcp)) {
-		unsigned long len, size, start, cur, end, abbrev_end;
-		GETGROUPS_T gid;
-		int failed = 0;
-
-		len = tcp->u_arg[0];
-		tprintf("%lu, ", len);
-		if (len == 0) {
-			tprints("[]");
-			return 0;
-		}
-		start = tcp->u_arg[1];
-		if (start == 0) {
-			tprints("NULL");
-			return 0;
-		}
-		size = len * sizeof(gid);
-		end = start + size;
-		if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
-			tprintf("%#lx", start);
-			return 0;
-		}
-		if (abbrev(tcp)) {
-			abbrev_end = start + max_strlen * sizeof(gid);
-			if (abbrev_end < start)
-				abbrev_end = end;
-		} else {
-			abbrev_end = end;
-		}
-		tprints("[");
-		for (cur = start; cur < end; cur += sizeof(gid)) {
-			if (cur > start)
-				tprints(", ");
-			if (cur >= abbrev_end) {
-				tprints("...");
-				break;
-			}
-			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
-				tprints("?");
-				failed = 1;
-				break;
-			}
-			tprintf("%lu", (unsigned long) gid);
-		}
-		tprints("]");
-		if (failed)
-			tprintf(" %#lx", tcp->u_arg[1]);
-	}
-	return 0;
-}
-
-int
-sys_getgroups(struct tcb *tcp)
-{
-	unsigned long len;
-
-	if (entering(tcp)) {
-		len = tcp->u_arg[0];
-		tprintf("%lu, ", len);
-	} else {
-		unsigned long size, start, cur, end, abbrev_end;
-		GETGROUPS_T gid;
-		int failed = 0;
-
-		len = tcp->u_rval;
-		if (len == 0) {
-			tprints("[]");
-			return 0;
-		}
-		start = tcp->u_arg[1];
-		if (start == 0) {
-			tprints("NULL");
-			return 0;
-		}
-		if (tcp->u_arg[0] == 0) {
-			tprintf("%#lx", start);
-			return 0;
-		}
-		size = len * sizeof(gid);
-		end = start + size;
-		if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
-		    size / sizeof(gid) != len || end < start) {
-			tprintf("%#lx", start);
-			return 0;
-		}
-		if (abbrev(tcp)) {
-			abbrev_end = start + max_strlen * sizeof(gid);
-			if (abbrev_end < start)
-				abbrev_end = end;
-		} else {
-			abbrev_end = end;
-		}
-		tprints("[");
-		for (cur = start; cur < end; cur += sizeof(gid)) {
-			if (cur > start)
-				tprints(", ");
-			if (cur >= abbrev_end) {
-				tprints("...");
-				break;
-			}
-			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
-				tprints("?");
-				failed = 1;
-				break;
-			}
-			tprintf("%lu", (unsigned long) gid);
-		}
-		tprints("]");
-		if (failed)
-			tprintf(" %#lx", tcp->u_arg[1]);
-	}
-	return 0;
-}
-
-int
-sys_setgroups32(struct tcb *tcp)
-{
-	if (entering(tcp)) {
-		unsigned long len, size, start, cur, end, abbrev_end;
-		GETGROUPS32_T gid;
-		int failed = 0;
-
-		len = tcp->u_arg[0];
-		tprintf("%lu, ", len);
-		if (len == 0) {
-			tprints("[]");
-			return 0;
-		}
-		start = tcp->u_arg[1];
-		if (start == 0) {
-			tprints("NULL");
-			return 0;
-		}
-		size = len * sizeof(gid);
-		end = start + size;
-		if (!verbose(tcp) || size / sizeof(gid) != len || end < start) {
-			tprintf("%#lx", start);
-			return 0;
-		}
-		if (abbrev(tcp)) {
-			abbrev_end = start + max_strlen * sizeof(gid);
-			if (abbrev_end < start)
-				abbrev_end = end;
-		} else {
-			abbrev_end = end;
-		}
-		tprints("[");
-		for (cur = start; cur < end; cur += sizeof(gid)) {
-			if (cur > start)
-				tprints(", ");
-			if (cur >= abbrev_end) {
-				tprints("...");
-				break;
-			}
-			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
-				tprints("?");
-				failed = 1;
-				break;
-			}
-			tprintf("%lu", (unsigned long) gid);
-		}
-		tprints("]");
-		if (failed)
-			tprintf(" %#lx", tcp->u_arg[1]);
-	}
-	return 0;
-}
-
-int
-sys_getgroups32(struct tcb *tcp)
-{
-	unsigned long len;
-
-	if (entering(tcp)) {
-		len = tcp->u_arg[0];
-		tprintf("%lu, ", len);
-	} else {
-		unsigned long size, start, cur, end, abbrev_end;
-		GETGROUPS32_T gid;
-		int failed = 0;
-
-		len = tcp->u_rval;
-		if (len == 0) {
-			tprints("[]");
-			return 0;
-		}
-		start = tcp->u_arg[1];
-		if (start == 0) {
-			tprints("NULL");
-			return 0;
-		}
-		size = len * sizeof(gid);
-		end = start + size;
-		if (!verbose(tcp) || tcp->u_arg[0] == 0 ||
-		    size / sizeof(gid) != len || end < start) {
-			tprintf("%#lx", start);
-			return 0;
-		}
-		if (abbrev(tcp)) {
-			abbrev_end = start + max_strlen * sizeof(gid);
-			if (abbrev_end < start)
-				abbrev_end = end;
-		} else {
-			abbrev_end = end;
-		}
-		tprints("[");
-		for (cur = start; cur < end; cur += sizeof(gid)) {
-			if (cur > start)
-				tprints(", ");
-			if (cur >= abbrev_end) {
-				tprints("...");
-				break;
-			}
-			if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) {
-				tprints("?");
-				failed = 1;
-				break;
-			}
-			tprintf("%lu", (unsigned long) gid);
-		}
-		tprints("]");
-		if (failed)
-			tprintf(" %#lx", tcp->u_arg[1]);
-	}
-	return 0;
-}
-
 #include "xlat/ptrace_cmds.h"
 #include "xlat/ptrace_setoptions_flags.h"
 #include "xlat/nt_descriptor_types.h"