X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fmarker.c;h=7b19391b0734baf67b6d2b0566ee5d0a5dfdb293;hb=7f440a66c6e6429ce477d208545b6965554ba4cb;hp=07c50f27d3581809dfc4b898bfd7fd0c045db7ee;hpb=565460eafbf79918133fa354b0827aa5a692f46e;p=lttv.git diff --git a/ltt/branches/poly/ltt/marker.c b/ltt/branches/poly/ltt/marker.c index 07c50f27..7b19391b 100644 --- a/ltt/branches/poly/ltt/marker.c +++ b/ltt/branches/poly/ltt/marker.c @@ -1,10 +1,27 @@ -/* - * Marker support code. +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2007 Mathieu Desnoyers + * + * Complete rewrite from the original version made by XangXiu Yang. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * Mathieu Desnoyers, August 2007 - * License: LGPL. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -63,7 +80,7 @@ static inline const char *parse_trace_type(struct marker_info *info, *trace_type = LTT_TYPE_STRING; goto parse_end; case 'p': - *trace_type = LTT_TYPE_UNSIGNED_INT; + *trace_type = LTT_TYPE_POINTER; *trace_size = info->pointer_size; goto parse_end; case 'd': @@ -167,7 +184,7 @@ static inline const char *parse_c_type(struct marker_info *info, *c_type = LTT_TYPE_STRING; goto parse_end; case 'p': - *c_type = LTT_TYPE_UNSIGNED_INT; + *c_type = LTT_TYPE_POINTER; *c_size = info->pointer_size; goto parse_end; case 'd': @@ -233,6 +250,7 @@ static inline long add_type(struct marker_info *info, switch (trace_type) { case LTT_TYPE_SIGNED_INT: case LTT_TYPE_UNSIGNED_INT: + case LTT_TYPE_POINTER: field->size = trace_size; field->alignment = trace_size; field->attributes = attributes; @@ -267,15 +285,22 @@ long marker_update_fields_offsets(struct marker_info *info, const char *data) unsigned int i; long offset = 0; - for (i = 0; i < info->fields->len; i++) { + /* Find the last field with a static offset, then update from there. */ + for (i = info->fields->len - 1; i >= 0; i--) { field = &g_array_index(info->fields, struct marker_field, i); + if (field->static_offset) { + offset = field->offset; + break; + } + } - if (field->static_offset) - continue; + for (; i < info->fields->len; i++) { + field = &g_array_index(info->fields, struct marker_field, i); switch (field->type) { case LTT_TYPE_SIGNED_INT: case LTT_TYPE_UNSIGNED_INT: + case LTT_TYPE_POINTER: field->offset = offset + ltt_align(offset, field->alignment, info->alignment); offset = field->offset + field->size; @@ -405,7 +430,7 @@ int marker_id_event(LttTrace *trace, GQuark name, guint16 id, struct marker_info *info, *head; int found = 0; - if (trace->markers->len < id) + if (trace->markers->len <= id) trace->markers = g_array_set_size(trace->markers, id+1); info = &g_array_index(trace->markers, struct marker_info, id); info->name = name;