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