X-Profiler / xprofiler

🌀An addon for node.js, which supporting output performance log and real-time profiling through sampling.
Other
429 stars 57 forks source link

xprofiler coredump导出的文件andb识别不了 #223

Closed CreatedFromZhang closed 1 year ago

CreatedFromZhang commented 1 year ago

image

xprofile 版本已经更新到了2.5.1

hyj1991 commented 1 year ago

你用错了吧,我们一直在使用这个功能,看下你的执行指令。

CreatedFromZhang commented 1 year ago

andb -g -c x-coredump-3085-20230406-0.core
用这个命令运行的

zhaolei0505 commented 1 year ago

这个错误提示是 corefile 不是一个有效的 elf 文件,可以使用 file x-coredump-3085-20230406-0.core 看一下输出么?

CreatedFromZhang commented 1 year ago

file x-coredump-3085-20230406-0.core x-coredump-3085-20230406-0.core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from 'node /data/project/ldap-agent/dist/index.js', real uid: 0, effective uid: 0, real gid: 0, effective gid: 0, execfn: '/bin/node', platform: 'x86_64'

CreatedFromZhang commented 1 year ago

andb -g -c x-coredump-3085-20230406-0.core /data/project/andb/loader error: not a valid elf file. Traceback (most recent call last): File "/data/project/andb/loader", line 124, in buildId = corefileFmt.GetBuildId() File "/data/project/andb/andb/loader/core.py", line 121, in GetBuildId return prog.GetBuildId() File "/data/project/andb/andb/loader/elf.py", line 510, in GetBuildId for (name, desc, n_type) in self.GetNotes(): File "/data/project/andb/andb/loader/elf.py", line 336, in GetNotes for p in self.GetPhdrs(): File "/data/project/andb/andb/loader/elf.py", line 280, in GetPhdrs m = self.Seek(off) File "/data/project/andb/andb/loader/elf.py", line 196, in Seek m.seek(x) ValueError: seek out of range

CreatedFromZhang commented 1 year ago

gdb --version GNU gdb (GDB) 10.2 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

zhaolei0505 commented 1 year ago

/bin/node 这是官方的 node 么?版本号是多少?

CreatedFromZhang commented 1 year ago

/bin/node --version v16.17.0 是用nvm 安装的

zhaolei0505 commented 1 year ago

可以直接从这个地址获取 node.typ.gz,下载后解压为 node.typ。 node-v16.17.0.typ.gz

然后将您本地的 /bin/node 和 x-coredump-3085-20230406-0.core 一起放在同一目录下。 使用以下命令启动本地调试,默认 andb 会查找和加载当前目录下的 node.typ 文件。

andb -g node -c x-coredump-3085-20230406-0.core
CreatedFromZhang commented 1 year ago

image

zhaolei0505 commented 1 year ago

运行环境是什么? 另外看一下 andb 是最新 main 的代码么?因为上面的行号和我看的对应不上。

zhaolei0505 commented 1 year ago

andb 项目地址在: https://github.com/noslate-project/andb

CreatedFromZhang commented 1 year ago

git remote -v origin https://github.com/noslate-project/andb.git (fetch) origin https://github.com/noslate-project/andb.git (push) git log commit 99b365b52297ec3d067c272139aeba9d5b3868ec Author: ZhaoLei 77103671+zhaolei0505@users.noreply.github.com Date: Tue Mar 21 11:06:02 2023 +0800

feat: added environ, isolate and mmap note in tsr. (#33)

commit c503c258cc19f26a2199b28add72d489a497c131 Author: ZhaoLei 77103671+zhaolei0505@users.noreply.github.com Date: Wed Mar 15 12:54:00 2023 +0800

git status -v

On branch main

nothing to commit, working directory clean

应该是最新的吧,用的主分支的代码

zhaolei0505 commented 1 year ago

或者试试删干净 andb 后 git reset 看看?因为这个错误我这边没有遇到过

CreatedFromZhang commented 1 year ago

image 好像变了一个错

zhaolei0505 commented 1 year ago

上面的错误,似乎是你的环境可以在 gdb 导入 lldb 的包导致?

(gdb) pi
>>> import lldb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named lldb
>>>

如果你本机上也安装了 lldb,可以去掉 -g (gdb) 选项直接使用 lldb 调试看看

CreatedFromZhang commented 1 year ago

image gcore 支持lldb吗?因为这个coredump是xprofIler生成的

zhaolei0505 commented 1 year ago

lldb 的版本是多少?lldb --version,如果太低可能不支持 node.typ 文件。 如果需要使用 gdb 的话,可以先临时把 andb/andb/dbg/dbg_select.py 去掉 lldb 的支持,

type = 'unknown'
if isGDB():
    from .dbg_gdb import *
    type = "gdb"
else:
    raise Exception
CreatedFromZhang commented 1 year ago

lldb --version lldb version 3.4.2 ( revision )

CreatedFromZhang commented 1 year ago

image 注释掉了,不过好像缺少了python包

zhaolei0505 commented 1 year ago

gdb 用 andb-gdb 的项目试试? https://github.com/noslate-project/andb-gdb

cd andb-gdb
source env.sh
zhaolei0505 commented 1 year ago

lldb --version lldb version 3.4.2 ( revision )

需要 7.0 以上版本

CreatedFromZhang commented 1 year ago

image 没有报错了,不过这个工具怎么查看v8对象呢

zhaolei0505 commented 1 year ago

image 没有报错了,不过这个工具怎么查看v8对象呢

启动命令发一下? 这个好像只是启动了 gdb,并没有加载 andb ?

正常的启动会显示 v8 的版本,以及加载的 v8 对象信息。 image

最后会有 andb loaded 字样 image

CreatedFromZhang commented 1 year ago

image

zhaolei0505 commented 1 year ago

看下你的 node 文件?执行下命令,

nm -C node | grep major
file node
CreatedFromZhang commented 1 year ago

nm -C /bin/node | grep major nm: /bin/node: no symbols file /bin/node /bin/node: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=5c066306816aaaf4548082844e1ba677268a1669, for GNU/Linux 2.6.32, stripped

zhaolei0505 commented 1 year ago

nm -C /bin/node | grep major nm: /bin/node: no symbols file /bin/node /bin/node: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=5c066306816aaaf4548082844e1ba677268a1669, for GNU/Linux 2.6.32, stripped

这个 node 版本不是 node.js 官方的 release,目前 andb 仅支持对官方 release 的版本产生的 coredump 进行分析。另外不要对 node 的二进制进行 strip 操作,strip 之后就无法进行调试了。如果你有 strip 之前的 node 二进制,可以放在和 coredump 同一目录下再启动调试。

hyj1991 commented 1 year ago

@CreatedFromZhang 先关闭了,使用官方的 Node 版本基于 xprofiler 生成的 core 是可以被 andb 识别的,如果使用还有疑问可以继续在这里回复。

CreatedFromZhang commented 1 year ago

感谢各位大佬的支持!