aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/admin/prog/spec.go
blob: 48e1719551f9f1e131f2115422e08731f8c05eff (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej

package prog

import (
	"strings"
)

type Spec struct {
	Program              string
	Args                 []string
	BaseName             string
	Env                  map[string]string
	numaSocket           int
	shouldUseCallgrind   bool
	shouldUseValgrind    bool
	shouldUseNumaCtl     bool
	shouldUseVespaMalloc bool
	vespaMallocPreload   string
}

func NewSpec(argv []string) *Spec {
	progName := argv[0]
	p := Spec{
		Program:    progName,
		Args:       argv,
		BaseName:   baseNameOf(progName),
		Env:        make(map[string]string),
		numaSocket: -1,
	}
	return &p
}

func baseNameOf(s string) string {
	idx := strings.LastIndex(s, "/")
	idx++
	return s[idx:]
}