Browse Source

internal: move symbolutil to internal core

Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
main
Tonghao Zhang 9 months ago
parent
commit
9d9474aafd
5 changed files with 25 additions and 25 deletions
  1. +3
    -3
      cmd/perf/parsedata.go
  2. +17
    -17
      core/events/dropwatch.go
  3. +3
    -3
      core/events/softirq_tracing.go
  4. +1
    -1
      internal/symbol/ksymbols.go
  5. +1
    -1
      internal/symbol/usymbols.go

+ 3
- 3
cmd/perf/parsedata.go View File

@@ -25,7 +25,7 @@ import (

"huatuo-bamai/internal/bpf"
"huatuo-bamai/internal/flamegraph"
"huatuo-bamai/internal/utils/symbolutil"
"huatuo-bamai/internal/symbol"

ingestv1 "github.com/grafana/pyroscope/api/gen/proto/go/ingester/v1"
querierv1 "github.com/grafana/pyroscope/api/gen/proto/go/querier/v1"
@@ -48,7 +48,7 @@ type eventdata struct {

// CgDumpTrace is an interface for dump stacks in cgusage case
func CgDumpTrace(addrs []uint64) string {
stacks := symbolutil.DumpKernelBackTrace(addrs, perfStackDepth)
stacks := symbol.DumpKernelBackTrace(addrs, perfStackDepth)
return strings.Join(stacks.BackTrace, "\n")
}

@@ -92,7 +92,7 @@ func parsedata(b bpf.BPF) error {
Value uint64
}

u := symbolutil.NewUsym()
u := symbol.NewUsym()
for _, v := range items {
ed := eventdata{}
var count uint64


+ 17
- 17
core/events/dropwatch.go View File

@@ -25,8 +25,8 @@ import (
"huatuo-bamai/internal/conf"
"huatuo-bamai/internal/log"
"huatuo-bamai/internal/storage"
"huatuo-bamai/internal/symbol"
"huatuo-bamai/internal/utils/netutil"
"huatuo-bamai/internal/utils/symbolutil"
"huatuo-bamai/pkg/tracing"
)

@@ -66,21 +66,21 @@ var typeMap = map[uint8]string{
}

type perfEventT struct {
TgidPid uint64 `json:"tgid_pid"`
Saddr uint32 `json:"saddr"`
Daddr uint32 `json:"daddr"`
Sport uint16 `json:"sport"`
Dport uint16 `json:"dport"`
Seq uint32 `json:"seq"`
AckSeq uint32 `json:"ack_seq"`
QueueMapping uint32 `json:"queue_mapping"`
PktLen uint64 `json:"pkt_len"`
StackSize int64 `json:"stack_size"`
Stack [symbolutil.KsymbolStackMaxDepth]uint64 `json:"stack"`
SkMaxAckBacklog uint32 `json:"sk_max_ack_backlog"`
State uint8 `json:"state"`
Type uint8 `json:"type"`
Comm [bpf.TaskCommLen]byte `json:"comm"`
TgidPid uint64 `json:"tgid_pid"`
Saddr uint32 `json:"saddr"`
Daddr uint32 `json:"daddr"`
Sport uint16 `json:"sport"`
Dport uint16 `json:"dport"`
Seq uint32 `json:"seq"`
AckSeq uint32 `json:"ack_seq"`
QueueMapping uint32 `json:"queue_mapping"`
PktLen uint64 `json:"pkt_len"`
StackSize int64 `json:"stack_size"`
Stack [symbol.KsymbolStackMaxDepth]uint64 `json:"stack"`
SkMaxAckBacklog uint32 `json:"sk_max_ack_backlog"`
State uint8 `json:"state"`
Type uint8 `json:"type"`
Comm [bpf.TaskCommLen]byte `json:"comm"`
}

type DropWatchTracingData struct {
@@ -179,7 +179,7 @@ func (c *dropWatchTracing) formatEvent(event *perfEventT) *DropWatchTracingData
}

// stack
stacks := strings.Join(symbolutil.DumpKernelBackTrace(event.Stack[:], symbolutil.KsymbolStackMaxDepth).BackTrace, "\n")
stacks := strings.Join(symbol.DumpKernelBackTrace(event.Stack[:], symbol.KsymbolStackMaxDepth).BackTrace, "\n")

// tracer data
data := &DropWatchTracingData{


+ 3
- 3
core/events/softirq_tracing.go View File

@@ -23,7 +23,7 @@ import (
"huatuo-bamai/internal/bpf"
"huatuo-bamai/internal/conf"
"huatuo-bamai/internal/storage"
"huatuo-bamai/internal/utils/symbolutil"
"huatuo-bamai/internal/symbol"
"huatuo-bamai/pkg/tracing"
)

@@ -32,7 +32,7 @@ import (
type softirqTracing struct{}

type softirqPerfEvent struct {
Stack [symbolutil.KsymbolStackMaxDepth]uint64
Stack [symbol.KsymbolStackMaxDepth]uint64
StackSize int64
Now uint64
StallTime uint64
@@ -129,7 +129,7 @@ func (c *softirqTracing) Start(ctx context.Context) error {

// softirqDumpTrace is an interface for dump stacks in this case with offset and module info
func softirqDumpTrace(addrs []uint64) string {
stacks := symbolutil.DumpKernelBackTrace(addrs, symbolutil.KsymbolStackMaxDepth)
stacks := symbol.DumpKernelBackTrace(addrs, symbol.KsymbolStackMaxDepth)
return strings.Join(stacks.BackTrace, "\n")
}



internal/utils/symbolutil/ksymbols.go → internal/symbol/ksymbols.go View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package symbolutil
package symbol

import (
"bufio"

internal/utils/symbolutil/usymbols.go → internal/symbol/usymbols.go View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package symbolutil
package symbol

import (
"bufio"

Loading…
Cancel
Save