This file is indexed.

/usr/include/xbt/exception.hpp is in libsimgrid-dev 3.14.159-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* Copyright (c) 2005-2016. The SimGrid Team.All rights reserved. */

/* This program is free software; you can redistribute it and/or modify it
 * under the terms of the license (GNU LGPL) which comes with this package. */

#ifndef SIMGRID_XBT_EXCEPTION_HPP
#define SIMGRID_XBT_EXCEPTION_HPP

#include <string>
#include <type_traits>
#include <vector>

#include <xbt/base.h>
#include <xbt/backtrace.h>
#include <xbt/backtrace.hpp>
#include <xbt/log.h>
#include <xbt/misc.h>  // xbt_procname
#include <xbt/virtu.h> // xbt_getpid

/** @addtogroup XBT_ex
 *  @brief Exceptions support
 */

namespace simgrid {
namespace xbt {

/** A backtrace
 *
 *  This is used (among other things) in exceptions to store the associated
 *  backtrace.
 *
 *  @ingroup XBT_ex
 */
typedef std::vector<xbt_backtrace_location_t> Backtrace;

/** The location of where an exception has been throwed
 *
 *  This is a tuple (__FILE__, __LINE__, __func__) and can be created with
 *  @ref XBT_THROW_POINT.
 *
 *  @ingroup XBT_ex
 */
class ThrowPoint {
 public:
  ThrowPoint() = default;
  ThrowPoint(const char* file, int line, const char* function) :
    file(file), line(line), function(function) {}
  const char* file = nullptr;
  int line = 0;
  const char* function = nullptr;
};

/** Create a ThrowPoint with (__FILE__, __LINE__, __func__) */
#define XBT_THROW_POINT ::simgrid::xbt::ThrowPoint(__FILE__, __LINE__, __func__)

/** A base class for exceptions with context
 *
 *  This is a base class for exceptions which store additional contextual
 *  infomations about them: backtrace, throw point, simulated process name
 *  and PID, etc.
 *
 *  You are not expected to inherit from it. Instead of you use should
 *  @ref XBT_THROW an exception which will throw a subclass of your original
 *  exception with those additional features.
 * 
 *  However, you can try `dynamic_cast` an exception to this type in order to
 *  get contextual information about the exception.
 */
XBT_PUBLIC_CLASS WithContextException {
public:
  WithContextException() :
    backtrace_(simgrid::xbt::backtrace()),
    procname_(xbt_procname()),
    pid_(xbt_getpid())
  {}
  WithContextException(Backtrace bt) :
    backtrace_(std::move(bt)),
    procname_(xbt_procname()),
    pid_(xbt_getpid())
  {}
  WithContextException(ThrowPoint throwpoint, Backtrace bt) :
    backtrace_(std::move(bt)),
    procname_(xbt_procname()),
    pid_(xbt_getpid()),
    throwpoint_(throwpoint)
  {}
  virtual ~WithContextException();
  Backtrace const& backtrace() const
  {
    return backtrace_;
  }
  int pid() const { return pid_; }
  std::string const& processName() const { return procname_; }
  ThrowPoint& throwPoint() { return throwpoint_; }
private:
  Backtrace backtrace_;
  std::string procname_; /**< Name of the process who thrown this */
  int pid_;              /**< PID of the process who thrown this */
  ThrowPoint throwpoint_;
};

/** Internal class used to mixin an exception E with WithContextException */
template<class E>
class WithContext : public E, public WithContextException
{
public:

  static_assert(!std::is_base_of<WithContextException,E>::value,
    "Trying to appli WithContext twice");

  WithContext(E exception) :
    E(std::move(exception)) {}
  WithContext(E exception, ThrowPoint throwpoint, Backtrace backtrace) :
    E(std::move(exception)),
    WithContextException(throwpoint, std::move(backtrace)) {}
  WithContext(E exception, Backtrace backtrace) :
    E(std::move(exception)),
    WithContextException(std::move(backtrace)) {}
  WithContext(E exception, WithContextException context) :
    E(std::move(exception)),
    WithContextException(std::move(context)) {}
  ~WithContext() override {}
};

/** Throw a C++ exception with some context
 *
 *  @param e Exception to throw
 *  @ingroup XBT_ex
 */
#define XBT_THROW(e) \
  throw WithContext<E>(std::move(exception), throwpoint, simgrid::xbt::backtrace())

/** Throw a C++ exception with a context and a nexted exception/cause
 *
 *  @param e Exception to throw
 *  @ingroup XBT_ex
 */
#define XBT_THROW_NESTED(e) \
  std::throw_with_nested(WithContext<E>(std::move(exception), throwpoint, simgrid::xbt::backtrace()))

}
}

#endif