MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / printSourceFileAndLine

Function printSourceFileAndLine

src/OSspecific/POSIX/printStack.C:92–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90
91
92void printSourceFileAndLine
93(
94 Ostream& os,
95 const fileName& filename,
96 Dl_info *info,
97 void *addr
98)
99{
100 uintptr_t address = uintptr_t(addr);
101 word myAddress = addressToWord(address);
102
103 if (filename.ext() == "so")
104 {
105 // Convert address into offset into dynamic library
106 uintptr_t offset = uintptr_t(info->dli_fbase);
107 intptr_t relativeAddress = address - offset;
108 myAddress = addressToWord(relativeAddress);
109 }
110
111 if (filename[0] == '/')
112 {
113 string line = pOpen
114 (
115 "addr2line -f --demangle=auto --exe "
116 + filename
117 + " "
118 + myAddress,
119 1
120 );
121
122 if (line == "")
123 {
124 os << " addr2line failed";
125 }
126 else if (line == "??:0")
127 {
128 os << " in " << filename;
129 }
130 else
131 {
132 string cwdLine(line.replaceAll(cwd() + '/', ""));
133 string homeLine(cwdLine.replaceAll(home(), '~'));
134
135 os << " at " << homeLine.c_str();
136 }
137 }
138}
139
140
141fileName absolutePath(const char* fn)

Callers 1

printStackFunction · 0.85

Calls 1

addressToWordFunction · 0.85

Tested by

no test coverage detected