qemu-e2k/trace
Markus Armbruster fb3a508531 trace: Fix simple trace dropped event record for big endian
We use atomic operations to keep track of dropped events.

Inconveniently, GLib supports only int and void * atomics, but the
counter dropped_events is uint64_t.  Can't stop commit 62bab732: a
quick (gint *)&dropped_events bludgeons the compiler into submission.

That cast is okay only when int is exactly 64 bits wide, which it
commonly isn't.

If int is even wider, we clobber whatever follows dropped_events.  Not
worth worrying about, as none of the machines that interest us have
such morbidly obese ints.

That leaves the common case: int narrower than 64 bits.

Harmless on little endian hosts: we just don't access the most
significant bits of dropped_events.  They remain zero.

On big endian hosts, we use only the most significant bits of
dropped_events as counter.  The least significant bits remain zero.
However, we write out the full value, which is the correct counter
shifted left a bunch of places.

Fix by changing the variables involved to int.

There's another, equally suspicious-looking (gint *)&trace_idx
argument to g_atomic_int_compare_and_exchange(), but that one casts
unsigned *, so it's okay.  But it's also superfluous, because GLib's
atomic int operations work just fine for unsigned.  Drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-02-05 21:52:55 +01:00
..
Makefile.objs Makefile: clean timestamp generation rule 2013-01-30 01:31:08 +02:00
control.c trace: allow disabling events in events file 2012-11-16 13:12:13 +01:00
control.h trace: add "-trace events" argument to control initial state 2011-09-01 10:34:54 +01:00
default.c trace: add "-trace events" argument to control initial state 2011-09-01 10:34:54 +01:00
simple.c trace: Fix simple trace dropped event record for big endian 2013-02-05 21:52:55 +01:00
simple.h trace: drop unused TraceBufferRecord->next_tbuf_idx field 2012-08-14 10:40:39 +01:00
stderr.c trace: Add wildcard trace event support 2011-11-01 14:12:15 +00:00
stderr.h trace: [stderr] add support for dynamically enabling/disabling events 2011-09-01 10:34:54 +01:00