Skip to content

Latest commit

 

History

History
97 lines (70 loc) · 2.82 KB

File metadata and controls

97 lines (70 loc) · 2.82 KB

ASTL Go Wrapper

This directory provides a Go wrapper for the Arm SoC Telemetry Library (ASTL), similar in spirit to the Python wrapper under python/.

Status

This Go interface is part of the supported in-tree ASTL wrapper surface.

It is implemented with cgo and maps closely to the public ASTL C API rather than introducing a separate Go-native telemetry model. The main remaining practical caveat is build/runtime integration: the wrapper still expects ASTL headers and a built shared library to be available to cgo, and it talks directly to the public ASTL C API from include/astl/.

Layout

  • astl/: Go package exposing ASTL discovery, configuration, collection, and sample-retrieval APIs
  • examples/basic/: small end-to-end enumeration example

Prerequisites

The Go package uses cgo and expects ASTL's public headers plus a built ASTL shared library to be available.

For a repo-local debug build:

just build
ASTL_HOST_ARCH="$(./scripts/host_arch.sh)"
export CGO_LDFLAGS="-L$PWD/build/debug/${ASTL_HOST_ARCH}/lib -Wl,-rpath,$PWD/build/debug/${ASTL_HOST_ARCH}/lib -lastl-0d"
export LD_LIBRARY_PATH="$PWD/build/debug/${ASTL_HOST_ARCH}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

The Go wrapper adds the repo-local source header path via cgo. Set CGO_CFLAGS when using generated headers from a build other than debug, and set CGO_LDFLAGS to the matching library (astl-0d for debug or astl-0 for release).

For an installed ASTL, point cgo directly at the install prefix:

export CGO_CFLAGS="-I/path/to/prefix/include"
export CGO_LDFLAGS="-L/path/to/prefix/lib -Wl,-rpath,/path/to/prefix/lib -lastl-0"

Running Tests

From the repo root:

ASTL_HOST_ARCH="$(./scripts/host_arch.sh)"
export CGO_LDFLAGS="-L$PWD/build/debug/${ASTL_HOST_ARCH}/lib -Wl,-rpath,$PWD/build/debug/${ASTL_HOST_ARCH}/lib -lastl-0d"
export LD_LIBRARY_PATH="$PWD/build/debug/${ASTL_HOST_ARCH}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
cd Go
go test ./...

A go.mod file is included in the Go/ directory to enable module mode. Ensure you're using Go 1.11 or later, which supports modules by default.

These tests are lightweight smoke tests today. They are mainly there to catch linking, cgo, and basic-discovery regressions for the Go wrapper.

Minimal Example

package main

import (
	"fmt"
	"log"

	"github.com/Arm-Debug/ASTL/Go/astl"
)

func main() {
	fmt.Println("ASTL version:", astl.VersionString())

	targets, err := astl.GetTargets()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("targets discovered: %d\n", len(targets))
	for _, target := range targets {
		fmt.Printf("- %s: %s\n", target.Name, target.Description)
	}
}