Skip to content

Instantly share code, notes, and snippets.

@YaSuenag
YaSuenag / raspi4-linux-headless-install.md
Last active September 16, 2023 07:18
ヘッドレスでのRaspberry Pi 4へのLinuxインストール

Raspberry Pi 4 をコンソール(ディスプレイ、キーボードなど)につながず、USB OTG でシリアル接続できる環境に仕上げる方法

前提条件

  • Windows 11 で、最新の WSL 2(ストア版)がインストールされていること
  • Ubuntu 22.04 が WSL 2 でインストールされていること
  • WSL 2 の systemd が設定済みであること https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
  • systemd-container と qemu-user-static がインストール済みであること
  • Raspberry Pi 4 と USB OTG でシリアル接続可能であること
#include <iostream>
#include <cstring>
#ifndef O_RDONLY
#define O_RDONLY 0 // for debug
#endif
// Function pointer for stub functions
int (*open)(const char *pathname, int flags);
ssize_t(*read)(int fd, void *buf, size_t count);
@YaSuenag
YaSuenag / README.md
Last active November 7, 2020 13:22
Unified Logging for network

outline

Abstract

-Xlog:all=info:host=127.0.0.1,port=9999

Log message is sent to the consumer in plain text each time it is issued. The user can configure it with -Xlog option.

  1. Log message is issued from the code in HotSpot
  2. Log message is stored in message buffer
import java.io.*;
import java.util.*;
import java.util.stream.*;
import java.lang.reflect.*;
import javax.management.*;
import sun.tools.jconsole.*;
public class JMXClient implements AutoCloseable{
@YaSuenag
YaSuenag / gist:a4bea7922bd0790550d4
Last active May 19, 2017 01:48
JVMCIを使ってみよう(メソッドプロファイル取得編)

とりあえず、JVMCI経由でメソッドプロファイル情報を取得してみます。

方針

  • プロファイルを取得したいクラスを予め決めておき、シャットダウンフック実行時に一気にダンプします。
  • JVMCIではメソッド単位でコントロール可能ですが、とりあえずクラス内定義メソッド全部をダンプするようにします。

JVMCI取得部

/*
 * Copyright (C) 2015 Yasumasa Suenaga
@YaSuenag
YaSuenag / gist:382ab8855905600e735c
Last active May 12, 2017 03:49
Raspbian/Pidoraをvirt-managerから使ってみる

環境

  • Fedora21
    • libvirt
    • virt-manager
    • qemu-system-arm
    • libguestfs-tools-c
  • Raspbian
  • Pidora20

下準備

@YaSuenag
YaSuenag / Makefile
Last active April 20, 2017 06:33
Example code of HeapStats realtime deadlock detector
.PHONY: clean
CFLAGS = -fPIC -g
LDFLAGS = -lpthread
CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
TARGETS = libdltest.so libdltest-jmm.so
all: $(TARGETS)
libdltest.so: deadlockDetector.o
@YaSuenag
YaSuenag / error1.log
Created June 26, 2016 15:04
Build JDK 9 with GCC 6.1.1
/home/ysuenaga/OpenJDK/hs/hotspot/src/share/vm/classfile/altHashing.cpp:227:43: error: narrowing conversion of '2206368128u' from 'unsigned int' to 'jint {aka int}' inside { } [-Wnarrowing]
static const jint ONE_INT[] = { 0x83828180};
^
/home/ysuenaga/OpenJDK/hs/hotspot/src/share/vm/classfile/altHashing.cpp:238:55: error: narrowing conversion of '2206368128u' from 'unsigned int' to 'jint {aka int}' inside { } [-Wnarrowing]
static const jint TWO_INT[] = { 0x83828180, 0x87868584};
^
/home/ysuenaga/OpenJDK/hs/hotspot/src/share/vm/classfile/altHashing.cpp:238:55: error: narrowing conversion of '2273740164u' from 'unsigned int' to 'jint {aka int}' inside { } [-Wnarrowing]
lib/CompileJvm.gmk:193: recipe for target '/home/ysuenaga/OpenJDK/hs/build/linux-x86_64-normal-server-fastdebug/hotspot/variant-server/libjvm/objs/altHashing.o' failed
gmake[4]: *** [/home/ysuenaga/OpenJDK/hs/build/linux-x86_64-normal-server-fastde