MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / GTEST_LOCK_EXCLUDED_

Function GTEST_LOCK_EXCLUDED_

tests/gtest/gtest-all.cc:5870–5917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5868
5869std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)
5870 GTEST_LOCK_EXCLUDED_(mutex_) {
5871#if GTEST_HAS_ABSL
5872 std::string result;
5873
5874 if (max_depth <= 0) {
5875 return result;
5876 }
5877
5878 max_depth = std::min(max_depth, kMaxStackTraceDepth);
5879
5880 std::vector<void*> raw_stack(max_depth);
5881 // Skips the frames requested by the caller, plus this function.
5882 const int raw_stack_size =
5883 absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1);
5884
5885 void* caller_frame = nullptr;
5886 {
5887 MutexLock lock(&mutex_);
5888 caller_frame = caller_frame_;
5889 }
5890
5891 for (int i = 0; i < raw_stack_size; ++i) {
5892 if (raw_stack[i] == caller_frame &&
5893 !GTEST_FLAG(show_internal_stack_frames)) {
5894 // Add a marker to the trace and stop adding frames.
5895 absl::StrAppend(&result, kElidedFramesMarker, "\n");
5896 break;
5897 }
5898
5899 char tmp[1024];
5900 const char* symbol = "(unknown)";
5901 if (absl::Symbolize(raw_stack[i], tmp, sizeof(tmp))) {
5902 symbol = tmp;
5903 }
5904
5905 char line[1024];
5906 snprintf(line, sizeof(line), " %p: %s\n", raw_stack[i], symbol);
5907 result += line;
5908 }
5909
5910 return result;
5911
5912#else // !GTEST_HAS_ABSL
5913 static_cast<void>(max_depth);
5914 static_cast<void>(skip_count);
5915 return "";
5916#endif // GTEST_HAS_ABSL
5917}
5918
5919void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
5920#if GTEST_HAS_ABSL

Callers 2

gtest.hFile · 0.85
gtest-all.ccFile · 0.85

Calls 6

FormatFileLocationFunction · 0.85
GetStringMethod · 0.80
ReportTestPartResultMethod · 0.80
TestPartResultFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected