@@ -54,6 +54,7 @@ struct hist_field {
54
54
unsigned int size ;
55
55
unsigned int offset ;
56
56
unsigned int is_signed ;
57
+ const char * type ;
57
58
struct hist_field * operands [HIST_FIELD_OPERANDS_MAX ];
58
59
struct hist_trigger_data * hist_data ;
59
60
struct hist_var var ;
@@ -717,6 +718,7 @@ static void destroy_hist_field(struct hist_field *hist_field,
717
718
718
719
kfree (hist_field -> var .name );
719
720
kfree (hist_field -> name );
721
+ kfree (hist_field -> type );
720
722
721
723
kfree (hist_field );
722
724
}
@@ -742,6 +744,10 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
742
744
743
745
if (flags & HIST_FIELD_FL_HITCOUNT ) {
744
746
hist_field -> fn = hist_field_counter ;
747
+ hist_field -> size = sizeof (u64 );
748
+ hist_field -> type = kstrdup ("u64" , GFP_KERNEL );
749
+ if (!hist_field -> type )
750
+ goto free ;
745
751
goto out ;
746
752
}
747
753
@@ -755,12 +761,18 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
755
761
hist_field -> fn = hist_field_log2 ;
756
762
hist_field -> operands [0 ] = create_hist_field (hist_data , field , fl , NULL );
757
763
hist_field -> size = hist_field -> operands [0 ]-> size ;
764
+ hist_field -> type = kstrdup (hist_field -> operands [0 ]-> type , GFP_KERNEL );
765
+ if (!hist_field -> type )
766
+ goto free ;
758
767
goto out ;
759
768
}
760
769
761
770
if (flags & HIST_FIELD_FL_TIMESTAMP ) {
762
771
hist_field -> fn = hist_field_timestamp ;
763
772
hist_field -> size = sizeof (u64 );
773
+ hist_field -> type = kstrdup ("u64" , GFP_KERNEL );
774
+ if (!hist_field -> type )
775
+ goto free ;
764
776
goto out ;
765
777
}
766
778
@@ -770,13 +782,24 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
770
782
if (is_string_field (field )) {
771
783
flags |= HIST_FIELD_FL_STRING ;
772
784
785
+ hist_field -> size = MAX_FILTER_STR_VAL ;
786
+ hist_field -> type = kstrdup (field -> type , GFP_KERNEL );
787
+ if (!hist_field -> type )
788
+ goto free ;
789
+
773
790
if (field -> filter_type == FILTER_STATIC_STRING )
774
791
hist_field -> fn = hist_field_string ;
775
792
else if (field -> filter_type == FILTER_DYN_STRING )
776
793
hist_field -> fn = hist_field_dynstring ;
777
794
else
778
795
hist_field -> fn = hist_field_pstring ;
779
796
} else {
797
+ hist_field -> size = field -> size ;
798
+ hist_field -> is_signed = field -> is_signed ;
799
+ hist_field -> type = kstrdup (field -> type , GFP_KERNEL );
800
+ if (!hist_field -> type )
801
+ goto free ;
802
+
780
803
hist_field -> fn = select_value_fn (field -> size ,
781
804
field -> is_signed );
782
805
if (!hist_field -> fn ) {
@@ -949,6 +972,11 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
949
972
expr -> operands [0 ] = operand1 ;
950
973
expr -> operator = FIELD_OP_UNARY_MINUS ;
951
974
expr -> name = expr_str (expr , 0 );
975
+ expr -> type = kstrdup (operand1 -> type , GFP_KERNEL );
976
+ if (!expr -> type ) {
977
+ ret = - ENOMEM ;
978
+ goto free ;
979
+ }
952
980
953
981
return expr ;
954
982
free :
@@ -1042,6 +1070,11 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
1042
1070
expr -> operands [1 ] = operand2 ;
1043
1071
expr -> operator = field_op ;
1044
1072
expr -> name = expr_str (expr , 0 );
1073
+ expr -> type = kstrdup (operand1 -> type , GFP_KERNEL );
1074
+ if (!expr -> type ) {
1075
+ ret = - ENOMEM ;
1076
+ goto free ;
1077
+ }
1045
1078
1046
1079
switch (field_op ) {
1047
1080
case FIELD_OP_MINUS :
0 commit comments