-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrashActivity.java
44 lines (36 loc) · 1.11 KB
/
CrashActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.kevinkreiser.crashtest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class CrashActivity extends AppCompatActivity {
static {
System.loadLibrary("native-lib");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_crash);
//setup segv handler
handleSegv();
//cause a segv
sendSegv();
}
/**
* Sets up signal handler for SIGSEGV which will call the callback function below
* @return true if the handler was set
*/
public native boolean handleSegv();
/**
* Raises the SIGSEGV signal which will cause the handler to be called
*/
public native void sendSegv();
/**
* A function that the native code will call back when it receives SIGSEGV
* as an illustration it just logs
*
* @param message The message coming back from c++
*/
public void callback(String message) {
Log.e("CrashActivity.callback", message);
}
}