Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary workaround for unsupported DWARF location types #626

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions pkg/internal/goexec/structmembers.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func structMemberOffsetsFromDwarf(data *dwarf.Data) (FieldOffsets, map[string]st
}
log.Debug("inspecting fields for struct type", "type", typeName)
if err := readMembers(reader, structMember.fields, expectedReturns, fieldOffsets); err != nil {
log.Debug("error reading DRWARF info", "type", typeName, "members", err)
log.Debug("error reading DWARF info", "type", typeName, "error", err)
return nil, expectedReturns
}
}
Expand All @@ -306,6 +306,7 @@ func readMembers(
expectedReturns map[string]struct{},
offsets FieldOffsets,
) error {
log := log()
for {
entry, err := reader.Next()
if err != nil {
Expand All @@ -320,11 +321,18 @@ func readMembers(
}
attrs := getAttrs(entry)
if constName, ok := fields[attrs[dwarf.AttrName].(string)]; ok {
delete(expectedReturns, constName)
value := attrs[dwarf.AttrDataMemberLoc]
log().Debug("found struct member offset",
"const", constName, "offset", attrs[dwarf.AttrDataMemberLoc])
offsets[constName] = uint64(value.(int64))
if constLocation, ok := value.(int64); ok {
delete(expectedReturns, constName)
log.Debug("found struct member offset",
"const", constName, "offset", attrs[dwarf.AttrDataMemberLoc])
offsets[constName] = uint64(constLocation)
} else {
// Temporary workaround
// TODO: properly address issue https://github.com/grafana/beyla/issues/625
return fmt.Errorf("at the moment, Beyla only supports constant values for DW_AT_data_member_location;"+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use the logger for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be logged as debug from the code that receives the error.

"got %s. Beyla will read the offsets from a pre-fetched database", attrs[dwarf.AttrDataMemberLoc])
}
}
}
}
Expand Down
Loading