Fix perf_submit() calls with array data crashing libbcc
A perf_submit() call like:
unsigned char buf[16] = ...;
output.perf_submit(ctx, buf, sizeof(buf));
Passes a non-pointer arg1, so getPointeeType().getTypePtr() is invalid,
and crashes libbcc.
Use getTypePtrOrNull() instead to avoid it.
@@ -925,8 +925,8 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
// events.perf_submit(ctx, &data, sizeof(data));
// ...
// &data -> data -> typeof(data) -> data_t
- auto type_arg1 = Call->getArg(1)->IgnoreCasts()->getType().getTypePtr()->getPointeeType().getTypePtr();
- if (type_arg1->isStructureType()) {
+ auto type_arg1 = Call->getArg(1)->IgnoreCasts()->getType().getTypePtr()->getPointeeType().getTypePtrOrNull();
+ if (type_arg1 && type_arg1->isStructureType()) {
auto event_type = type_arg1->getAsTagDecl();
const auto *r = dyn_cast<RecordDecl>(event_type);
std::vector<std::string> perf_event;
