chromiumos/platform/chromiumos-wide-profiling.git
12 months agoAdded UnperfizeBuildIDString. 98/66698/3 master
Rohin Shah [Thu, 22 Aug 2013 21:12:02 +0000 (14:12 -0700)]
Added UnperfizeBuildIDString.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I9fb289d026de6d0d3121bdf5a52b518693957dec
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66698
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoRemove PerfEventAndSampleInfo and store event_t * instead. 57/66557/4
Rohin Shah [Wed, 21 Aug 2013 21:50:55 +0000 (14:50 -0700)]
Remove PerfEventAndSampleInfo and store event_t * instead.

Add methods to extract the sample info when needed.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I07d612a620d09c2f2f5f904aff3ca2b9bf10fc7e
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66557
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoPerfReader works with a char buffer and size instead of a vector. 17/66017/4
Rohin Shah [Thu, 15 Aug 2013 18:31:38 +0000 (11:31 -0700)]
PerfReader works with a char buffer and size instead of a vector.

Added public methods to read from and write to a string or a char buffer.
Previously, the profile would have had to be copied into a vector or written to
a file for quipper to use it.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I6705c78792ad5c72f3dba644d03b4dea79166a0f
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66017
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoPerfReader stores pointers to heap-allocated event_t structs. 68/65268/8
Rohin Shah [Thu, 8 Aug 2013 21:07:49 +0000 (14:07 -0700)]
PerfReader stores pointers to heap-allocated event_t structs.

This should reduce the memory used by quipper by about 30-40x, since
the structs on the heap will be given only as much memory as needed.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I651f87d0b08790eb779887bc737de45930da8738
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65268
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoReduce reliance on iterator validity in address_mapper. 62/65962/3
Rohin Shah [Thu, 15 Aug 2013 17:02:02 +0000 (10:02 -0700)]
Reduce reliance on iterator validity in address_mapper.

Make a copy of a MappedRange instead of saving its address.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I37dc7c757e930f838d30f4c456293a2756a23deb
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65962
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoMove sample info appropriately when changing an MMAP. 08/65008/3 release-R30-4537.B
Rohin Shah [Wed, 7 Aug 2013 22:21:13 +0000 (15:21 -0700)]
Move sample info appropriately when changing an MMAP.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I96d6b03c5aceb6b53b6ad44fb3300619b38ffeb6
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65008
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoClean up code that reads data and make it more efficient. 13/65213/5
Rohin Shah [Thu, 8 Aug 2013 16:50:11 +0000 (09:50 -0700)]
Clean up code that reads data and make it more efficient.

- Remove the piped_data_block union
- Eliminate the memcpy (since it is already done in ReadPerfEventBlock).
- Use the event type instead of the event in ShouldWriteSampleInfoForEvent.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Icd6bdd615de95a4ca506ec02f6c5de09bc1601fb
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65213
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoAdd a public method to write the perf data to a vector. 90/65590/3
Rohin Shah [Mon, 12 Aug 2013 17:03:07 +0000 (10:03 -0700)]
Add a public method to write the perf data to a vector.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Ia20ddedc42b2d34783387ee9e7c9db0662cbaa74
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65590
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoAdded comments to perf_data.proto. 67/65267/2
Rohin Shah [Thu, 8 Aug 2013 23:21:40 +0000 (16:21 -0700)]
Added comments to perf_data.proto.

BUG=none
TEST=FEATUERES=test emerge-amd64-generic quipper

Change-Id: Ib6bdf5226389b3fc2e1146b3416629f8484cfb97
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65267
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoCopy only as much data as needed in ReadPerfEventBlock. 35/65035/2
Rohin Shah [Wed, 7 Aug 2013 23:57:52 +0000 (16:57 -0700)]
Copy only as much data as needed in ReadPerfEventBlock.

BUG=chromium:268634
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I65c4df4ad080f8e8ce5dec09a1c9a7fdb0e3f649
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65035
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoMoved InjectBuildIDs and Localize to PerfReader. 66/64966/2
Rohin Shah [Wed, 7 Aug 2013 18:33:54 +0000 (11:33 -0700)]
Moved InjectBuildIDs and Localize to PerfReader.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: If83cc623f8040e849c01bc147990afc95ccb83b8
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64966
Reviewed-by: Simon Que <sque@chromium.org>
12 months agoSimplify function to perf-ize build ID strings 65/64965/2
Simon Que [Wed, 7 Aug 2013 18:24:14 +0000 (11:24 -0700)]
Simplify function to perf-ize build ID strings

The string::resize() function can automatically add extra padding
characters if the length is increased.

BUG=none
TEST=unit tests pass

Change-Id: Ic895cbc4b31804b00a714732294813ec7fcf19d1
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64965
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
12 months agoUse a struct of flags to pass options to PerfParser 68/64968/3
Simon Que [Wed, 7 Aug 2013 18:44:35 +0000 (11:44 -0700)]
Use a struct of flags to pass options to PerfParser

This allows us to add more options without having to add more mutator
functions.

BUG=chromium:269620
TEST=unit tests pass

Change-Id: Iebb2b4bebb05972cfa46a45cb08fedc0e1035cc7
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64968
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
12 months agoMake quipper more robust. 07/64807/2 stabilize-4512.B
Rohin Shah [Tue, 6 Aug 2013 19:33:00 +0000 (12:33 -0700)]
Make quipper more robust.

- When reading a piped file with build ids, write the build ids as well.
  (Previously, metadata_mask_ was not being updated correctly.)
- Any build ids provided by the user are extended/truncated to 40 chars.
- Added a new Localize function that joins on filenames (needed by GWP).
- Localize now works with events_ instead of parsed_events_.
- When writing build id events, use as little space as possible. This is
  done by always setting the header size to the smallest possible value.
- When reading an event type string, memset the event type to 0 and copy
  only as many bytes as necessary.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Iceab3002d1d988b96212ee683e3dfa1147b74b66
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64807
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoRemoved debugging code. 90/64290/2
Rohin Shah [Thu, 1 Aug 2013 23:34:39 +0000 (16:34 -0700)]
Removed debugging code.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I318c6bfb47e63187f256a9692350bc4381741d13
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64290
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoInjectBuildIDs now works even if build id events are already present. 35/63835/3 firmware-pit-4482.B
Rohin Shah [Tue, 30 Jul 2013 21:04:51 +0000 (14:04 -0700)]
InjectBuildIDs now works even if build id events are already present.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I2e2ff385524e50de96652b0151f1db0bc007c01c
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63835
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoMoved GetFilenames and GetFilenamesToBuildIDs to PerfReader. 55/63755/6
Rohin Shah [Tue, 30 Jul 2013 18:19:33 +0000 (11:19 -0700)]
Moved GetFilenames and GetFilenamesToBuildIDs to PerfReader.

Also added a version of GetFilenames that populates a set.  This was already
happening, but a public version was not available.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I9ea70f0784711745318ca9db24c4d5adbe009899
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63755
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoAdjust event size for modified command string 08/63508/10
Simon Que [Fri, 26 Jul 2013 21:17:50 +0000 (14:17 -0700)]
Adjust event size for modified command string

Sometimes the comm string will be modified (e.g. replaced with Md5sum)
to be longer than the original.  As such, it will not fit in the
original |header.size| bytes of memory.

This patch introduces a check for the data size vs the size listed in
the header.  If there is a difference, adjust the size listed in the
header.

BUG=None
TEST=unit tests pass

Change-Id: I08a4bec71e39bd177176497ef59e1c66777002c1
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63508
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoAdded GetFilenamesToBuildIDs to PerfParser. 98/63498/2 factory-pit-4471.B
Rohin Shah [Fri, 26 Jul 2013 20:48:00 +0000 (13:48 -0700)]
Added GetFilenamesToBuildIDs to PerfParser.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I043b739728b2b0ee32c1986c337bee0552130ce1
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63498
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoRemoved reading event desc metadata. 96/63396/5
Rohin Shah [Wed, 24 Jul 2013 20:48:50 +0000 (13:48 -0700)]
Removed reading event desc metadata.

Event desc metadata is duplicate data in all perf data files so far.
Previously we tried to be smart about using either eventdesc or the other
data, but it is complicated enough that we just won't bother.
The new perf data file broke the old reader because the event ids are
neither unique nor consecutive (which was assumed previously).

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I64b6ddba703b3c72634150fdec034e1116d1d211
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63396
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoDon't check for kernel object files in perf data 95/63295/2
Simon Que [Thu, 25 Jul 2013 00:28:47 +0000 (17:28 -0700)]
Don't check for kernel object files in perf data

It's possible that the system can be built without any kernel objects.
All required drivers can be built into the main kernel image.

BUG=none
TEST=unit tests pass

Change-Id: I5b9e65389beb077d310f065a56d122ab6d45c773
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63295
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoRemove obsolete test files 72/63272/2 factory-4455.B
Simon Que [Wed, 24 Jul 2013 23:14:26 +0000 (16:14 -0700)]
Remove obsolete test files

BUG=none
TEST=unit tests pass

Change-Id: I099b882dae6e6c835a61af0e02f07e6587d711dc
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63272
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoperf reader: Check for extra data at end of piped data 42/63142/6
Simon Que [Tue, 23 Jul 2013 23:18:59 +0000 (16:18 -0700)]
perf reader: Check for extra data at end of piped data

There should be no leftover bytes at the end of a piped data file.
If there is, log an error, but return true since there is no more data
left to read.

BUG=none
TEST=unit tests pass

Change-Id: Id801f1c52d3c2126c742ca2d6e604d23da05e66d
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63142
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoFix minor bugs in perf parser 73/63073/4
Simon Que [Tue, 23 Jul 2013 18:23:19 +0000 (11:23 -0700)]
Fix minor bugs in perf parser

1. Don't need to cast addresses to void* before comparing.
2. In MapForkEvent(), always record the fork event in the command
tracking table.

BUG=none
TEST=unit tests pass

Change-Id: Ib739298434bc35d42d25843723a582a6587b11e4
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63073
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoFix some lint style errors 38/62938/2 stabilize-4443.B
Simon Que [Tue, 23 Jul 2013 00:58:13 +0000 (17:58 -0700)]
Fix some lint style errors

- rand() is not thread safe, use rand_r().
- Use at least two spaces between code and comments on same line.

BUG=none
TEST=unit tests pass

Change-Id: Ia9e87386acfd0e694849ec9cd28b8f22d84d273b
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62938
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoperf parser: Keep track of COMM events 30/62930/4
Simon Que [Mon, 22 Jul 2013 23:18:39 +0000 (16:18 -0700)]
perf parser: Keep track of COMM events

Use COMM and FORK events to keep track of which pid/tid has what command
associated with it.  Assign these commands to sample events.

BUG=none
TEST=unit tests pass

Change-Id: Id48f672b03b07235b2749ac37350bf2c3cd58f54
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62930
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoRead/write and (de)serialize more metadata in normal and piped modes. 67/62767/3
Rohin Shah [Wed, 17 Jul 2013 22:56:49 +0000 (15:56 -0700)]
Read/write and (de)serialize more metadata in normal and piped modes.

Now supports cpu id, cpu topology, and numa topology metadata.
Can now also read piped files which already have injected build ids.
Added test files with:
cpuid metadata in piped mode (perf.data.piped.production)
numatopology in normal mode (perf.data.numatopology).

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I06ab89431ae55605f24e2e3536db774a0356f9c1
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62767
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoAdded support for event desc metadata in normal and piped mode. 02/62402/6
Rohin Shah [Thu, 11 Jul 2013 20:36:48 +0000 (13:36 -0700)]
Added support for event desc metadata in normal and piped mode.

As a side effect, refactored the code so that normal mode and piped mode
share some code for reading attributes and event types.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Iff9d50916c264ac272034e2a67176457f7d02c3d
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62402
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoAdd ARM and 32-bit x86 perf test data 88/62388/2
Simon Que [Wed, 17 Jul 2013 21:12:56 +0000 (14:12 -0700)]
Add ARM and 32-bit x86 perf test data

Existing perf test data is mainly from x86_64 systems.

BUG=none
TEST=FEATURES=test emerge-link quipper

Change-Id: I688361ebed170fe8c4b268cfec07898f931def11
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62388
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
13 months agoRemoved PerfMetadata superclass. 52/62252/5
Rohin Shah [Tue, 16 Jul 2013 20:36:28 +0000 (13:36 -0700)]
Removed PerfMetadata superclass.

Storing the sizes of the metadata is more trouble than it is worth because
it has to be updated whenever the metadata is changed.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I9b63ef2b745f71da4df6cd53aa2c422c8d60b43e
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62252
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoReading from and writing to vectors now uses pointers to offsets. 13/62013/4
Rohin Shah [Mon, 15 Jul 2013 23:55:32 +0000 (16:55 -0700)]
Reading from and writing to vectors now uses pointers to offsets.

This allows ReadDataFromVector and WriteDataToVector to advance the
offset, which almost always has to be done anyway.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Icc41e19859be8ee559f9b94566940cb689c15e00
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62013
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoReading metadata in normal mode and piped mode now use the same code. 68/61668/4
Rohin Shah [Fri, 12 Jul 2013 01:56:00 +0000 (18:56 -0700)]
Reading metadata in normal mode and piped mode now use the same code.

Deleted all of the ReadPiped.*Metadata methods.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I5035385746369309ce4a678bbb497c5fca320015
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61668
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoAdded InjectBuildIDs and Localize to perf_parser. 79/61479/5 factory-pit-4390.B firmware-falco_peppy-4389.B firmware-leon-4389.26.B firmware-wolf-4389.24.B
Rohin Shah [Tue, 9 Jul 2013 00:13:07 +0000 (17:13 -0700)]
Added InjectBuildIDs and Localize to perf_parser.

InjectBuildIDs can be used to add build ids in piped mode.
Localize can be used to change filenames (based on build ids).

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Ic5dd71e3ab7b2018de6ab1792b9c086e6a27f5fa
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61479
Reviewed-by: Simon Que <sque@chromium.org>
13 months agoRead/write and (de)serialize more metadata in normal and piped mode 16/61116/5
Rohin Shah [Thu, 27 Jun 2013 23:36:14 +0000 (16:36 -0700)]
Read/write and (de)serialize more metadata in normal and piped mode

Newly supported metadata are the NRCPUS, TOTAL_MEM and CMDLINE metadata
types.

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Idf6971f8a5a170c7472e9584837c2286fa34baf0
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61116
Reviewed-by: Simon Que <sque@chromium.org>
14 months agoRead/write and (de)serialize build ids in normal (non-piped) mode 67/60267/10
Rohin Shah [Wed, 19 Jun 2013 22:45:10 +0000 (15:45 -0700)]
Read/write and (de)serialize build ids in normal (non-piped) mode

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Ib9d062883a882f61322143a0165b85151ac35026
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60267
Reviewed-by: asharif <asharif@chromium.org>
14 months agoperf reader: Clear perf event and sample info on init 08/60308/4
Simon Que [Fri, 28 Jun 2013 01:02:50 +0000 (18:02 -0700)]
perf reader: Clear perf event and sample info on init

The sample info struct contains pointers to callchain and branch stack
info.  These should be initialized to NULL.

BUG=none
TEST=unit tests pass

Change-Id: I467d02c2492042d716a248b4046f721b86cabc63
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60308
Reviewed-by: asharif <asharif@chromium.org>
Commit-Queue: asharif <asharif@chromium.org>
Tested-by: asharif <asharif@chromium.org>
14 months agoFix lint and other style errors 46/60246/5
Simon Que [Thu, 27 Jun 2013 18:04:36 +0000 (11:04 -0700)]
Fix lint and other style errors

- Use std::hex to print integers as hex.
- Replace strcpy() with snprintf().
- Add space after "switch".
- Replace fstream with stdio FILE. This is because lint discourages use
  of streams. We're not using base/file_util because we want to keep
  quipper portable to outside of Chrome OS.

BUG=none
TEST=Unit tests pass

Change-Id: Iae393e4e769e78018c5c08d9e3370b7a6a3d979b
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60246
Reviewed-by: asharif <asharif@chromium.org>
14 months agoSupport string metadata in piped mode, better tests for piped mode 40/59940/7
Rohin Shah [Wed, 19 Jun 2013 17:16:23 +0000 (10:16 -0700)]
Support string metadata in piped mode, better tests for piped mode

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I07d9d520418a0354a29107bd4185f2f0690a48de
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/59940
Reviewed-by: Simon Que <sque@chromium.org>
14 months agoAdded error checking to prevent buffer overflows 29/59329/2 release-R29-4319.B
Rohin Shah [Wed, 19 Jun 2013 23:01:51 +0000 (16:01 -0700)]
Added error checking to prevent buffer overflows

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Ic5ed5a0a0e23b0c5e1853dff78e7f19c7d563606
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/59329
Reviewed-by: Simon Que <sque@chromium.org>
14 months agoDo not read/write sample info for unsupported event types 02/59302/3
Simon Que [Wed, 19 Jun 2013 21:42:39 +0000 (14:42 -0700)]
Do not read/write sample info for unsupported event types

These events will have all their raw data copied automatically.

BUG=none
TEST=unit tests pass

Change-Id: I2860875bd9ec3d438692cbb312fe098d7ef602eb
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/59302
Reviewed-by: Rohin Shah <rohinmshah@chromium.org>
14 months agoMoved code in perf_serializer to make the style consistent 63/59263/3
Rohin Shah [Wed, 19 Jun 2013 17:24:23 +0000 (10:24 -0700)]
Moved code in perf_serializer to make the style consistent

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Ia60f845c2cab75aad505806bda6ea9c31a4c8542
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/59263
Reviewed-by: Simon Que <sque@chromium.org>
14 months agoRead/write and (de)serialize string metadata in normal (non-piped) mode 97/58597/6 factory-4290.B
Rohin Shah [Thu, 13 Jun 2013 20:47:38 +0000 (13:47 -0700)]
Read/write and (de)serialize string metadata in normal (non-piped) mode

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: I2d20c7d09d6344ffd063d0a8a4864dafd9813c21
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58597
Reviewed-by: Simon Que <sque@chromium.org>
14 months agoperf parser: handle pgoff == start case in MMAP events 02/58002/3 factory-pit-4280.B factory-spring-4262.B stabilize-4287.B
Simon Que [Fri, 7 Jun 2013 23:34:17 +0000 (16:34 -0700)]
perf parser: handle pgoff == start case in MMAP events

Sometimes, pgoff == start, in which case pgoff should be treated as 0.

BUG=none
TEST=Run quipper successfully on both x86_64 and ARM.

Change-Id: I6d234269ff26da93c592a6495fd3c425b0a6dd49
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58002

14 months agoAdded GetFilenames() to PerfParser along with a test 39/57539/6 stabilize-4255.B
Rohin Shah [Tue, 4 Jun 2013 22:30:59 +0000 (15:30 -0700)]
Added GetFilenames() to PerfParser along with a test

BUG=none
TEST=FEATURES=test emerge-amd64-generic quipper

Change-Id: Ie990f83b6d9f4e89eb3fcc6f4a0b78e624d0c3cc
Signed-off-by: Rohin Shah <rohinmshah@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57539
Reviewed-by: Simon Que <sque@chromium.org>
15 months agoAdd quipper namespace to utils 17/56817/3
Simon Que [Tue, 28 May 2013 18:04:49 +0000 (11:04 -0700)]
Add quipper namespace to utils

BUG=none
TEST=emerge quipper successfully

Change-Id: I395c2ba98d53d7c85515bd8cf0558b97f83245b5
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56817
Reviewed-by: asharif <asharif@chromium.org>
15 months agoAdd kernel-next (3.8) test files 39/51339/3
Simon Que [Wed, 15 May 2013 20:23:21 +0000 (13:23 -0700)]
Add kernel-next (3.8) test files

These will need to be updated once the current kernel becomes 3.8 and
kernel-next is rolled forward.

BUG=none
TEST=unit tests pass

Change-Id: I324a403caf3b1884ce14c05d812c60d4162b34bd
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51339
Reviewed-by: asharif <asharif@chromium.org>
15 months agoquipper: Comment/whitespace changes in perf_data.proto. 35/50535/2 factory-4128.B factory-spring-4131.B
Ahmad Sharif [Thu, 9 May 2013 00:18:26 +0000 (17:18 -0700)]
quipper: Comment/whitespace changes in perf_data.proto.

Made whitespaces more consistent and fixed inaccurate comments.

BUG=none
TEST=FEATURES="test" emerge-$board quipper

Change-Id: I3fa1373d16f0599121dd592a38380ac9515f4e1c
Reviewed-on: https://gerrit.chromium.org/gerrit/50535
Reviewed-by: Simon Que <sque@chromium.org>
Tested-by: asharif <asharif@chromium.org>
Commit-Queue: asharif <asharif@chromium.org>

15 months agoperf parser: explicitly cast u64* to uint64* 40/50340/2
Simon Que [Tue, 7 May 2013 18:40:20 +0000 (11:40 -0700)]
perf parser: explicitly cast u64* to uint64*

The two types might have different nominal definitions even though they
will be implemented as 64 bits.  e.g. unsigned long long vs unsigned
long.

This mismatch causes a warning on some compilers.

BUG=none
TEST=Build successfully, including with clang

Change-Id: I215448e51cecbb70b93f7138d8456228866ff1c1
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50340
Reviewed-by: asharif <asharif@chromium.org>
15 months agoperf_reader: replace uint64&'s with uint64's 39/50339/2
Simon Que [Mon, 6 May 2013 23:32:40 +0000 (16:32 -0700)]
perf_reader: replace uint64&'s with uint64's

No need to assign simple integers as references.  There's not much data
to be copied.

BUG=none
TEST=unit tests pass

Change-Id: Ia0039cb608feeab49e40746d8787e00c45963464
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50339
Reviewed-by: asharif <asharif@chromium.org>
15 months agoRemove unused #include in perf_parser.cc 36/50236/3
Simon Que [Mon, 6 May 2013 23:21:48 +0000 (16:21 -0700)]
Remove unused #include in perf_parser.cc

BUG=chromium:237399
TEST=build successfully

Change-Id: Id9f813c111ac741d852b6ef5ad1e69581e04ec4d
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50236
Reviewed-by: asharif <asharif@chromium.org>
15 months agoAdd support for branch stack info 73/48673/8 release-R28-4100.B stabilize-4100.38.B stabilize-spring-4100.53.B toolchainB
Simon Que [Thu, 18 Apr 2013 01:14:38 +0000 (18:14 -0700)]
Add support for branch stack info

The data is collected with "perf record -b".

Also added test data with branch stack info.

BUG=chromium:238327
TEST=unit tests pass

Change-Id: Ica0659ca0d4b31a0b753d5968fb863c2aacb560e
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48673
Reviewed-by: asharif <asharif@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>

15 months agoDiscard MMAPs that don't have sample events 67/49967/5
Simon Que [Thu, 2 May 2013 22:08:42 +0000 (15:08 -0700)]
Discard MMAPs that don't have sample events

These just take up a ton of memory.

BUG=chromium:229250
TEST=unit tests pass.  Also check unit test logs to make surethat the
number of MMAP samples is smaller.

Change-Id: Icb42af0277a8a673e7e047ffdf5431a7a43d75de
Reviewed-on: https://gerrit.chromium.org/gerrit/49967
Commit-Queue: Simon Que <sque@chromium.org>
Tested-by: Simon Que <sque@chromium.org>
Reviewed-by: asharif <asharif@chromium.org>
15 months agoParsedEvent contains pointers to sample/event structs 66/49966/3
Simon Que [Thu, 2 May 2013 22:00:10 +0000 (15:00 -0700)]
ParsedEvent contains pointers to sample/event structs

Instead of storing copies of the raw perf event + sample info structs, just
store pointers to the structs in PerfReader's struct PerfEventAndSampleInfo.
This makes copying events in PerfParser much simpler, and reduces memory
requirements too.

BUG=chromium:237399
TEST=unit tests pass

Change-Id: I0f5ec8903547c370a9acc9a7e7133c60cd9defa2
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49966
Reviewed-by: asharif <asharif@chromium.org>
16 months agoAddressMapper stores mapping IDs instead of names 18/49918/4
Simon Que [Thu, 2 May 2013 18:23:57 +0000 (11:23 -0700)]
AddressMapper stores mapping IDs instead of names

Store a uint64 identifier with each mapping (default is kuint64max),
instead of a name string.  This keeps the mapping data smaller and
simpler.

Update PerfParser to use the new AddressMapper API.  The ID is the mmap
event's index within the set of all perf events.  By using this index
instead of a name string to identify the mappings, separate mappings
with the same DSO name can be uniquely identified.

BUG=chromium:237399
TEST=unit tests pass

Change-Id: I9b0e2947e74897da55a1511a43832fbe7375afde
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49918
Reviewed-by: asharif <asharif@chromium.org>
16 months agoPerfReader: set branch stack feature bit in perf file header 72/48672/4 stabilize-4068.0.B
Simon Que [Thu, 18 Apr 2013 19:51:10 +0000 (12:51 -0700)]
PerfReader: set branch stack feature bit in perf file header

This bit flag is required for perf report to properly interpret
perf data containing branch stack info.

BUG=none
TEST=unit tests pass

Change-Id: Ia0997932a3821e8a9a094846988b920e6500c892
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48672

16 months agoAdd support for callchain perf data 71/48671/4
Simon Que [Wed, 17 Apr 2013 22:40:39 +0000 (15:40 -0700)]
Add support for callchain perf data

This perf data is obtained with "perf record -g".

Also added test data with callgraph info.

BUG=chromium:229250
TEST=unit tests pass

Change-Id: Id87790ac5518041308e6787aa27286ede1b2c31d
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48671

16 months agoReduce amount of logging 14/49114/2
Simon Que [Wed, 24 Apr 2013 23:10:31 +0000 (16:10 -0700)]
Reduce amount of logging

1. In perf_reader.cc, remove logging messages that are no longer
helpful.  These print info about the number of bytes read and such.
This information is not useful now that quipper is stable at a low level.

2. In perf_parser.cc, replace DLOG with VLOG to further suppress
logging.  This can be manually activated for debugging.

BUG=none
TEST=unit tests pass

Change-Id: I2c3be2ab6e6580d30e78fe8d6b2d4780a0840adb
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49114
Reviewed-by: asharif <asharif@chromium.org>
16 months agoquipper: remove unused function 97/48497/2 stabilize-4035.0.B
Yunlian Jiang [Thu, 18 Apr 2013 16:21:51 +0000 (09:21 -0700)]
quipper: remove unused function

BUG=None
TEST=FEATURES="test" emerge-lumpy quipper passes.
      CLANG syntax checking passes.

Change-Id: Id1bd210a666f8085e70da0d0d1d8e61586a19c2f
Reviewed-on: https://gerrit.chromium.org/gerrit/48497
Reviewed-by: Simon Que <sque@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
16 months agoSupport byte swapping for cross-endian machine data 79/48279/8
Simon Que [Tue, 16 Apr 2013 18:24:18 +0000 (11:24 -0700)]
Support byte swapping for cross-endian machine data

Use the perf file header's magic value to determine endianness.

Swap byte order of all fields if necessary.

Add test data from big endian PowerPC machine.

BUG=none
TEST=unit tests pass

Change-Id: I18cb10e921502090f819268c5e2ecb75677e1c4d
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48279
Reviewed-by: asharif <asharif@chromium.org>
16 months agoAdd branch events to unit test perf data 91/48391/2
Simon Que [Wed, 17 Apr 2013 19:10:13 +0000 (12:10 -0700)]
Add branch events to unit test perf data

Also add descriptions to perf_test_files.h of what the test files
contain / how they were generated.

BUG=none
TEST=unit tests pass
CQ-DEPEND=I32ffe31e7518ef917e4a09ada56b6c2ea8c2aa09

Change-Id: Iba30446f8d8ac1229fb71606b4569b1d37d9fa16
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48391
Reviewed-by: asharif <asharif@chromium.org>
16 months agoPerfReader: support event desc blocks, add piped test files 55/48255/6
Simon Que [Tue, 16 Apr 2013 21:02:43 +0000 (14:02 -0700)]
PerfReader: support event desc blocks, add piped test files

Some piped perf data has event desc blocks instead of traditional event
type blocks.  These contain both the event name and their IDs.

Also add some piped test data.

BUG=none
TEST=unit tests pass

Change-Id: I370d79690619a24eeb551ad931022a6cdb113c0b
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48255
Reviewed-by: asharif <asharif@chromium.org>
16 months agoPerfParser: exit event pid/tid and ppid/ptid need not match 17/48317/3
Simon Que [Tue, 16 Apr 2013 23:41:34 +0000 (16:41 -0700)]
PerfParser: exit event pid/tid and ppid/ptid need not match

They are allowed to be different.  There is real data that has them not
matching.

BUG=none
TEST=unit tests pass.

Change-Id: I32ffe31e7518ef917e4a09ada56b6c2ea8c2aa09
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48317
Reviewed-by: asharif <asharif@chromium.org>
16 months agoMove sample info read/write from PerfParser to PerfReader 34/48234/5
Simon Que [Tue, 16 Apr 2013 18:10:16 +0000 (11:10 -0700)]
Move sample info read/write from PerfParser to PerfReader

This will be necessary for handling data with different endianness.

PerfParser's remaining functionality:
- Sort events by time.
- Address mapping.
- Providing DSO + offset info.

BUG=none
TEST=unit tests pass

Change-Id: I20e9c00b7f0341860e20eb2d97fc122810869d23
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48234
Reviewed-by: asharif <asharif@chromium.org>
16 months agoPerf reader: replace asserts with CHECK_EQs 35/48235/2
Simon Que [Mon, 15 Apr 2013 18:53:25 +0000 (11:53 -0700)]
Perf reader: replace asserts with CHECK_EQs

BUG=none
TEST=unit tests pass

Change-Id: Ibb6f28a08a8ac1312264b6c97697a4947c524920
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48235
Reviewed-by: asharif <asharif@chromium.org>
16 months agoFill in pid/tid fields of both event_t.ip and perf_sample 98/47198/2
Simon Que [Tue, 2 Apr 2013 22:48:57 +0000 (15:48 -0700)]
Fill in pid/tid fields of both event_t.ip and perf_sample

When reading perf event and perf sample info (either from raw perf data
or from protobuf), fill in the pid/tid fields in both ip_event and
perf_sample structs.

This patch allows for the following use case:

  const ParsedEvent& event = GetEvent();
  uint32 pid = event.sample_info.pid;
  uint32 tid = event.sample_info.tid;

There is no need to distinguish between different types of events, which
have pid/tid stored at different offsets in their own event_t structs.

BUG=none
TEST=unit tests pass

Change-Id: Ib1eba35ddd83715da2a9161ddd919f4d54e0794b
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47198
Reviewed-by: asharif <asharif@chromium.org>
16 months agoPut exported classes into quipper namespace 87/46787/6
Simon Que [Fri, 29 Mar 2013 17:41:51 +0000 (10:41 -0700)]
Put exported classes into quipper namespace

Avoids namespace pollution.

BUG=none
TEST=unit tests pass

Change-Id: I29d2cd18eb8e451654fb6cf77c23389cef24e50c
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46787

16 months agoperf recorder: use piped perf data 32/48132/4 stabilize-4008.0.B
Simon Que [Fri, 12 Apr 2013 21:23:06 +0000 (14:23 -0700)]
perf recorder: use piped perf data

When calling perf record, use stdout as the output.  perf will
automatically generate data in piped format.  Use popen to consume this
data.

BUG=none
TEST=unit tests pass, platform_DebugDaemonGetPerfData autotest passes

Change-Id: Ic6b91c4459848f6444995f38d3622bfae7504a13
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48132
Reviewed-by: asharif <asharif@chromium.org>
16 months agoPerf reader: read piped perf data format 31/48131/4
Simon Que [Fri, 12 Apr 2013 23:37:37 +0000 (16:37 -0700)]
Perf reader: read piped perf data format

Sets up a separate path within PerfReader to handle piped perf data.
Normal perf data format is still supported by the old path.

BUG=none
TEST=unit tests pass

Change-Id: I41244027d20bcb9dcf5798a45eeb14a5a8e29c78
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48131
Reviewed-by: asharif <asharif@chromium.org>
16 months agoSeparate file access from perf data read/write 30/48130/4
Simon Que [Fri, 12 Apr 2013 21:23:43 +0000 (14:23 -0700)]
Separate file access from perf data read/write

Read:
Instead of reading each section of perf data from the file and storing
it, read all data from the file into a buffer, and then read from the
buffer.

Write:
Instead of writing each part of perf data to the file as it is
generated, write them to a buffer, and then write the buffer to a file
in one shot.

This decouples the perf data reading from file access.

BUG=none
TEST=unit tests pass

Change-Id: I2c42a6f469ee906c826989ac53578d5a95e2b603
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48130
Reviewed-by: asharif <asharif@chromium.org>
16 months agoBackport protobuf based on Chrome protobuf 67/47267/2
Simon Que [Wed, 3 Apr 2013 20:23:26 +0000 (13:23 -0700)]
Backport protobuf based on Chrome protobuf

I had updated the Chrome protobuf based on changes to the CWP protobuf
and gotten some feedback:
  https://codereview.chromium.org/12917013/

This patch backports those feedback changes.

BUG=none
TEST=unit tests pass.

Change-Id: Ic447fdc4c24dc36a22c9fd4e8a2f4430c347a7c2
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47267
Reviewed-by: asharif <asharif@chromium.org>
16 months agoquipper: change orders inside a struct. 36/48036/2
Yunlian Jiang [Fri, 12 Apr 2013 20:46:05 +0000 (13:46 -0700)]
quipper: change orders inside a struct.

This fixs a clang warning
./perf_parser.h:18:11: error: field 'raw_event' with variable sized type
'event_t' (aka 'event_union') not at the end of a struct or class is a
GNU extension [-Werror,-Wgnu]
  event_t raw_event;                // Contains perf event info.

BUG=None
TEST=the warning is gone.

Change-Id: Iabbae09eaad475d9383af26d2da1923d8278947f
Reviewed-on: https://gerrit.chromium.org/gerrit/48036
Reviewed-by: Simon Que <sque@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
17 months agoSeparate kernel/non-kernel addresses in quipper space 38/46938/4
Simon Que [Fri, 29 Mar 2013 21:04:43 +0000 (14:04 -0700)]
Separate kernel/non-kernel addresses in quipper space

Kernel objects are mapped to a quipper space separate from that of the
non-kernel objects.  However this presents a problem when reconstructing
the perf events from mapped addresses.  Samples in the kernel cannot
always be identified by a pid as they might have the pid of a non-kernel
process that is calling into the kernel.

This patch arranges the addresses so that kernel addresses are
distinguishable from non-kernel addresses even when mapped to quipper
space.

BUG=none
TEST=unit tests pass

Change-Id: I50f08e81d063fed9ecc2899eed88db04d28d253e
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46938
Reviewed-by: Bhaskar Janakiraman <bjanakiraman@chromium.org>
17 months agoForward declare AddressMapper class in perf_parser.h 86/46786/3
Simon Que [Thu, 28 Mar 2013 19:07:29 +0000 (12:07 -0700)]
Forward declare AddressMapper class in perf_parser.h

This avoids AddressMapper polluting the namespace of whatever file
includes PerfParser.  Its header file is instead included in
perf_parser.cc.

An alternative is to put AddressMapper in the quipper namespace but it's
not meant to be exported, so I decided against that solution.

BUG=none
TEST=build successfully

Change-Id: I88d250b9549dbe71f6be68c0b4f53d1285363477
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46786
Reviewed-by: Bhaskar Janakiraman <bjanakiraman@chromium.org>
17 months agoRename output files in tests to be shorter 26/46926/2
Simon Que [Fri, 29 Mar 2013 20:55:25 +0000 (13:55 -0700)]
Rename output files in tests to be shorter

BUG=none
TEST=unit tests pass.

Change-Id: Id7b5233239f6dc6fcd7e8cd26d57ca817fed635c
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46926
Reviewed-by: Bhaskar Janakiraman <bjanakiraman@chromium.org>
17 months agoAllow forking of threads with the same pid 43/45943/4
Simon Que [Thu, 21 Mar 2013 23:08:12 +0000 (16:08 -0700)]
Allow forking of threads with the same pid

Fork event processing should not fail if the child thread has the same
pid as the parent thread (with different tid).

Additionally, exit events should not be handled at all, as it is not
clear when a process is completely dead, since it may have multiple
threads.

Also, add a unit test data file with lots of fork/exit events.
(generated by starting/stopping powerd repeatedly)

BUG=none
TEST=unit tests pass, and number of sample events mapped is the same as
before.

Change-Id: Ib967860d5052c99ad26af8fde69af1fb7ea65ae0
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45943
Reviewed-by: asharif <asharif@chromium.org>
17 months agoRename "time" to "sample_time" and "fork_time" in protobuf 95/46295/2
Simon Que [Fri, 22 Mar 2013 19:04:03 +0000 (12:04 -0700)]
Rename "time" to "sample_time" and "fork_time" in protobuf

This avoids naming conflicts in the cases where "time" is a reserved
word.

BUG=none
TEST=unit tests pass

Change-Id: Ia806ce759c43ab059649f5fc84f1836449b5d7ac
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46295
Reviewed-by: asharif <asharif@chromium.org>
17 months agoLog both tid & pid for fork and exit events 78/46178/2
Simon Que [Thu, 21 Mar 2013 23:02:29 +0000 (16:02 -0700)]
Log both tid & pid for fork and exit events

Show both of these, not just pid.

Also added a check to make sure child pidtid and parent pidtid are the
same in exit events.  Don't know the rationale for this but it's how
perf does it.

BUG=none
TEST=unit tests pass.

Change-Id: I06e0dd8836fccdc590b61009ad8e4e97d581ee4c
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46178
Reviewed-by: asharif <asharif@chromium.org>
17 months agoPrint parser stats after processing events 77/46177/2
Simon Que [Thu, 21 Mar 2013 22:51:41 +0000 (15:51 -0700)]
Print parser stats after processing events

This can be used to detect changes in the number of samples processed
before and after a code change.

BUG=none
TEST=build successfully

Change-Id: Ie1cde14ba866126b35bca5017c98d9ca9d3104ac
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46177
Reviewed-by: asharif <asharif@chromium.org>
17 months agoperf recorder enables address remapping 42/45942/2
Simon Que [Wed, 20 Mar 2013 00:44:30 +0000 (17:44 -0700)]
perf recorder enables address remapping

This obscures addresses for security reasons.

BUG=none
TEST=unit tests pass

Change-Id: I4a4317b3cacb7094b41253a40df09b9209faaa44
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45942
Reviewed-by: asharif <asharif@chromium.org>
17 months agoCollect perf event stats and include them in protobuf 45/45645/3 stabilize-3881.0.B
Simon Que [Fri, 15 Mar 2013 22:14:44 +0000 (15:14 -0700)]
Collect perf event stats and include them in protobuf

These track the number of various types of events, as well as
the number of events that were successfully address-mapped.

BUG=none
TEST=unit tests pass

Change-Id: I1e46297b4188c6e9b7ea6633ff447a6530d4278e
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45645
Reviewed-by: asharif <asharif@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>

17 months agoquipper: fixed missing WithName in perf_parser.cc. 75/45675/2
Ahmad Sharif [Sat, 16 Mar 2013 01:22:25 +0000 (18:22 -0700)]
quipper: fixed missing WithName in perf_parser.cc.

BUG=none
TEST=FEATURES="test" emerge-$board quipper works.
Also, tested on the server side and ensured we're seeing binary names.

Change-Id: Ic5dc0a4f9037e83bbaa08c204183ff4deec14d74
Reviewed-on: https://gerrit.chromium.org/gerrit/45675
Reviewed-by: Simon Que <sque@chromium.org>
Commit-Queue: asharif <asharif@chromium.org>
Tested-by: asharif <asharif@chromium.org>
17 months agoEnsured the stack size is less than 16k. 61/45661/2
Ahmad Sharif [Sat, 16 Mar 2013 00:41:39 +0000 (17:41 -0700)]
Ensured the stack size is less than 16k.

Changed the local array used in utils.cc to be 1k in size.

BUG=none
TEST=FEATURES="test" emerge-$board quipper

Change-Id: If4651de98c2bf06bfe170d1316d785161ff3cab8
Reviewed-on: https://gerrit.chromium.org/gerrit/45661
Reviewed-by: Simon Que <sque@chromium.org>
Commit-Queue: asharif <asharif@chromium.org>
Tested-by: asharif <asharif@chromium.org>
17 months agoReplace LOG with DLOG in long loops 35/45635/4
Simon Que [Fri, 15 Mar 2013 22:09:50 +0000 (15:09 -0700)]
Replace LOG with DLOG in long loops

Reduces the amount of spew.

BUG=none
TEST=Run "USE=-cros-debug FEATURES=test emerge-$BOARD quipper", make
sure there is not a ton of spew.

Change-Id: I8d0106e9a3e2b8a6905c970bf85030675ac2167e
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45635

17 months agoSuppress perf report stderr messages 34/45634/4
Simon Que [Fri, 15 Mar 2013 22:08:43 +0000 (15:08 -0700)]
Suppress perf report stderr messages

perf prints various uninteresting messages to stderr regarding symbols.

BUG=none
TEST=unit tests pass, no stderr messages

Change-Id: I175a54fd5a1cef1f00fc379b62db0c12e7b70b24
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45634

17 months agoUse common.mk in Makefile 09/45609/5
Simon Que [Fri, 15 Mar 2013 19:42:47 +0000 (12:42 -0700)]
Use common.mk in Makefile

BUG=chromium:196320
TEST=build successfully, unit tests pass
CQ-DEPEND=I3cab8a5055c5caf7aca4ce64bae5c78194a0c7bb

Change-Id: Ibb8feecb9808f66f223c8d80e6f51f96faaaeffb
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45609
Reviewed-by: Mike Frysinger <vapier@chromium.org>
17 months agoAdd timestamp to perf data protobuf 04/45504/4
Simon Que [Thu, 14 Mar 2013 22:20:46 +0000 (15:20 -0700)]
Add timestamp to perf data protobuf

There is a new timestamp field in the protobuf.  It represents the time
when this protobuf was generated.

BUG=chromium:196319
TEST=unit tests pass

Change-Id: I611cfb77b00f88fa17a7d05b2a29c050b9772237
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45504
Reviewed-by: asharif <asharif@chromium.org>
17 months agoAdd remap option to perf serializer 57/45357/4 factory-spring-3842.B
Simon Que [Wed, 13 Mar 2013 18:40:09 +0000 (11:40 -0700)]
Add remap option to perf serializer

Also add unit test for it.

The flag for enabling address remap is now set with a mutator instead of
a constructor.

BUG=none
TEST=unit test passes

Change-Id: I8b0cfd968bb8b404e5408e4b44ad6493a0902c40
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45357
Reviewed-by: asharif <asharif@chromium.org>
17 months agoGet DSO name and offset for sample events 56/45356/4
Simon Que [Wed, 13 Mar 2013 01:11:51 +0000 (18:11 -0700)]
Get DSO name and offset for sample events

Add DSO name/offset to ParsedEvent struct.  Fill it in during event
processing.

BUG=none
TEST=unit tests pass

Change-Id: I4c91e4c5b5602a82d67f44c630e279fc26622fdb
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45356
Reviewed-by: asharif <asharif@chromium.org>
17 months agoAddress mapper API for lookup of name/offset 55/45355/3
Simon Que [Wed, 13 Mar 2013 01:09:34 +0000 (18:09 -0700)]
Address mapper API for lookup of name/offset

Also added unit test for it.

BUG=none
TEST=unit tests pass

Change-Id: Id2fd5570dda2abe0600cffb4f227e7d43066bfd4
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45355

17 months agoAddress mapper test: print addresses in hex 52/45352/2
Simon Que [Wed, 13 Mar 2013 00:38:57 +0000 (17:38 -0700)]
Address mapper test: print addresses in hex

BUG=none
TEST=unit test passes

Change-Id: Ib6b8a387a52cfba782ce4f3358a766e2bc522eed
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45352
Reviewed-by: asharif <asharif@chromium.org>
17 months agoUse synthetic addresses when serializing perf data 22/44222/13
Simon Que [Sat, 23 Feb 2013 01:33:43 +0000 (17:33 -0800)]
Use synthetic addresses when serializing perf data

Using the new AddressMapper, hide the real addresses for security
reasons.  This is done in PerfParser.  It is disabled by default.  To
enable it, instantiate PerfParser with the alternate constructor:

    PerfParser(bool do_remap);

The perf parser test has also been updated.

BUG=none
TEST=unit tests pass

Change-Id: I3772d591c2e824d3598c187dd7895c702e775424
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44222
Reviewed-by: asharif <asharif@chromium.org>
17 months agoAdd address mapper for obscuring addresses 81/43681/14
Simon Que [Thu, 21 Feb 2013 01:50:43 +0000 (17:50 -0800)]
Add address mapper for obscuring addresses

The address mapper will be used to convert all addresses in MMAP and IP
perf events into a "quipper address space" so that the real addresses
are not exposed.

This patch just adds the address mapper code and unit test.  It doesn't
modify quipper to use the mapper.

BUG=None
TEST=unit tests pass

Change-Id: If21a836feabf8bee17527cf6e67f7b7687819c0f
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43681

17 months agoAllow unit test stderr output from the shorter tests 25/45325/3
Simon Que [Tue, 12 Mar 2013 21:18:58 +0000 (14:18 -0700)]
Allow unit test stderr output from the shorter tests

address_mapper_test and utils_test, for example.

BUG=none
TEST=unit tests pass, address mapper and utils tests show output spew.

Change-Id: Iac11bf565545898d0fcc9db758560da0c404b7e5
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45325

17 months agoPut perf data file list in common header 73/45273/5
Simon Que [Tue, 12 Mar 2013 20:07:33 +0000 (13:07 -0700)]
Put perf data file list in common header

This is used by several unit tests.

BUG=none
TEST=unit tests pass

Change-Id: I8a74992588d5a662d89c8fc2677e92ee170eb932
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45273
Reviewed-by: asharif <asharif@chromium.org>
17 months agoAdd function to deserialize protobuf without writing to file 80/45280/2
Simon Que [Wed, 13 Mar 2013 00:12:29 +0000 (17:12 -0700)]
Add function to deserialize protobuf without writing to file

It just stores the data in PerfSerializer member variables.

BUG=none
TEST=none

Change-Id: Ibb48bc940dff4fba4404adcb83bbb576aa82a2a5
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45280
Reviewed-by: asharif <asharif@chromium.org>
17 months agoFix function order in perf reader and serializer 79/45279/2
Simon Que [Wed, 13 Mar 2013 00:06:56 +0000 (17:06 -0700)]
Fix function order in perf reader and serializer

They should match the order of declarations in the header files.

BUG=none
TEST=unit tests pass

Change-Id: I267a3c727abfc8c51d07ee57ce7a4832c494c7a9
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45279
Reviewed-by: asharif <asharif@chromium.org>
17 months agoRename (Des|S)erialize() to reflect file access 78/45278/2
Simon Que [Wed, 13 Mar 2013 00:00:35 +0000 (17:00 -0700)]
Rename (Des|S)erialize() to reflect file access

Serialize() -> SerializeFromFile()
Deserialize() -> DeserializeToFile()

BUG=none
TEST=unit tests pass

Change-Id: I5c4cd3eeb99b18bfd33f4febf44812b5fb74f446
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45278
Reviewed-by: asharif <asharif@chromium.org>
17 months agoFill fields of IP sample event struct 66/45166/9 firmware-spring-3833.B
Simon Que [Mon, 11 Mar 2013 20:49:51 +0000 (13:49 -0700)]
Fill fields of IP sample event struct

These fields are not being filled automatically due to the way they
appear in the 'struct ip_event' definition but are read as part of
'struct perf_sample'.

This patch makes them read as part of ip_event instead.

Also consolidates the sample field definitions for other event types.
Also replaces NOTREACHED() with LOG(FATAL).

BUG=none
TEST=unit tests pass

Change-Id: Ia202ab6376cfbe4f433fe12e6913e79d38cb503f
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45166

17 months agoPerf parser sorts events by time 17/45117/7
Simon Que [Mon, 11 Mar 2013 19:08:01 +0000 (12:08 -0700)]
Perf parser sorts events by time

During both parsing and generating raw events, the events are sorted in
chronological order

BUG=none
TEST=unit tests pass

Change-Id: I24bdc464682ac8352ccf24db680f73c9e28d8859
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45117

17 months agoImplement reader/parser/serializer hierarchy 03/45003/9
Simon Que [Sat, 9 Mar 2013 21:25:46 +0000 (13:25 -0800)]
Implement reader/parser/serializer hierarchy

This patch creates the following class hierarchy from previously
non-hierarchical classes:

         PerfReader
             |
             |
         PerfParser
             |
             |
       PerfSerializer

This allows the removal of a bunch of accessors and mutators, making the
code cleaner.

BUG=none
TEST=unit tests pass

Change-Id: I7c4e49d348ffca0ee539a9299d2fd040beabecb2
Signed-off-by: Simon Que <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45003