Skip to content

Commit 9f7bb3c

Browse files
committed
Initial commit
0 parents  commit 9f7bb3c

File tree

10 files changed

+335
-0
lines changed

10 files changed

+335
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea
2+
/out
3+
/cmake-build-debug

CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.9)
2+
project(template_module)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
6+
add_executable(template_module
7+
src/module.cc
8+
src/module.h
9+
src/instrumentation_pass.cc
10+
src/instrumentation_pass.h
11+
src/codelib.cc
12+
src/codelib.h)
13+
14+
target_include_directories(template_module PUBLIC
15+
/opt/artist-sdk/include/external/valgrind
16+
/opt/artist-sdk/include/external/valgrind/include
17+
/opt/artist-sdk/include/bionic/libc/private
18+
/opt/artist-sdk/include/art/runtime
19+
/opt/artist-sdk/include/art/compiler
20+
/opt/artist-sdk/include/art/compiler/optimizing
21+
/opt/artist-sdk/include/libnativehelper/include/nativehelper
22+
/opt/artist-sdk/include/external/libcxx/include
23+
/opt/artist-sdk/include/bionic/libc/arch-arm/include
24+
/opt/artist-sdk/include/bionic/libc/include
25+
/opt/artist-sdk/include/bionic/libc/kernel/uapi
26+
/opt/artist-sdk/include/bionic/libc/kernel/uapi/asm-arm
27+
/opt/artist-sdk/include/bionic/libm/include)

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARTIST_SDK ?= /opt/artist-sdk
2+
3+
include $(ARTIST_SDK)/makefiles/core.mk

Manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"manifest_version": 1,
3+
"package_name": "com.example.module",
4+
"name": "Artist Module",
5+
"description": "This a template module.",
6+
"author": "John Doe <[email protected]>",
7+
"version": 1
8+
}

src/codelib.cc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* The ARTist Project (https://artist.cispa.saarland)
3+
*
4+
* Copyright (C) 2018 CISPA (https://cispa.saarland), Saarland University
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author "Parthipan Ramesh <[email protected]>"
19+
*
20+
*/
21+
22+
#include "codelib.h"
23+
24+
unordered_set<string> &ModuleCodeLib::getMethods() const {
25+
// TODO: implement methods like example below
26+
// static string instanceField = "Lsaarland/cispa/artist/codelib/CodeLib;traceLog()V";
27+
// static unordered_set<string> methods({instanceField});
28+
static unordered_set<string> methods({});
29+
return methods;
30+
}
31+
32+
string &ModuleCodeLib::getInstanceField() const {
33+
// TODO: implement instance fields like example below
34+
// static string instanceField = "Lsaarland/cispa/artist/codelib/CodeLib;INSTANCE";
35+
static string instanceField;
36+
return instanceField;
37+
}
38+
39+
string &ModuleCodeLib::getCodeClass() const {
40+
// TODO: implement code class like example below
41+
// static string codeClass = "Lsaarland/cispa/artist/codelib/CodeLib;";
42+
static string codeClass;
43+
return codeClass;
44+
}

src/codelib.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* The ARTist Project (https://artist.cispa.saarland)
3+
*
4+
* Copyright (C) 2018 CISPA (https://cispa.saarland), Saarland University
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author "Parthipan Ramesh <[email protected]>"
19+
*
20+
*/
21+
22+
#ifndef ART_MODULES_CODELIB_H_
23+
#define ART_MODULES_CODELIB_H_
24+
25+
#include <string>
26+
#include <unordered_set>
27+
#include <artist/env/codelib.h>
28+
29+
using std::string;
30+
using std::unordered_set;
31+
32+
using art::CodeLib;
33+
34+
class ModuleCodeLib : public CodeLib {
35+
public:
36+
ModuleCodeLib() = default;
37+
38+
ModuleCodeLib(const ModuleCodeLib &other) = default;
39+
40+
ModuleCodeLib(ModuleCodeLib &&other) = default;
41+
42+
~ModuleCodeLib() override = default;
43+
44+
ModuleCodeLib &operator=(const ModuleCodeLib &) = default;
45+
46+
ModuleCodeLib &operator=(ModuleCodeLib &&) = default;
47+
48+
unordered_set<string> &getMethods() const override;
49+
50+
string &getInstanceField() const override;
51+
52+
string &getCodeClass() const override;
53+
}; // class ModuleCodeLib
54+
55+
#endif // ART_MODULES_CODELIB_H_

src/instrumentation_pass.cc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* The ARTist Project (https://artist.cispa.saarland)
3+
*
4+
* Copyright (C) 2018 CISPA (https://cispa.saarland), Saarland University
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author "Parthipan Ramesh <[email protected]>"
19+
*
20+
*/
21+
22+
#include <atomic>
23+
24+
#include <artist/artist_log.h>
25+
#include <artist/injection/injection_visitor.h>
26+
#include <artist/env/java_env.h>
27+
#include <artist/injection/primitives.h>
28+
#include <artist/injection/boolean.h>
29+
#include <artist/injection/integer.h>
30+
#include <artist/injection/float.h>
31+
#include <artist/verbose_printer.h>
32+
#include <artist/injection/char.h>
33+
34+
#include "instrumentation_pass.h"
35+
36+
using std::string;
37+
using std::vector;
38+
using std::shared_ptr;
39+
using std::make_shared;
40+
using std::endl;
41+
using std::sort;
42+
43+
using art::Target;
44+
using art::Parameter;
45+
using art::Char;
46+
using art::InjectionTarget;
47+
48+
vector<Injection> HModule::ProvideInjections() const {
49+
vector<Injection> results;
50+
51+
// TODO: Implement injections here
52+
53+
return results;
54+
}

src/instrumentation_pass.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* The ARTist Project (https://artist.cispa.saarland)
3+
*
4+
* Copyright (C) 2018 CISPA (https://cispa.saarland), Saarland University
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author "Parthipan Ramesh <[email protected]>"
19+
*
20+
*/
21+
22+
#ifndef ART_MODULES_ARTIST_H_
23+
#define ART_MODULES_ARTIST_H_
24+
25+
#include <artist/injection/universal_artist.h>
26+
27+
using art::HUniversalArtist;
28+
using art::MethodInfo;
29+
using art::OptimizingCompilerStats;
30+
using art::Injection;
31+
32+
class HModule : public HUniversalArtist {
33+
public:
34+
explicit HModule(
35+
const MethodInfo &method_info,
36+
#ifdef BUILD_MARSHMALLOW
37+
bool is_in_ssa_form = true,
38+
#endif
39+
const char *pass_name = "ArtistModule", OptimizingCompilerStats *stats = nullptr)
40+
: HUniversalArtist(method_info
41+
#ifdef BUILD_MARSHMALLOW
42+
, is_in_ssa_form
43+
#endif
44+
, pass_name, stats) {
45+
// Nothing
46+
}
47+
48+
vector<Injection> ProvideInjections() const OVERRIDE;
49+
};
50+
51+
#endif // ART_MODULES_ARTIST_H_

src/module.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* The ARTist Project (https://artist.cispa.saarland)
3+
*
4+
* Copyright (C) 2018 CISPA (https://cispa.saarland), Saarland University
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author "Parthipan Ramesh <[email protected]>"
19+
*
20+
*/
21+
22+
#include <artist/filtering/method_name_filters.h>
23+
24+
#include "module.h"
25+
#include "instrumentation_pass.h"
26+
#include "codelib.h"
27+
28+
using std::make_shared;
29+
using std::unique_ptr;
30+
31+
shared_ptr<HArtist> ArtistModule::createPass(const MethodInfo &method_info) const {
32+
return make_shared<HModule>(method_info);
33+
}
34+
35+
shared_ptr<const CodeLib> ArtistModule::createCodeLib() const {
36+
return make_shared<ModuleCodeLib>();
37+
}
38+
39+
// Possible MethodFilter: skip android support lib ui methods since they bloat up the log
40+
unique_ptr<Filter> ArtistModule::getMethodFilter() const {
41+
const vector<const string> ui = {"android.support."};
42+
return unique_ptr<Filter>(new art::BlacklistFilter(ui));
43+
}
44+
45+
// the class factories
46+
extern "C" shared_ptr<art::Module> create() {
47+
return make_shared<ArtistModule>();
48+
}

src/module.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* The ARTist Project (https://artist.cispa.saarland)
3+
*
4+
* Copyright (C) 2018 CISPA (https://cispa.saarland), Saarland University
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author "Parthipan Ramesh <[email protected]>"
19+
*
20+
*/
21+
22+
#ifndef ART_MODULES__MODULE_H_
23+
#define ART_MODULES__MODULE_H_
24+
25+
#include <artist/modules/module.h>
26+
27+
using art::Module;
28+
using art::HArtist;
29+
using art::MethodInfo;
30+
using art::CodeLib;
31+
using art::Filter;
32+
33+
class ArtistModule : public Module {
34+
shared_ptr<HArtist> createPass(const MethodInfo &method_info) const OVERRIDE;
35+
36+
shared_ptr<const CodeLib> createCodeLib() const OVERRIDE;
37+
38+
public:
39+
unique_ptr<Filter> getMethodFilter() const OVERRIDE;
40+
};
41+
42+
#endif // ART_MODULES__MODULE_H_

0 commit comments

Comments
 (0)