src/core/breakpoint.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 1211 f96d69ef6038
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2006,2007 INRIA, INESC Porto
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License version 2 as
     7  * published by the Free Software Foundation;
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    19  * Author: Gustavo Carneiro <gjc@inescporto.pt>
    20  */
    21 
    22 #include "breakpoint.h"
    23 #include "ns3/core-config.h"
    24 #ifdef HAVE_SIGNAL_H
    25 # include <signal.h>
    26 #endif
    27 
    28 namespace ns3 {
    29 
    30 #if defined (HAVE_SIGNAL_H) && defined (SIGTRAP)
    31 
    32 void
    33 BreakpointFallback (void)
    34 {
    35   raise (SIGTRAP);
    36 }
    37 
    38 #else
    39 
    40 void
    41 BreakpointFallback (void)
    42 {
    43   int *a = 0;
    44   /**
    45    * we test here to allow a debugger to change the value of
    46    * the variable 'a' to allow the debugger to avoid the 
    47    * subsequent segfault.
    48    */
    49   if (a == 0)
    50     {
    51       *a = 0;
    52     }
    53 }
    54 
    55 #endif // HAVE_SIGNAL_H
    56 
    57 }//namespace ns3