A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
demangle.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005,2006 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
* Modified by: Gabriel Ferreira <gabrielcarvfer@gmail.com>
8
* Moved the Demangle function out of CallbackImplBase
9
*/
10
11
#include "
demangle.h
"
12
13
#include "
assert.h
"
14
#include "
log.h
"
15
16
NS_LOG_COMPONENT_DEFINE
(
"Demangle"
);
17
18
#if (__GNUC__ >= 3)
19
20
#include <cstdlib>
21
#include <cxxabi.h>
22
23
std::string
24
ns3::Demangle
(
const
std::string& mangled)
25
{
26
NS_LOG_FUNCTION
(mangled);
27
28
int
status;
29
char
* demangled = abi::__cxa_demangle(mangled.c_str(),
nullptr
,
nullptr
, &status);
30
31
std::string ret;
32
if
(status == 0)
33
{
34
NS_ASSERT
(demangled);
35
ret = demangled;
36
}
37
else
if
(status == -1)
38
{
39
NS_LOG_DEBUG
(
"Demangling failed: Memory allocation failure occurred."
);
40
ret = mangled;
41
}
42
else
if
(status == -2)
43
{
44
NS_LOG_DEBUG
(
"Demangling failed: Mangled name is not a valid under the C++ ABI "
45
"mangling rules."
);
46
ret = mangled;
47
}
48
else
if
(status == -3)
49
{
50
NS_LOG_DEBUG
(
"Demangling failed: One of the arguments is invalid."
);
51
ret = mangled;
52
}
53
else
54
{
55
NS_LOG_DEBUG
(
"Demangling failed: status "
<< status);
56
ret = mangled;
57
}
58
59
if
(demangled)
60
{
61
std::free(demangled);
62
}
63
return
ret;
64
}
65
66
#else
67
68
std::string
69
ns3::Demangle
(
const
std::string& mangled)
70
{
71
NS_LOG_FUNCTION
(mangled);
72
return
mangled;
73
}
74
75
#endif
assert.h
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
demangle.h
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
log.h
Debug message logging.
ns3::Demangle
std::string Demangle(const std::string &mangled)
Definition
demangle.cc:69
src
core
model
demangle.cc
Generated on Thu Dec 12 2024 18:40:36 for ns-3 by
1.11.0