X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fevent.c;h=3b28f57616ed5baa6eb0ff74c3fc2fffdbfc6584;hb=2864f4c5ccd6f4d5401b40a05b4f4d816617a557;hp=46333ffbb4fb50df99703e1f69dfcfc3322ad806;hpb=e4eced0fb7cd23ba2b16eff08f2185bed49ab5e5;p=lttv.git diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 46333ffb..3b28f576 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -1,9 +1,30 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2003-2004 Xiangxiu Yang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + #include #include #include -#include + #include "parser.h" +#include +#include "ltt-private.h" #include +#include /***************************************************************************** *Function name @@ -201,6 +222,11 @@ void ltt_event_position(LttEvent *e, LttEventPosition *ep) ep->tf = e->tracefile; } +LttEventPosition * ltt_event_position_new() +{ + return g_new(LttEventPosition, 1); +} + /***************************************************************************** *Function name * ltt_event_position_get : get the block number and index of the event @@ -244,8 +270,23 @@ void ltt_event_position_set(LttEventPosition *ep, ****************************************************************************/ unsigned ltt_event_cpu_id(LttEvent *e) -{ - return (unsigned)atoi(e->tracefile->name); +{ + char * c1, * c2, * c3; + c1 = strrchr(e->tracefile->name,'\\'); + c2 = strrchr(e->tracefile->name,'/'); + if(c1 == NULL && c2 == NULL){ + return (unsigned)atoi(e->tracefile->name); + }else if(c1 == NULL){ + c2++; + return (unsigned)atoi(c2); + }else if(c2 == NULL){ + c1++; + return (unsigned)atoi(c1); + }else{ + c3 = (c1 > c2) ? c1 : c2; + c3++; + return (unsigned)atoi(c3); + } } /***************************************************************************** @@ -337,17 +378,26 @@ unsigned ltt_event_get_unsigned(LttEvent *e, LttField *f) g_error("The type of the field is not unsigned int\n"); if(f->field_size == 1){ - uint8_t x = *(uint8_t*)(e->data + f->offset_root); + guint8 x = *(guint8 *)(e->data + f->offset_root); return (unsigned int) x; }else if(f->field_size == 2){ - uint16_t x = *(uint16_t*)(e->data + f->offset_root); - return (unsigned int) (revFlag ? BREV16(x): x); + guint16 x = *(guint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned int) (revFlag ? GUINT16_FROM_BE(x): x); + else + return (unsigned int) (revFlag ? GUINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - uint32_t x = *(uint32_t*)(e->data + f->offset_root); - return (unsigned int) (revFlag ? BREV32(x): x); + guint32 x = *(guint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned int) (revFlag ? GUINT32_FROM_BE(x): x); + else + return (unsigned int) (revFlag ? GUINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - uint64_t x = *(uint64_t*)(e->data + f->offset_root); - return (unsigned int) (revFlag ? BREV64(x): x); + guint64 x = *(guint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned int) (revFlag ? GUINT64_FROM_BE(x): x); + else + return (unsigned int) (revFlag ? GUINT64_FROM_LE(x): x); } } @@ -360,17 +410,26 @@ int ltt_event_get_int(LttEvent *e, LttField *f) g_error("The type of the field is not int\n"); if(f->field_size == 1){ - int8_t x = *(int8_t*)(e->data + f->offset_root); + gint8 x = *(gint8 *)(e->data + f->offset_root); return (int) x; }else if(f->field_size == 2){ - int16_t x = *(int16_t*)(e->data + f->offset_root); - return (int) (revFlag ? BREV16(x): x); + gint16 x = *(gint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (int) (revFlag ? GINT16_FROM_BE(x): x); + else + return (int) (revFlag ? GINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - int32_t x = *(int32_t*)(e->data + f->offset_root); - return (int) (revFlag ? BREV32(x): x); + gint32 x = *(gint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (int) (revFlag ? GINT32_FROM_BE(x): x); + else + return (int) (revFlag ? GINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - int64_t x = *(int64_t*)(e->data + f->offset_root); - return (int) (revFlag ? BREV64(x): x); + gint64 x = *(gint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (int) (revFlag ? GINT64_FROM_BE(x): x); + else + return (int) (revFlag ? GINT64_FROM_LE(x): x); } } @@ -384,17 +443,26 @@ unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f) g_error("The type of the field is not unsigned long\n"); if(f->field_size == 1){ - uint8_t x = *(uint8_t*)(e->data + f->offset_root); + guint8 x = *(guint8 *)(e->data + f->offset_root); return (unsigned long) x; }else if(f->field_size == 2){ - uint16_t x = *(uint16_t*)(e->data + f->offset_root); - return (unsigned long) (revFlag ? BREV16(x): x); + guint16 x = *(guint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned long) (revFlag ? GUINT16_FROM_BE(x): x); + else + return (unsigned long) (revFlag ? GUINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - uint32_t x = *(uint32_t*)(e->data + f->offset_root); - return (unsigned long) (revFlag ? BREV32(x): x); + guint32 x = *(guint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned long) (revFlag ? GUINT32_FROM_BE(x): x); + else + return (unsigned long) (revFlag ? GUINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - uint64_t x = *(uint64_t*)(e->data + f->offset_root); - return (unsigned long) (revFlag ? BREV64(x): x); + guint64 x = *(guint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (unsigned long) (revFlag ? GUINT64_FROM_BE(x): x); + else + return (unsigned long) (revFlag ? GUINT64_FROM_LE(x): x); } } @@ -407,17 +475,26 @@ long int ltt_event_get_long_int(LttEvent *e, LttField *f) g_error("The type of the field is not long int\n"); if(f->field_size == 1){ - int8_t x = *(int8_t*)(e->data + f->offset_root); + gint8 x = *(gint8 *)(e->data + f->offset_root); return (long) x; }else if(f->field_size == 2){ - int16_t x = *(int16_t*)(e->data + f->offset_root); - return (long) (revFlag ? BREV16(x): x); + gint16 x = *(gint16 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (long) (revFlag ? GINT16_FROM_BE(x): x); + else + return (long) (revFlag ? GINT16_FROM_LE(x): x); }else if(f->field_size == 4){ - int32_t x = *(int32_t*)(e->data + f->offset_root); - return (long) (revFlag ? BREV32(x): x); + gint32 x = *(gint32 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (long) (revFlag ? GINT32_FROM_BE(x): x); + else + return (long) (revFlag ? GINT32_FROM_LE(x): x); }else if(f->field_size == 8){ - int64_t x = *(int64_t*)(e->data + f->offset_root); - return (long) (revFlag ? BREV64(x): x); + gint64 x = *(gint64 *)(e->data + f->offset_root); + if(e->tracefile->trace->my_arch_endian == LTT_LITTLE_ENDIAN) + return (long) (revFlag ? GINT64_FROM_BE(x): x); + else + return (long) (revFlag ? GINT64_FROM_LE(x): x); } } @@ -432,7 +509,7 @@ float ltt_event_get_float(LttEvent *e, LttField *f) if(revFlag == 0) return *(float *)(e->data + f->offset_root); else{ - uint32_t aInt; + guint32 aInt; memcpy((void*)&aInt, e->data + f->offset_root, 4); aInt = ___swab32(aInt); return *((float*)&aInt); @@ -450,7 +527,7 @@ double ltt_event_get_double(LttEvent *e, LttField *f) if(revFlag == 0) return *(double *)(e->data + f->offset_root); else{ - uint64_t aInt; + guint64 aInt; memcpy((void*)&aInt, e->data + f->offset_root, 8); aInt = ___swab64(aInt); return *((double *)&aInt);