OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [siginfo-obj.c] - Diff between revs 834 and 842

Only display areas with differences | Details | Blame | View Log

Rev 834 Rev 842
/* This testcase is part of GDB, the GNU debugger.
/* This testcase is part of GDB, the GNU debugger.
 
 
   Copyright 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
   Copyright 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
 
 
   This program is free software; you can redistribute it and/or modify
   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
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
*/
*/
 
 
#include <signal.h>
#include <signal.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/mman.h>
#include <unistd.h>
#include <unistd.h>
 
 
static void *p;
static void *p;
 
 
static void
static void
handler (int sig, siginfo_t *info, void *context)
handler (int sig, siginfo_t *info, void *context)
{
{
  /* Copy to local vars, as the test wants to read them, and si_addr,
  /* Copy to local vars, as the test wants to read them, and si_addr,
     etc. may be preprocessor defines.  */
     etc. may be preprocessor defines.  */
  int ssi_errno = info->si_errno;
  int ssi_errno = info->si_errno;
  int ssi_signo = info->si_signo;
  int ssi_signo = info->si_signo;
  int ssi_code = info->si_code;
  int ssi_code = info->si_code;
  void *ssi_addr = info->si_addr;
  void *ssi_addr = info->si_addr;
 
 
  _exit (0); /* set breakpoint here */
  _exit (0); /* set breakpoint here */
}
}
 
 
int
int
main (void)
main (void)
{
{
  /* Set up unwritable memory.  */
  /* Set up unwritable memory.  */
  {
  {
    size_t len;
    size_t len;
    len = sysconf(_SC_PAGESIZE);
    len = sysconf(_SC_PAGESIZE);
    p = mmap (0, len, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
    p = mmap (0, len, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
    if (p == MAP_FAILED)
    if (p == MAP_FAILED)
      {
      {
        perror ("mmap");
        perror ("mmap");
        return 1;
        return 1;
      }
      }
  }
  }
  /* Set up the signal handler.  */
  /* Set up the signal handler.  */
  {
  {
    struct sigaction action;
    struct sigaction action;
    memset (&action, 0, sizeof (action));
    memset (&action, 0, sizeof (action));
    action.sa_sigaction = handler;
    action.sa_sigaction = handler;
    action.sa_flags |= SA_SIGINFO;
    action.sa_flags |= SA_SIGINFO;
    if (sigaction (SIGSEGV, &action, NULL))
    if (sigaction (SIGSEGV, &action, NULL))
      {
      {
        perror ("sigaction");
        perror ("sigaction");
        return 1;
        return 1;
      }
      }
  }
  }
  /* Trigger SIGSEGV.  */
  /* Trigger SIGSEGV.  */
  *(int *)p = 0;
  *(int *)p = 0;
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.