From beca885a4bcd578e8648aa54ca5f72520b8923fb Mon Sep 17 00:00:00 2001 From: "hp.com!davidm" Date: Fri, 15 Oct 2004 13:48:38 +0000 Subject: [PATCH] (Logical change 1.276) --- tests/ident.c | 5 ++ tests/run-ptrace-misc | 2 + tests/test-ptrace-misc.c | 118 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) diff --git a/tests/ident.c b/tests/ident.c index e69de29b..9024e292 100644 --- a/tests/ident.c +++ b/tests/ident.c @@ -0,0 +1,5 @@ +long +f (long val) +{ + return val; +} diff --git a/tests/run-ptrace-misc b/tests/run-ptrace-misc index e69de29b..c3a6552f 100644 --- a/tests/run-ptrace-misc +++ b/tests/run-ptrace-misc @@ -0,0 +1,2 @@ +#!/bin/sh +./test-ptrace -c -t ./test-ptrace-misc diff --git a/tests/test-ptrace-misc.c b/tests/test-ptrace-misc.c index e69de29b..2160548b 100644 --- a/tests/test-ptrace-misc.c +++ b/tests/test-ptrace-misc.c @@ -0,0 +1,118 @@ +/* libunwind - a platform-independent unwind library + Copyright (C) 2004 Hewlett-Packard Co + Contributed by David Mosberger-Tang + +This file is part of libunwind. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include +#include +#include +#include +#include + +#include + +pid_t self; +int global[64]; + +int +func (int arg) +{ + int sum = 0, i, max, arr[1024]; + + if (arg == 0) + { + sum = global[2]; + sum += sum + sum * getppid (); + return sum; + } + else + { + max = arg; + if (max >= 64) + max = 64; + + for (i = 0; i < max; ++i) + arr[i] = func (arg - 1); + + for (i = 0; i < max; ++i) + if (arr[i] > 16) + sum += arr[i]; + else + sum -= arr[i]; + } + return sum; +} + +int +bar (int v) +{ + extern long f (long); + int arr[1]; + uintptr_t r; + + /* This is a vain attempt to use up lots of registers to force + the frame-chain info to be saved on the memory stack on ia64. + It happens to work with gcc v3.3.4 and gcc v3.4.1 but perhaps + not with any other compiler. */ + r = (uintptr_t) malloc(f (arr[0]) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + f (v)) + )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + ))))))))))))))))))))))))))))))))))))))))))))))))))))))); + if (r < 2) + v = r; + + kill (self, SIGUSR1); /* tell test-ptrace to start single-stepping */ + v = func (v); + kill (self, SIGUSR2); /* tell test-ptrace to stop single-stepping */ + return v; +} + +int +main (int argc, char **argv) +{ + int val = argc; + + signal (SIGUSR1, SIG_IGN); + signal (SIGUSR2, SIG_IGN); + + self = getpid (); + + printf ("sum = %d\n", bar (val)); + return 0; +}