Skip to content

Commit

Permalink
fix a bug in tracepoint struct rewriter (iovisor#1856)
Browse files Browse the repository at this point in the history
Fix issue iovisor#1853.

Commit 7c48946 ("adjust tracepoint field type
based on size") tried to fix the tracepoint format
descrepancy between declared type and actual size is 8.
The type has to be promoted to match the size.

The commit introduced a bug if the field is an array.
For exmaple, block:block_rq_complete tracepoint has
field rwbs:
  field:char rwbs[8];	offset:32;	size:8;	signed:1;

The current implementation will incorrectly translate it
into
  s64 rwbs[8];
since it considers the type is "char".

This patch fixed this issue by checking the field name
and if it is an array, rewriting will be skipped.

Signed-off-by: Yonghong Song <[email protected]>
  • Loading branch information
yonghong-song committed Jun 26, 2018
1 parent eba1483 commit c2e2a26
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cc/frontends/clang/tp_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ static inline field_kind_t _get_field_kind(string const& line,
return field_kind_t::data_loc;
if (field_name.find("common_") == 0)
return field_kind_t::common;
// do not change type definition for array
if (field_name.find("[") != string::npos)
return field_kind_t::regular;

// adjust the field_type based on the size of field
// otherwise, incorrect value may be retrieved for big endian
Expand Down

0 comments on commit c2e2a26

Please sign in to comment.