1
1
/*
2
- * Copyright (c) 2000, 2020 , Oracle and/or its affiliates.
2
+ * Copyright (c) 2000, 2024 , Oracle and/or its affiliates.
3
3
*
4
4
* Licensed under the Universal Permissive License v 1.0 as shown at
5
- * http ://oss.oracle.com/licenses/upl.
5
+ * https ://oss.oracle.com/licenses/upl.
6
6
*/
7
7
#ifndef COH_GLIBC_BACKTRACE_HPP
8
8
#define COH_GLIBC_BACKTRACE_HPP
14
14
#include " private/coherence/native/NativeBacktrace.hpp"
15
15
#include " private/coherence/native/NativeABI.hpp"
16
16
#include " private/coherence/native/NativeStackElement.hpp"
17
+
17
18
#include " private/coherence/util/StringHelper.hpp"
18
19
19
20
#ifndef __USE_GNU
@@ -34,7 +35,6 @@ COH_OPEN_NAMESPACE2(coherence,native)
34
35
using coherence::util::ArrayList;
35
36
using coherence::util::StringHelper;
36
37
37
-
38
38
// ----- file local helpers -------------------------------------------------
39
39
40
40
namespace
@@ -52,49 +52,56 @@ namespace
52
52
53
53
ObjectArray::Handle NativeBacktrace::getStackTrace (size32_t cTrim)
54
54
{
55
- static bool fTrim = Boolean::parse (System::getProperty
56
- (" coherence.threaddump.trim" , " true" )); // for diagnostics
55
+ // COH-31048 - more relevant for Windows, but include support here as well
56
+ static bool fEnabled = Boolean::parse (System::getProperty
57
+ (" coherence.backtrace.enabled" , " true" ));
57
58
58
- ArrayList::Handle haFrames = ArrayList::create ();
59
- String::View vsThreadRun = getThreadRun ();
60
- void *frames[100 ];
61
- int size;
62
-
63
- size = backtrace (frames, 100 );
64
- cTrim += 1 ;
59
+ static bool fTrim = Boolean::parse (System::getProperty
60
+ (" coherence.threaddump.trim" , " true" )); // for diagnostics
65
61
66
- for (int i = 0 , c = size - 1 ; i < c; i++)
62
+ ArrayList::Handle haFrames = ArrayList::create ();
63
+ if (fEnabled )
67
64
{
68
- if (fTrim && cTrim)
69
- {
70
- --cTrim;
71
- }
72
- else
73
- {
74
- void *pc = frames[i];
65
+ String::View vsThreadRun = getThreadRun ();
66
+ void *frames[100 ];
67
+ int size;
75
68
76
- Dl_info info;
69
+ size = backtrace (frames, 100 );
70
+ cTrim += 1 ;
77
71
78
- if (dladdr (pc, &info) == 0 )
72
+ for (int i = 0 , c = size - 1 ; i < c; i++)
73
+ {
74
+ if (fTrim && cTrim)
79
75
{
80
- break ;
76
+ --cTrim;
77
+ }
78
+ else
79
+ {
80
+ void *pc = frames[i];
81
+
82
+ Dl_info info;
83
+
84
+ if (dladdr (pc, &info) == 0 )
85
+ {
86
+ break ;
87
+ }
88
+
89
+ String::View vsName = (info.dli_sname
90
+ ? NativeABI::demangle (info.dli_sname )
91
+ : (String::View) StringHelper::getEmptyString ());
92
+
93
+ haFrames->add (NativeStackElement::create (
94
+ (info.dli_fname
95
+ ? String::create (info.dli_fname )
96
+ : StringHelper::getEmptyString ()),
97
+ vsName));
98
+
99
+ // trim off OS specific bits below coherence created threads
100
+ if (fTrim && vsName->endsWith (vsThreadRun))
101
+ {
102
+ break ;
103
+ }
81
104
}
82
-
83
- String::View vsName = (info.dli_sname
84
- ? NativeABI::demangle (info.dli_sname )
85
- : (String::View) StringHelper::getEmptyString ());
86
-
87
- haFrames->add (NativeStackElement::create (
88
- (info.dli_fname
89
- ? String::create (info.dli_fname )
90
- : StringHelper::getEmptyString ()),
91
- vsName));
92
-
93
- // trim off OS specific bits below coherence created threads
94
- if (fTrim && vsName->endsWith (vsThreadRun))
95
- {
96
- break ;
97
- }
98
105
}
99
106
}
100
107
0 commit comments