Skip to content

Commit

Permalink
Update flatbuffers
Browse files Browse the repository at this point in the history
  • Loading branch information
kornilova203 committed Apr 11, 2020
1 parent 1167ce6 commit 1b6cc90
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ visualization/node_modules/
/.idea/
generated-resources/
generated/
/flatbuffers/
22 changes: 3 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
language: java
sudo: required # to install flatbuffers
jdk:
- openjdk8

addons:
apt:
update: true
packages:
- git
- cmake
- make

before_install:
- chmod +x ./scripts/install-flatbuffers.sh
- ./scripts/install-flatbuffers.sh

jdk: oraclejdk8
install: true

script:
- ./gradlew prepareStaticAndAgent
- ./gradlew test -x :agent-test:test
- ./gradlew buildPlugin
- ./gradlew :visualization:copyStatic
- ./gradlew :intellij-plugin:test
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,16 @@ If only want to use plugin then you should simply install ready-to-use [jar](htt
./gradlew :intellij-plugin:runIdea
```

### Regenerate flatbuffers
[cflamegraph_schema.fbs] has to be regenerated after [flatbuffers compiler] and [flatbuffers runtime library] are updated.
```bash
chmod +x ./scripts/install-flatbuffers.sh
./scripts/install-flatbuffers.sh
./gradlew :core:compileFlatBuffers
```


[open an issue]: https://github.com/kornilova203/FlameViewer/issues
[cflamegraph_schema.fbs]: core/src/main/flatbuffers/cflamegraph_schema.fbs
[flatbuffers compiler]: scripts/install-flatbuffers.sh
[flatbuffers runtime library]: core/build.gradle
6 changes: 3 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import io.netifi.flatbuffers.plugin.tasks.FlatBuffers

plugins {
id "io.netifi.flatbuffers" version "1.0.4"
id "io.netifi.flatbuffers" version "1.0.6"
}

dependencies {
compile project(":proto")
compile group: 'com.github.davidmoten', name: 'flatbuffers-java', version: '1.10.0.2'
compile group: 'com.google.flatbuffers', name: 'flatbuffers-java', version: '1.12.0'
compile fileTree(dir: 'lib', include: ['com.jrockit.mc.flightrecorder_5.5.1.172852.jar'])
compile fileTree(dir: 'lib', include: ['com.jrockit.mc.common_5.5.1.172852.jar'])
compile fileTree(dir: 'lib', include: ['flight-recorder-parser-for-java-9.jar'])
Expand All @@ -16,7 +16,7 @@ dependencies {
}

flatbuffers {
flatcPath = '/usr/local/bin/flatc'
flatcPath = '../flatbuffers/target/flatc'
language = 'java'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,37 @@

@SuppressWarnings("unused")
public final class Names extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); }
public static Names getRootAsNames(ByteBuffer _bb) { return getRootAsNames(_bb, new Names()); }
public static Names getRootAsNames(ByteBuffer _bb, Names obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Names __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

public String classNames(int j) { int o = __offset(4); return o != 0 ? __string(__vector(o) + j * 4) : null; }
public int classNamesLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
public StringVector classNamesVector() { return classNamesVector(new StringVector()); }
public StringVector classNamesVector(StringVector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public String methodNames(int j) { int o = __offset(6); return o != 0 ? __string(__vector(o) + j * 4) : null; }
public int methodNamesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
public StringVector methodNamesVector() { return methodNamesVector(new StringVector()); }
public StringVector methodNamesVector(StringVector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
public String descriptions(int j) { int o = __offset(8); return o != 0 ? __string(__vector(o) + j * 4) : null; }
public int descriptionsLength() { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; }
public StringVector descriptionsVector() { return descriptionsVector(new StringVector()); }
public StringVector descriptionsVector(StringVector obj) { int o = __offset(8); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }

public static int createNames(FlatBufferBuilder builder,
int class_namesOffset,
int method_namesOffset,
int descriptionsOffset) {
builder.startObject(3);
builder.startTable(3);
Names.addDescriptions(builder, descriptionsOffset);
Names.addMethodNames(builder, method_namesOffset);
Names.addClassNames(builder, class_namesOffset);
return Names.endNames(builder);
}

public static void startNames(FlatBufferBuilder builder) { builder.startObject(3); }
public static void startNames(FlatBufferBuilder builder) { builder.startTable(3); }
public static void addClassNames(FlatBufferBuilder builder, int classNamesOffset) { builder.addOffset(0, classNamesOffset, 0); }
public static int createClassNamesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
public static void startClassNamesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
Expand All @@ -43,8 +50,15 @@ public static int createNames(FlatBufferBuilder builder,
public static int createDescriptionsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
public static void startDescriptionsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
public static int endNames(FlatBufferBuilder builder) {
int o = builder.endObject();
int o = builder.endTable();
return o;
}

public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }

public Names get(int j) { return get(new Names(), j); }
public Names get(Names obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@SuppressWarnings("unused")
public final class Node extends Struct {
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Node __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

public int classNameId() { return bb.getInt(bb_pos + 0); }
Expand All @@ -27,5 +27,12 @@ public static int createNode(FlatBufferBuilder builder, int classNameId, int met
builder.putInt(classNameId);
return builder.offset();
}

public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }

public Node get(int j) { return get(new Node(), j); }
public Node get(Node obj, int j) { return obj.__assign(__element(j), bb); }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,45 @@

@SuppressWarnings("unused")
public final class Tree extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); }
public static Tree getRootAsTree(ByteBuffer _bb) { return getRootAsTree(_bb, new Tree()); }
public static Tree getRootAsTree(ByteBuffer _bb, Tree obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Tree __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

public Names names() { return names(new Names()); }
public Names names(Names obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public Node nodes(int j) { return nodes(new Node(), j); }
public Node nodes(Node obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o) + j * 20, bb) : null; }
public com.github.kornilova203.flameviewer.cflamegraph.Names names() { return names(new com.github.kornilova203.flameviewer.cflamegraph.Names()); }
public com.github.kornilova203.flameviewer.cflamegraph.Names names(com.github.kornilova203.flameviewer.cflamegraph.Names obj) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
public com.github.kornilova203.flameviewer.cflamegraph.Node nodes(int j) { return nodes(new com.github.kornilova203.flameviewer.cflamegraph.Node(), j); }
public com.github.kornilova203.flameviewer.cflamegraph.Node nodes(com.github.kornilova203.flameviewer.cflamegraph.Node obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o) + j * 20, bb) : null; }
public int nodesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
public com.github.kornilova203.flameviewer.cflamegraph.Node.Vector nodesVector() { return nodesVector(new com.github.kornilova203.flameviewer.cflamegraph.Node.Vector()); }
public com.github.kornilova203.flameviewer.cflamegraph.Node.Vector nodesVector(com.github.kornilova203.flameviewer.cflamegraph.Node.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 20, bb) : null; }

public static int createTree(FlatBufferBuilder builder,
int namesOffset,
int nodesOffset) {
builder.startObject(2);
builder.startTable(2);
Tree.addNodes(builder, nodesOffset);
Tree.addNames(builder, namesOffset);
return Tree.endTree(builder);
}

public static void startTree(FlatBufferBuilder builder) { builder.startObject(2); }
public static void startTree(FlatBufferBuilder builder) { builder.startTable(2); }
public static void addNames(FlatBufferBuilder builder, int namesOffset) { builder.addOffset(0, namesOffset, 0); }
public static void addNodes(FlatBufferBuilder builder, int nodesOffset) { builder.addOffset(1, nodesOffset, 0); }
public static void startNodesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(20, numElems, 4); }
public static int endTree(FlatBufferBuilder builder) {
int o = builder.endObject();
int o = builder.endTable();
return o;
}
public static void finishTreeBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
public static void finishSizePrefixedTreeBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset); }

public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }

public Tree get(int j) { return get(new Tree(), j); }
public Tree get(Tree obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}

5 changes: 1 addition & 4 deletions scripts/install-flatbuffers.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!/usr/bin/env bash

mkdir dependencies
cd dependencies
git clone https://github.com/google/flatbuffers.git
cd flatbuffers
git checkout tags/v1.9.0
git checkout tags/v1.12.0
mkdir target
cd target
cmake .. -G "Unix Makefiles"
make
sudo mv flatc /usr/local/bin/

0 comments on commit 1b6cc90

Please sign in to comment.