-/*
- * 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 <config.h>
+#endif
+
#include <glib.h>
#include <stdio.h>
#include <string.h>
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:
}
break;
case ' ':
- if (name_end && name_begin) {
+ if (!name_end && name_begin) {
name_end = fmt;
if (name)
g_free(name);
}
break; /* Skip white spaces */
default:
- if (!name) {
+ if (!name_begin) {
name_begin = fmt;
name_end = NULL;
}
g_error("Error parsing marker format \"%s\" for marker \"%s\"", format,
g_quark_to_string(name));
}
+ return 0;
}
int marker_id_event(LttTrace *trace, GQuark name, guint16 id,
uint8_t size_t_size, uint8_t alignment)
{
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;
if (!head)
g_hash_table_insert(trace->markers_hash, (gpointer)name, info);
else {
- g_hash_table_replace(trace->markers_hash, (gpointer)name, info);
- info->next = head;
+ struct marker_info *iter;
+ for (iter = head; iter != NULL; iter = iter->next)
+ if (iter->name == name)
+ found = 1;
+ if (!found) {
+ g_hash_table_replace(trace->markers_hash, (gpointer)name, info);
+ info->next = head;
+ }
}
+ return 0;
}
int allocate_marker_data(LttTrace *trace)