Skip to content

Instantly share code, notes, and snippets.

@kay
kay / jdk11-hsdis-ubuntu.sh
Last active Aug 9, 2020
Build HotSpot disassembler for JDK 11 and 12
View jdk11-hsdis-ubuntu.sh
# The following is based on a fresh Ubuntu 18.04.2 LTS with gcc, make and perl already
# installed (not that perl has anything to do with any of this..)
#
# This is based on JDK 11 but for JDK 12 I've confirmed it builds ok with binutils-2.29
# and binutils-2.32
apt install mercurial
# Be nice if this didn't check out the universe
hg clone http://hg.openjdk.java.net/jdk/jdk11/
cd jdk11/src/utils/hsdis/
@kay
kay / hsdis-ubuntu.sh
Last active Oct 21, 2019 — forked from zajacmp3/hsdis-ubuntu.sh
Build hsdis for JDK 1.8 on Debian/Ubuntu
View hsdis-ubuntu.sh
sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev g++-multilib mercurial texinfo
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u
cd jdk8u
hg update jdk8u92-b14
sed -ri 's/subrepos="[^"]+"/subrepos="hotspot"/' ./make/scripts/hgforest.sh # only get hotspot
sed -ri 's/subrepos="[^"]+"/subrepos="hotspot"/' ./common/bin/hgforest.sh # only get hotspot
chmod +x ./get_source.sh; ./get_source.sh
cd hotspot/src/share/tools/hsdis
wget http://ftp.heanet.ie/mirrors/ftp.gnu.org/gnu/binutils/binutils-2.29.tar.gz
tar -xzf binutils-2.29.tar.gz
@kay
kay / ListJvmMonitorMetrics.java
Created Jun 27, 2018
List JVM monitoring metrics
View ListJvmMonitorMetrics.java
package org.neverfear.services.jvmmonitor.api;
import static java.lang.System.out;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Set;
import sun.jvmstat.monitor.HostIdentifier;
import sun.jvmstat.monitor.Monitor;
@kay
kay / dogtag.c
Created May 27, 2013
tag_invalidate and tag_free
View dogtag.c
void tag_invalidate(memory_t * memory) {
TAG_TYPE * start = PTR_START_TAG(memory);
*start = TAG_INVALID_VALUE;
TAG_TYPE * end = PTR_END_TAG(memory);
*end = TAG_INVALID_VALUE;
}
bool tag_free(memory_t * memory) {
if (tag_underran(memory) || tag_overran(memory)) {
@kay
kay / dogtag.c
Created May 27, 2013
tag_underran and tag_overran
View dogtag.c
bool tag_underran(memory_t * memory) {
return *PTR_START_TAG(memory) != VALID_START_TAG;
}
bool tag_overran(memory_t * memory) {
return *PTR_END_TAG(memory) != VALID_END_TAG;
}
@kay
kay / dogtag.c
Last active Dec 17, 2015
tag_alloc
View dogtag.c
#define TAG_TYPE int
#define TAG_SIZE sizeof(TAG_TYPE)
#define VALID_START_TAG 0xDEADBEEF
#define VALID_END_TAG 0xCAFEBABE
#define TAG_INVALID_VALUE 0xBADC0DE5
#define PTR_START_TAG(memory) (TAG_TYPE *)(memory->ptr - TAG_SIZE)
#define PTR_END_TAG(memory) (TAG_TYPE *)(memory->ptr + memory->size)
@kay
kay / dogtag.c
Last active Dec 17, 2015
Simple implementation of the dog tag technique to detect memory corruption.
View dogtag.c
#include "dogtag.h"
bool tag_alloc(memory_t * memory, size_t size) {
void * ptr = malloc(size + (2 * TAG_SIZE));
if (ptr == NULL) {
return false;
}
TAG_TYPE * startPtr = ptr;
*startPtr = VALID_START_TAG;
View LeadershipResolver.java
package org.neverfear.ha;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import org.jgroups.JChannel;
import org.jgroups.blocks.locking.LockService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
View FailoverManager.java
public class FailoverManager implements AutoCloseable, ChannelListener, Receiver {
private static final Logger LOGGER = LoggerFactory.getLogger(FailoverManager.class);
private static final String HA_CLUSTER = "ha-cluster";
private final JChannel channel;
private final int maximumClusterSize;
private final LeadershipResolver decider;
@kay
kay / pom.xml
Created Feb 25, 2013
Maven dependency for the allocation.jar of Google Caliber
View pom.xml
<dependencies>
<dependency>
<groupId>com.google.caliber</groupId>
<artifactId>allocation</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${env.ALLOCATION_JAR}</systemPath>
</dependency>
</dependencies>
You can’t perform that action at this time.