summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2015-03-04 15:21:13 -0600
committerGerrit Code Review2015-03-04 15:21:13 -0600
commit4487c605eaeea2b85c8511fe915a286c3aaf4da4 (patch)
tree43eae354b5c268486a3d763f7ab8d08a203fe797
parent8ee42f9c50086830edb2cdf035ad5bedcf0fa6f1 (diff)
parent66bfc5ccbda1c36923230b8dea36e86e8ac62d67 (diff)
downloadplatform-system-core-4487c605eaeea2b85c8511fe915a286c3aaf4da4.tar.gz
platform-system-core-4487c605eaeea2b85c8511fe915a286c3aaf4da4.tar.xz
platform-system-core-4487c605eaeea2b85c8511fe915a286c3aaf4da4.zip
Merge changes I0ec0fe3e,I9e5fccba
* changes: liblog: logprint use <endian.h> private: Add event payload structures to android_logger.h
-rw-r--r--include/private/android_logger.h42
-rw-r--r--liblog/logprint.c29
2 files changed, 46 insertions, 25 deletions
diff --git a/include/private/android_logger.h b/include/private/android_logger.h
index cc7ba3042..724ca5173 100644
--- a/include/private/android_logger.h
+++ b/include/private/android_logger.h
@@ -41,4 +41,46 @@ typedef struct __attribute__((__packed__)) {
41 log_time realtime; 41 log_time realtime;
42} android_log_header_t; 42} android_log_header_t;
43 43
44/* Event Header Structure to logd */
45typedef struct __attribute__((__packed__)) {
46 int32_t tag; // Little Endian Order
47} android_event_header_t;
48
49/* Event payload EVENT_TYPE_INT */
50typedef struct __attribute__((__packed__)) {
51 int8_t type; // EVENT_TYPE_INT
52 int32_t data; // Little Endian Order
53} android_event_int_t;
54
55/* Event with single EVENT_TYPE_INT */
56typedef struct __attribute__((__packed__)) {
57 android_event_header_t header;
58 android_event_int_t payload;
59} android_log_event_int_t;
60
61/* Event payload EVENT_TYPE_LONG */
62typedef struct __attribute__((__packed__)) {
63 int8_t type; // EVENT_TYPE_LONG
64 int64_t data; // Little Endian Order
65} android_event_long_t;
66
67/* Event with single EVENT_TYPE_LONG */
68typedef struct __attribute__((__packed__)) {
69 android_event_header_t header;
70 android_event_long_t payload;
71} android_log_event_long_t;
72
73/* Event payload EVENT_TYPE_STRING */
74typedef struct __attribute__((__packed__)) {
75 int8_t type; // EVENT_TYPE_STRING;
76 int32_t length; // Little Endian Order
77 char data[];
78} android_event_string_t;
79
80/* Event with single EVENT_TYPE_STRING */
81typedef struct __attribute__((__packed__)) {
82 android_event_header_t header;
83 android_event_string_t payload;
84} android_log_event_string_t;
85
44#endif 86#endif
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 7ba4c8e78..8093a4c26 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -416,27 +416,6 @@ int android_log_processLogBuffer(struct logger_entry *buf,
416} 416}
417 417
418/* 418/*
419 * Extract a 4-byte value from a byte stream.
420 */
421static inline uint32_t get4LE(const uint8_t* src)
422{
423 return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
424}
425
426/*
427 * Extract an 8-byte value from a byte stream.
428 */
429static inline uint64_t get8LE(const uint8_t* src)
430{
431 uint32_t low, high;
432
433 low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
434 high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
435 return ((long long) high << 32) | (long long) low;
436}
437
438
439/*
440 * Recursively convert binary log data to printable form. 419 * Recursively convert binary log data to printable form.
441 * 420 *
442 * This needs to be recursive because you can have lists of lists. 421 * This needs to be recursive because you can have lists of lists.
@@ -473,7 +452,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData,
473 452
474 if (eventDataLen < 4) 453 if (eventDataLen < 4)
475 return -1; 454 return -1;
476 ival = get4LE(eventData); 455 ival = le32toh(*((int32_t *)eventData));
477 eventData += 4; 456 eventData += 4;
478 eventDataLen -= 4; 457 eventDataLen -= 4;
479 458
@@ -494,7 +473,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData,
494 473
495 if (eventDataLen < 8) 474 if (eventDataLen < 8)
496 return -1; 475 return -1;
497 lval = get8LE(eventData); 476 lval = le64toh(*((int64_t *)eventData));
498 eventData += 8; 477 eventData += 8;
499 eventDataLen -= 8; 478 eventDataLen -= 8;
500 479
@@ -515,7 +494,7 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData,
515 494
516 if (eventDataLen < 4) 495 if (eventDataLen < 4)
517 return -1; 496 return -1;
518 strLen = get4LE(eventData); 497 strLen = le32toh(*((int32_t *)eventData));
519 eventData += 4; 498 eventData += 4;
520 eventDataLen -= 4; 499 eventDataLen -= 4;
521 500
@@ -630,7 +609,7 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf,
630 inCount = buf->len; 609 inCount = buf->len;
631 if (inCount < 4) 610 if (inCount < 4)
632 return -1; 611 return -1;
633 tagIndex = get4LE(eventData); 612 tagIndex = le32toh(*((int32_t *)eventData));
634 eventData += 4; 613 eventData += 4;
635 inCount -= 4; 614 inCount -= 4;
636 615