L4Re - L4 Runtime Environment
std_exc_io
Go to the documentation of this file.
1 // vi:set ft=cpp: -*- Mode: C++ -*-
2 /**
3  * \file
4  * \brief Base exceptions std stream operator
5  * \ingroup l4cxx_exceptions
6  */
7 /*
8  * (c) 2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9  * Alexander Warg <warg@os.inf.tu-dresden.de>
10  * economic rights: Technische Universit├Ąt Dresden (Germany)
11  *
12  * This file is part of TUD:OS and distributed under the terms of the
13  * GNU General Public License 2.
14  * Please see the COPYING-GPL-2 file for details.
15  *
16  * As a special exception, you may use this file as part of a free software
17  * library without restriction. Specifically, if other files instantiate
18  * templates or use macros or inline functions from this file, or you compile
19  * this file and link it with other files to produce an executable, this
20  * file does not by itself cause the resulting executable to be covered by
21  * the GNU General Public License. This exception does not however
22  * invalidate any other reasons why the executable file might be covered by
23  * the GNU General Public License.
24  */
25 
26 #pragma once
27 
28 #include <l4/cxx/exceptions>
29 #include <iostream>
30 
31 inline
32 std::ostream &
33 operator << (std::ostream &o, L4::Base_exception const &e)
34 {
35  o << "Exception: " << e.str() << ", backtrace ...\n";
36  for (int i = 0; i < e.frame_count(); ++i)
37  o << (void *)(e.pc_array()[i]) << '\n';
38 
39  return o;
40 }
41 
42 inline
43 std::ostream &
44 operator << (std::ostream &o, L4::Runtime_error const &e)
45 {
46  o << "Exception: " << e.str() << ": ";
47  if (e.extra_str())
48  o << e.extra_str() << ": ";
49  o << "backtrace ...\n";
50  for (int i = 0; i < e.frame_count(); ++i)
51  o << (void *)(e.pc_array()[i]) << '\n';
52 
53  return o;
54 }