#!/bin/sh

set -e

JAVA="java"
JAVAC="javac"
if [ ! -z "$JAVA_HOME" ]; then
    JAVA="$JAVA_HOME/bin/java"
    JAVAC="$JAVA_HOME/bin/javac"
fi

$JAVAC Reproducer.java

GDB_SCRIPT=`cat <<EOF
set args -XX:MaxMetaspaceSize=11m -XX:-UseCompressedOops Reproducer
file $JAVA
handle SIGUSR1 nostop noprint
handle SIGUSR2 nostop noprint
handle SIGFPE nostop noprint
handle SIGSEGV nostop noprint
set breakpoint pending on
break VMError::report_and_die
break Metaspace::report_metadata_oome
run
EOF`

echo "$GDB_SCRIPT" > reproduce.gdb
gdb -x reproduce.gdb
