From de2a42042ee5a18185a83435b67bc51cb3874ba9 Mon Sep 17 00:00:00 2001 From: "hp.com!davidm" Date: Thu, 6 May 2004 20:26:29 +0000 Subject: [PATCH] (Logical change 1.231) --- tests/Gia64-test-readonly.c | 109 +++++++++++++++++++++++++++++++++ tests/Lia64-test-readonly.c | 5 ++ tests/ia64-test-readonly-asm.S | 56 +++++++++++++++++ 3 files changed, 170 insertions(+) diff --git a/tests/Gia64-test-readonly.c b/tests/Gia64-test-readonly.c index e69de29b..574f2cb5 100644 --- a/tests/Gia64-test-readonly.c +++ b/tests/Gia64-test-readonly.c @@ -0,0 +1,109 @@ +/* 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. */ + +/* This file verifies that read-only registers cannot be written to. */ + +#include +#include +#include +#include + +#include + +#define panic(args...) \ + do { printf (args); ++nerrors; } while (0) + +static int verbose; +static int nerrors; + +extern void test_func (void (*) (void)); + +void +checker (void) +{ + unw_fpreg_t fpval; + unw_context_t uc; + unw_cursor_t c; + int ret; + + fpval.raw.bits[0] = 100; + fpval.raw.bits[1] = 101; + + unw_getcontext (&uc); + + if ((ret = unw_init_local (&c, &uc)) < 0) + panic ("%s: unw_init_local (ret=%d)\n", __FUNCTION__, ret); + + if ((ret = unw_step (&c)) < 0) + panic ("%s: unw_step (ret=%d)\n", __FUNCTION__, ret); + + if ((ret = unw_step (&c)) < 0) + panic ("%s: unw_step (ret=%d)\n", __FUNCTION__, ret); + + if ((ret = unw_set_reg (&c, UNW_IA64_IP, 99)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_reg (ip) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_reg (&c, UNW_IA64_GR + 5, 99)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_reg (r5) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_reg (&c, UNW_IA64_GR + 6, 99)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_reg (r6) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_reg (&c, UNW_IA64_AR_LC, 99)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_reg (ar.lc) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_reg (&c, UNW_IA64_BR + 2, 99)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_reg (b2) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_reg (&c, UNW_IA64_BR + 3, 99)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_reg (b3) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_fpreg (&c, UNW_IA64_FR + 2, fpval)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_fpreg (f2) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); + if ((ret = unw_set_fpreg (&c, UNW_IA64_FR + 3, fpval)) != -UNW_EREADONLYREG) + panic ("%s: unw_set_fpreg (f3) returned %d instead of %d\n", + __FUNCTION__, ret, -UNW_EREADONLYREG); +} + +int +main (int argc, char **argv) +{ + int i; + + if (argc > 1) + verbose = 1; + + test_func (checker); + + if (nerrors > 0) + { + fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); + exit (-1); + } + if (verbose) + printf ("SUCCESS.\n"); + return 0; +} diff --git a/tests/Lia64-test-readonly.c b/tests/Lia64-test-readonly.c index e69de29b..cd23e926 100644 --- a/tests/Lia64-test-readonly.c +++ b/tests/Lia64-test-readonly.c @@ -0,0 +1,5 @@ +#define UNW_LOCAL_ONLY +#include +#if !defined(UNW_REMOTE_ONLY) +#include "Gia64-test-readonly.c" +#endif diff --git a/tests/ia64-test-readonly-asm.S b/tests/ia64-test-readonly-asm.S index e69de29b..9be4fb8d 100644 --- a/tests/ia64-test-readonly-asm.S +++ b/tests/ia64-test-readonly-asm.S @@ -0,0 +1,56 @@ +/* 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. */ + + .text + + .global test_func + .proc test_func +test_func: + .prologue + .regstk 1, 3, 0, 0 + .save ar.pfs, loc0 + alloc loc0 = ar.pfs, 1, 3, 0, 0 + mov loc1 = rp + .save rp, r0 + .spillreg r5, f0 + .spillreg r6, f1 + .spillreg f2, f0 + .spillreg f3, f1 + .save ar.lc, r0 + .spillreg b2, f0 + .spillreg b3, f1 + .body + mov loc2 = gp + ld8 r2 = [in0], 8;; + ld8 r1 = [in0];; + mov b6 = r2 + br.call.sptk.many rp = b6 + + mov gp = loc2 + mov rp = loc1 + mov ar.pfs = loc0 + br.ret.sptk.many rp + + .endp test_func