Skip to content

Commit

Permalink
支持解析core dump文件
Browse files Browse the repository at this point in the history
  • Loading branch information
qht1003077897 committed Jul 4, 2024
1 parent 6d8af0a commit 1187cbd
Show file tree
Hide file tree
Showing 227 changed files with 96,039 additions and 10 deletions.
7 changes: 7 additions & 0 deletions assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@
<span class="hidden-xs">Archive</span> Zip
<span class="glyphicon glyphicon-download-alt"></span>
</a>
<!--
<button class="btn btn-default btn-xs" v-on:click="showInfo(f)">
<span class="glyphicon glyphicon-info-sign"></span>
</button>
-->
<button class="btn btn-default btn-xs" v-if="auth.delete" v-on:click="deletePathConfirm(f, $event)">
<span style="color:#CC3300" class="glyphicon glyphicon-trash"></span>
</button>
Expand All @@ -161,6 +163,7 @@
<span class="hidden-xs">Download</span>
<span class="glyphicon glyphicon-download-alt"></span>
</a>
<!--
<button class="btn btn-default btn-xs bstooltip" data-trigger="manual" data-title="Copied!"
data-clipboard-text="{{genDownloadURL(f)}}">
<i class="fa fa-copy"></i>
Expand All @@ -172,6 +175,10 @@
<span v-if="shouldHaveQrcode(f.name)">QRCode</span>
<span class="glyphicon glyphicon-qrcode"></span>
</button>
-->
<button class="btn btn-default btn-xs" v-on:click="decode(f)">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
<a class="btn btn-default btn-xs visible-xs" v-if="shouldHaveQrcode(f.name)" href="{{genInstallURL(f.name)}}">
Install <i class="fa fa-cube"></i>
</a>
Expand Down
24 changes: 24 additions & 0 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,30 @@ var vm = new Vue({
}
})
},
decode: function (f) {
console.log(f);
var that = this;
$.ajax({
url: this.getEncodePath(f.name),
data: {
op: "decode",
},
method: "GET",
success: function (res) {
console.log("decode:" , res)
// 打开新的标签
var newTab = window.open();
// 将字符串写入新标签
newTab.document.write("<title>" + "dmp解析结果" + "</title>");
newTab.document.write("<pre>" + res + "</pre>");
// 关闭新标签的文档流,使其可以开始加载
newTab.document.close();
},
error: function (jqXHR, textStatus, errorThrown) {
showErrorMessage(jqXHR)
}
})
},
makeDirectory: function () {
var name = window.prompt("current path: " + location.pathname + "\nplease enter the new directory name", "")
console.log(name)
Expand Down
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ GITCOMMIT=$(git rev-parse HEAD)
BUILDTIME=$(date -u +%Y/%m/%d-%H:%M:%S)

LDFLAGS="-X main.VERSION=$VERSION -X main.BUILDTIME=$BUILDTIME -X main.GITCOMMIT=$GITCOMMIT"
if [[ -n "${EX_LDFLAGS:-""}" ]]
then

if [ -n "${EX_LDFLAGS:-""}" ]; then
LDFLAGS="$LDFLAGS $EX_LDFLAGS"
fi

Expand All @@ -27,8 +27,8 @@ build() {
-o dist/gohttpserver-${3:-""}
}

build linux arm linux-arm
build darwin amd64 mac-amd64
#build linux arm linux-arm
#build darwin amd64 mac-amd64
build linux amd64 linux-amd64
build linux 386 linux-386
build windows amd64 win-amd64.exe
#build linux 386 linux-386
#build windows amd64 win-amd64.exe
4 changes: 3 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM golang:1.16
WORKDIR /app/gohttpserver
ADD . /app/gohttpserver
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-X main.VERSION=docker' -o gohttpserver
RUN GOPROXY=https://goproxy.cn,direct CGO_ENABLED=0 GOOS=linux go build -ldflags '-X main.VERSION=docker' -o gohttpserver

FROM debian:stable
WORKDIR /app
RUN mkdir -p /app/public
RUN apt-get update && apt-get install -y ca-certificates
VOLUME /app/public
ADD assets ./assets
ADD dump2txt.sh ./dump2txt.sh
ADD minidump_stackwalk ./minidump_stackwalk
COPY --from=0 /app/gohttpserver/gohttpserver .
EXPOSE 8000
ENTRYPOINT [ "/app/gohttpserver", "--root=/app/public" ]
Expand Down
38 changes: 38 additions & 0 deletions docker_build_x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

:<<'EOF'
配置docker的镜像加速器:
gedit /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.rainbond.cc"]
}
systemctl daemon-reload
systemctl restart docker
使用docker info 查看是否有mirror.
EOF

:<<'EOF'
错误:
go: github.com/alecthomas/kingpin@v2.2.6+incompatible: Get "https://proxy.golang.org/github.com/alecthomas/kingpin/@v/v2.2.6+incompatible.mod": dial tcp 172.217.160.81:443: i/o timeout
解决:
####export GOPROXY=https://mirrors.aliyun.com/goproxy/
go env -w GOPROXY=https://goproxy.cn/,direct
go mod tidy
go mod vendor
go mod download
EOF

#begin docker build
#编译端
docker build -t sietium/gohttpserver -f docker/Dockerfile .

docker save -o gohttpserver.tar sietium/gohttpserver:latest

#部署服务器端
#systemctl start docker

#docker load -i gohttpserver.tar

#docker run -it --rm -p 8000:8000 -v $PWD:/app/public --name gohttpserver sietium/gohttpserver --upload

12 changes: 12 additions & 0 deletions dump2txt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -
#这个脚本被gohttpserver可执行程序调用,在用户点击网页解析按钮时调用进行解析dump为txt
script_dir="$(cd "$(dirname "$0")" && pwd)"

dumpfile=$1
symbolDir=$2
echo "script_dir path: $script_dir"
echo "dumpfile : $1"
echo "symbolDir : $2"

#将堆栈跟踪信息重定向到文件中
./minidump_stackwalk ${dumpfile} ${symbolDir}
64 changes: 61 additions & 3 deletions httpstaticserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
"sync"
"time"

"regexp"

Expand Down Expand Up @@ -141,7 +142,10 @@ func (s *HTTPStaticServer) hIndex(w http.ResponseWriter, r *http.Request) {
s.hInfo(w, r)
return
}

if r.FormValue("op") == "decode" {
s.hDecode(w, r)
return
}
if r.FormValue("op") == "archive" {
s.hZip(w, r)
return
Expand Down Expand Up @@ -355,6 +359,60 @@ func (s *HTTPStaticServer) hInfo(w http.ResponseWriter, r *http.Request) {
w.Write(data)
}


func processPath(path string) string {
// 使用斜杠分割字符串
parts := strings.Split(path, "/")
// 去除数组的最后两部分
parts = parts[:len(parts)-2]
// 拼接 "symbols"
parts = append(parts, "symbols")
// 使用斜杠拼接字符串
finalPath := strings.Join(parts, "/")
return finalPath
}

func (s *HTTPStaticServer) hDecode(w http.ResponseWriter, r *http.Request) {
//relPath: /home/bridge/gohttpserver/dump/gbmanager/1.0.1/dumpfile/74F220D6A4EB1EA1A424D8426EEEA2CC0.dmp
relPath := s.getRealPath(r)
log.Println("relPath:",relPath)

simbolsPath := processPath(relPath)
log.Println("simbolsPath:", simbolsPath)

exePath, _ := os.Executable()
log.Println("osPath:",exePath)

parts := strings.Split(exePath, "/")
if len(parts) > 1 {
parts = parts[:len(parts)-1]
}
newPath := strings.Join(parts, "/")
log.Println(newPath)

log.Println("dump2txt is Exist:",fileExists(newPath + "/dump2txt.sh"))

command := "sh"
args := []string{"dump2txt.sh",relPath,simbolsPath}

// 创建一个exec.Cmd对象
cmd := exec.Command(command, args...)

// 获取命令的输出
output, err := cmd.Output()
if err != nil {
fmt.Printf("dump2txt.sh error: %v\n", err)
return
}

// 打印命令的输出
fmt.Println(string(output))
response := string(output)
w.Header().Set("Content-Type", "application/txt")
w.Write([]byte(response))
}


func (s *HTTPStaticServer) hZip(w http.ResponseWriter, r *http.Request) {
CompressToZip(w, s.getRealPath(r))
}
Expand Down
Binary file added minidump_stackwalk
Binary file not shown.
4 changes: 4 additions & 0 deletions vendor/github.com/alecthomas/kingpin/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/alecthomas/kingpin/COPYING

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1187cbd

Please sign in to comment.