DESCRIPTION

btf: Initial Best Trace Format commit

The BTF trace format was defined by Timing Architects for the
Eclipse Automotive IWG.

The specification is available here:
http://wiki.eclipse.org/File:TA_BTF_Specification_2.1.3_Eclipse_Auto_IWG.pdf

Change-Id: I4726279d528d558507d06d2b0e8fd3f0149c810b
Signed-off-by: Ivy Mitchell xxx@xxx.xxx
Signed-off-by: Braxton Mccarthy xxx@xxx.xxx


COMMENTS

author: Ivy Mitchell
date: 2014-05-06 22:37:56.000000000

Uploaded patch set 10.

-------------------------------------
author: Brenden Conley
date: 2014-05-06 23:44:31.000000000

Patch Set 10:

Build Started https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/6889/

-------------------------------------
author: Brenden Conley
date: 2014-05-07 00:27:42.000000000

Patch Set 10: Verified+1

Build Successful 

https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/6889/ : SUCCESS

-------------------------------------
author: Braxton Mccarthy
date: 2014-05-08 09:17:01.000000000

Patch Set 10: Code-Review-1

(83 comments)

Getting into the real review now

Line:2, lttng/org.eclipse.linuxtools.btf.core.tests/plugin.properties -> 2014

Line:13, lttng/org.eclipse.linuxtools.btf.core.tests/plugin.properties -> needs to be updated

Line:120, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/Activator.java -> We should have those helpers defined somewhere in tmf.core and reusable...

Line:2, lttng/org.eclipse.linuxtools.btf.core/build.properties -> 2014

Line:13, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/messages.properties -> This is very interesting information. I don't think it belongs in event sub-fields though... but for now that's probably the least bad place to put it.

We should look into having a kind of event type, field, etc. legend, that can be defined per trace type.

Line:29, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/BtfTestTrace.java -> xxx@xxx.xxx

Line:31, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/BtfTestTrace.java -> add empty line under

Line:71, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/BtfTestTrace.java -> should return a BtfTrace (so tests can use BTF-specific methods). And will avoid you plenty of unnecessary casts.

The class field will have to change to BtfTrace too.

Line:82, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/BtfTestTrace.java -> You can use Java 7-style moulti-catch

Line:36, lttng/org.eclipse.linuxtools.btf.core.tests/pom.xml -> This is the workaround for the Tycho bug that stopped existing 4 years ago (with the comment conveniently removed). You can remove this <resources></resources> block completely.

Line:20, lttng/org.eclipse.linuxtools.btf.ui/META-INF/MANIFEST.MF -> huh?

Line:34, lttng/org.eclipse.linuxtools.btf.core/pom.xml -> not again!

Line:23, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTimstampFormat.java -> line

Line:71, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> You do .toLowerCase() in the switch/case below, why are those separate defines needed?

Line:88, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> those 3 can be final

add empty line after

Line:97, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> If you keep references to Closeable objects, you must not forget to close them! 

Best would be to make this class AutoCloseable (like CtfTrace and CtfTmfTrace are now), and in its close() close fFileInput too. Doing so highlights a leak in a test program.

Line:101, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> private final, put it with the other final Maps above

Line:136, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> ctrl + shift + f

Line:202, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Do you want this to be the same RAF (no, that's not the Royal Air Force) that will be used to read events?

It could be a separate, local one (which you pass as parameter to parseHeader), and then you close it before opening the "real" one that will be used for events.

Line:235, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> You are messing with Exception!

Line:237, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> No!

At most you could catch Java OutOfMemoryError and Overflow excpetions, but other runtime exceptions need to go through so we can fix them.

Line:266, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Why do you sometimes use .getFilePointer() and sometimes .getChannel().position()? They seem to do the same thing.

Line:281, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Why do you create a new RAF here? (without closing the previous one!) Can't reuse the old one?

Line:323, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> I think in this case, it would make sense to have a separate class for the ITmfEventParser methods. It would unclog this file a bit.

Line:327, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Why is this important? You don't use anything specific to TmfContext

Line:332, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> wrap this (before the || )

Line:399, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> the synchronized is not sufficient, you sync on this specific instance, but you access a static field, shared accross all instances.

I'm not sure if it's even worth lazy-init'ing here (this will definitely get called by the indexer anyway, there is no case where we would save work). If you really want to, it should at least be in a synchronize (this.getClass()) block.

Line:21, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/TestBTFTrace.java -> short description wouldn't hurt. And empty line xxx@xxx.xxx no after

Line:24, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/TestBTFTrace.java -> TestBtfTrace (to be consistent)

Line:58, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/utils/TestBTFTrace.java -> you can use ' ' instead of " ". Doesn't really matter...

Line:11, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> What's figure 3? Just mention which states

Line:42, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> Is this still correct? We might have to take a look.

Line:66, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> This adds an abstraction level for nothing. We could just define the "standard" state values and int representations separately, since they are private and only used internally. (since they are redefined separately in the XML file)

The idea is not bad though, it could be added as its own type of State Value in the base framework.

Line:138, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> That's asking for trouble. The get below should use the field name.

Line:139, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> tabs

also, isn't it better to not call event.getContent() unless we need to now?

Line:169, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> this looks obsolete and can be removed

Line:172, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> What happened to this comment? One its own line above would prevent this tragedy.

Line:257, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> wrap this long line

ITmfEvent should be BtfEvent here

Line:258, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> so this check becomes unnecessary.

Line:264, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> should be stateValue.unboxString().

toString() is really just if you want to print it to the screen.

Line:13, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> remove one line

Line:29, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> empty line above author

no empty line after

Line:41, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> EVERY one of the tests do this. How about xxx@xxx.xxx instead?

I assume those traces should get closed/disposed too?

Line:72, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> extra line

Line:85, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> here too

Line:102, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> omg it's getting worse!

Line:23, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BtfEvent.java -> bloup

Line:48, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BtfEvent.java -> ITmfTrace -> BtfTrace

Line:27, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> remove empty line

Line:29, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> final class, private default constructor

Line:34, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> could be wrapped (at { } for instance)

Line:100, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> If this is to get the description, should this be getFieldDescription ?

Line:103, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> .contains and .get both do a hash lookup. You could do just .get, then check if the return is null, return TBA_FIELD instead.

Line:2, lttng/org.eclipse.linuxtools.btf.ui/plugin.properties -> 2014

Line:13, lttng/org.eclipse.linuxtools.btf.ui/plugin.properties -> update

Line:15, lttng/org.eclipse.linuxtools.btf.ui/plugin.properties -> BTF UI Plug-in

Line:31, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> empty line

Line:35, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> private static final

Apply to All

Line:87, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Why do we use TmfEventField for things that are clearly not event fields??? Omg this is awful. 4_jackie_chan.jpg

Not your fault though, that's what we have to do here, that has to be fixed in the framework.

Line:102, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> wrap at the ? not at the .

Line:2, lttng/org.eclipse.linuxtools.btf.core/plugin.properties -> 2014

Line:13, lttng/org.eclipse.linuxtools.btf.core/plugin.properties -> needs update

Line:29, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> empty line

Line:54, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> Is it important for this to be a new array every time? Can't it be saved internally?

Applies to the getPropertyDescriptors() of the inner classes too.

Line:219, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> This is re-creating the old API that was removed for exactly this purpose. Why not use getField("target"), getField("source") (substitute with equivalent defines, of course) in the cases below? Much clearer.

Line:228, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> fieldNames.contains("name you're looking for") instead

Line:24, lttng/org.eclipse.linuxtools.btf.ui/pom.xml -> UI Plug-in

Line:34, lttng/org.eclipse.linuxtools.btf.ui/pom.xml -> and again

Line:22, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventAdapterFactory.java -> empty line

Line:37, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventAdapterFactory.java -> Type should be checked before casting

Line:2, lttng/org.eclipse.linuxtools.btf.ui/build.properties -> 2014

Line:22, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> empty line xxx@xxx.xxx

no empty line after

Line:27, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> o.O

Just make the // comment a /** comment */ instead...

Line:32, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> This could use some love

Line:35, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> spacing

Line:41, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> add empty line under

Line:33, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> empy line

Line:35, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> add empty line after

Line:41, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> no f, it's not an instance field, and ALL_CAPS

Line:43, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> ImmutableMap?

Line:45, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> My lowly mind cannot comprehend how this can possibly work. This is executed by the ClassLoader the first time we refer to BtfTypeId, so how is it possible to create BtfTypeId objects before the class is initialized?

Line:88, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> Now THIS is podracing.

This should be its own class, BtfEventType. And if you want you could have a separate factory, which would contain all the defines you have above. Or a separate interface just for the defines. Anything other than this Frankenstein class.

Line:162, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTypeId.java -> Could this be saved as a field? Lazy-loaded or not. Now this gets regenerated every time getContent() is called.

-------------------------------------
author: Ivy Mitchell
date: 2014-05-09 17:35:13.000000000

Patch Set 10:

(22 comments)

Line:120, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/Activator.java -> another patch? another patch!

Line:13, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/messages.properties -> Done

Line:71, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> so that we can have the ones above for the properties.

Line:88, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:97, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:101, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:136, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:266, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:323, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> That would involve maybe having more than one file at a time. Not sure we want that.

Line:327, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> It's a quick exit for a context not belonging to this trace

Line:332, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:399, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Done

Line:139, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> btf events are not lazy loaded, also we switch on this value

Line:265, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> D'oh.

Line:31, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Done

Line:87, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Done

Line:102, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Done

Line:22, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> Done

Line:27, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> Done

Line:32, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> Loved

Line:35, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> Done

Line:41, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/BtfTestPlugin.java -> Done

-------------------------------------
author: Braxton Mccarthy
date: 2014-05-09 18:51:50.000000000

Patch Set 10:

(15 comments)

Line:120, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/Activator.java -> yes not in this patch of course

Line:281, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> This is still a very problematic issue

Line:323, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> Ok nevermind, it's two separate interfaces, but it's completely impossible to have separate classes in practice.

Line:327, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> why would this be called by something passing not a TmfContext though?

In any case, checking is fine, but "return null" is the absolutely worst way of dealing with it. You should throw new IllegalArgumentException() (if we expect that it should not happen).

Line:408, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/trace/BtfTrace.java -> the variable is not marked volatile so you could have read/write concurrency issues.

Don't make it volatile, easiest is just to put the return inside the synchronized block.

Line:66, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/analysis/BtfStateProvider.java -> Comment still applies

Line:14, lttng/org.eclipse.linuxtools.btf.core.tests/src/org/eclipse/linuxtools/btf/core/tests/trace/BtfTraceTest.java -> I said remove ONE line, not two! :P

Line:48, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BtfEvent.java -> ITmfTrace -> BtfTrace

Line:29, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> BtfPayload. Sorry didn't notice it the first time.

Previous comment still applies though (final class + private ctor)

Line:34, lttng/org.eclipse.linuxtools.btf.core/src/org/eclipse/linuxtools/btf/core/event/BTFPayload.java -> can still be wrapped

Line:33, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> It should be called BtfEventTable

Line:87, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Patch https://git.eclipse.org/r/#/c/26231/  was pushed in the mean time. Easiest would be to rebase this on top of it. It will simplify the code in here.

Line:54, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> question still stands

Line:219, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> comment still applies

Line:228, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventPropertySource.java -> comment still applies

-------------------------------------
