mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-12-24 13:48:04 +08:00
feat: add pprof
This commit is contained in:
94
plugin/debug/pkg/internal/binutils/testdata/build_binaries.go
vendored
Normal file
94
plugin/debug/pkg/internal/binutils/testdata/build_binaries.go
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
// Copyright 2019 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This is a script that generates the test executables for MacOS and Linux
|
||||
// in this directory. It should be needed very rarely to run this script.
|
||||
// It is mostly provided as a future reference on how the original binary
|
||||
// set was created.
|
||||
|
||||
// When a new executable is generated, hardcoded addresses in the
|
||||
// functions TestObjFile, TestMachoFiles, TestPEFile in binutils_test.go must be updated.
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
if err := removeGlob("exe_linux_64*"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
out, err := exec.Command("cc", "-g", "-ffile-prefix-map="+wd+"="+"/tmp", "-o", "exe_linux_64", "hello.c").CombinedOutput()
|
||||
log.Println(string(out))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
case "darwin":
|
||||
if err := removeGlob("exe_mac_64*", "lib_mac_64"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
out, err := exec.Command("clang", "-g", "-ffile-prefix-map="+wd+"="+"/tmp", "-o", "exe_mac_64", "hello.c").CombinedOutput()
|
||||
log.Println(string(out))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
out, err = exec.Command("clang", "-g", "-ffile-prefix-map="+wd+"="+"/tmp", "-o", "lib_mac_64", "-dynamiclib", "lib.c").CombinedOutput()
|
||||
log.Println(string(out))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
case "windows":
|
||||
// Many gcc environments may create binaries that trigger false-positives
|
||||
// in antiviruses. MSYS2 with gcc 10.2.0 is a working environment for
|
||||
// compiling. To setup the environment follow the guide at
|
||||
// https://www.msys2.org/ and install gcc with `pacman -S gcc`.
|
||||
out, err := exec.Command("gcc", "-g", "-ffile-prefix-map="+wd+"=", "-o", "exe_windows_64.exe", "hello.c").CombinedOutput()
|
||||
log.Println(string(out))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Println("Please verify that exe_windows_64.exe does not trigger any antivirus on `virustotal.com`.")
|
||||
default:
|
||||
log.Fatalf("Unsupported OS %q", runtime.GOOS)
|
||||
}
|
||||
}
|
||||
|
||||
func removeGlob(globs ...string) error {
|
||||
for _, glob := range globs {
|
||||
matches, err := filepath.Glob(glob)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, p := range matches {
|
||||
os.Remove(p)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_linux_64
vendored
Executable file
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_linux_64
vendored
Executable file
Binary file not shown.
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_mac_64
vendored
Executable file
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_mac_64
vendored
Executable file
Binary file not shown.
20
plugin/debug/pkg/internal/binutils/testdata/exe_mac_64.dSYM/Contents/Info.plist
vendored
Normal file
20
plugin/debug/pkg/internal/binutils/testdata/exe_mac_64.dSYM/Contents/Info.plist
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.apple.xcode.dsym.exe_mac_64</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>dSYM</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_mac_64.dSYM/Contents/Resources/DWARF/exe_mac_64
vendored
Normal file
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_mac_64.dSYM/Contents/Resources/DWARF/exe_mac_64
vendored
Normal file
Binary file not shown.
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_windows_64.exe
vendored
Normal file
BIN
plugin/debug/pkg/internal/binutils/testdata/exe_windows_64.exe
vendored
Normal file
Binary file not shown.
39
plugin/debug/pkg/internal/binutils/testdata/fake-llvm-symbolizer
vendored
Executable file
39
plugin/debug/pkg/internal/binutils/testdata/fake-llvm-symbolizer
vendored
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright 2014 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Fake llvm-symbolizer to use in tests
|
||||
|
||||
set -f
|
||||
IFS=" "
|
||||
|
||||
while read line; do
|
||||
# line has form:
|
||||
# filename 0xaddr
|
||||
# Emit dummy output that matches llvm-symbolizer JSON output format.
|
||||
set -- ${line}
|
||||
kind=$1
|
||||
fname=$2
|
||||
addr=$3
|
||||
case ${kind} in
|
||||
CODE)
|
||||
echo "{\"Address\":\"${addr}\",\"ModuleName\":\"${fname}\",\"Symbol\":[{\"Column\":0,\"FileName\":\"${fname}.h\",\"FunctionName\":\"Inlined_${addr}\",\"Line\":0,\"StartLine\":0},{\"Column\":1,\"FileName\":\"${fname}.c\",\"FunctionName\":\"Func_${addr}\",\"Line\":2,\"StartLine\":2}]}"
|
||||
;;
|
||||
DATA)
|
||||
echo "{\"Address\":\"${addr}\",\"ModuleName\":\"${fname}\",\"Data\":{\"Name\":\"${fname}_${addr}\",\"Size\":\"0x8\",\"Start\":\"${addr}\"}}"
|
||||
;;
|
||||
*) exit 1;;
|
||||
esac
|
||||
done
|
||||
6
plugin/debug/pkg/internal/binutils/testdata/hello.c
vendored
Normal file
6
plugin/debug/pkg/internal/binutils/testdata/hello.c
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Hello, world!\n");
|
||||
return 0;
|
||||
}
|
||||
7
plugin/debug/pkg/internal/binutils/testdata/lib.c
vendored
Normal file
7
plugin/debug/pkg/internal/binutils/testdata/lib.c
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
int foo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bar() {
|
||||
return 2;
|
||||
}
|
||||
BIN
plugin/debug/pkg/internal/binutils/testdata/lib_mac_64
vendored
Executable file
BIN
plugin/debug/pkg/internal/binutils/testdata/lib_mac_64
vendored
Executable file
Binary file not shown.
20
plugin/debug/pkg/internal/binutils/testdata/lib_mac_64.dSYM/Contents/Info.plist
vendored
Normal file
20
plugin/debug/pkg/internal/binutils/testdata/lib_mac_64.dSYM/Contents/Info.plist
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.apple.xcode.dsym.lib_mac_64</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>dSYM</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
plugin/debug/pkg/internal/binutils/testdata/lib_mac_64.dSYM/Contents/Resources/DWARF/lib_mac_64
vendored
Normal file
BIN
plugin/debug/pkg/internal/binutils/testdata/lib_mac_64.dSYM/Contents/Resources/DWARF/lib_mac_64
vendored
Normal file
Binary file not shown.
1
plugin/debug/pkg/internal/binutils/testdata/malformed_elf
vendored
Normal file
1
plugin/debug/pkg/internal/binutils/testdata/malformed_elf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ELF<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
1
plugin/debug/pkg/internal/binutils/testdata/malformed_macho
vendored
Normal file
1
plugin/debug/pkg/internal/binutils/testdata/malformed_macho
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Reference in New Issue
Block a user