bpftrace/SOURCES/bpftrace-0.9-fix-struct-definition-from-headers.patch

33 lines
1.1 KiB
Diff
Raw Normal View History

2019-11-05 19:45:41 +00:00
From 151351ea22c855e4e605b8fd2058c19dc4ae5ed6 Mon Sep 17 00:00:00 2001
From: Matheus Marchini <mat@mmarchini.me>
Date: Tue, 16 Apr 2019 12:06:01 -0700
Subject: [PATCH 2/2] fix struct definition from headers
Regression caused by iovisor/bpftrace@80ce138c7. With the changes on how
we identify the parent struct, we ended up with our parent cursor in the
header file sometimes instead of a valid cursor. This PR checks if the
parent cursor is a struct, otherwise returns an empty string and let the
caller handle the situation (which is similar to the previous behavior).
---
src/clang_parser.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/clang_parser.cpp b/src/clang_parser.cpp
index b1db8ff..b787b67 100644
--- a/src/clang_parser.cpp
+++ b/src/clang_parser.cpp
@@ -40,6 +40,10 @@ static std::string get_parent_struct_name(CXCursor c)
{
CXCursor parent = get_indirect_field_parent_struct(c);
+ if (clang_getCursorKind(parent) != CXCursor_StructDecl &&
+ clang_getCursorKind(parent) != CXCursor_UnionDecl)
+ return "";
+
return get_clang_string(clang_getCursorSpelling(parent));
}
--
2.20.1