尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

perf中 的dwarf是什么?

perf中 的dwarf是什么?
📅 发布时间:2026/6/17 22:03:12

DWARF 是一种调试信息格式,全称 Debugging With Attributed Record Formats。它不是压缩算法,而是一种标准,用来描述程序的结构、变量、函数、行号等信息,方便调试器(如 gdb)或性能分析工具(如 perf)做符号解析和调用栈展开。


DWARF 的作用

  • 当你用 gcc 或 clang 编译时加 -g,编译器会在目标文件和可执行文件里生成 DWARF 调试信息。
  • 这些信息包括:
    • 源文件名、行号(用于断点、回溯)
    • 函数名、变量名
    • 调用关系(用于 perf --call-graph dwarf 展开调用栈)

为什么 perf 需要 DWARF?

  • perf 采样时只拿到指令地址,要想显示函数名和调用链,需要知道地址对应的源代码位置。
  • 如果用 --call-graph dwarf,perf 会利用 DWARF 的 unwind 信息 来还原完整调用栈,比传统的帧指针(fp)方式更准确,尤其在编译器优化后帧指针被省略的情况下。

DWARF 与其他方式对比

方式 优点 缺点
fp(frame pointer) 开销低 需要 -fno-omit-frame-pointer,优化受限
dwarf 不依赖帧指针,准确率高 开销大,采样频率需降低
lbr(last branch record) 开销低,硬件支持 仅部分 CPU 支持,栈深有限

如何解决 PERF 时unknown的问题

If you see [unknown], the following might be useful assuming you're using --call-stack dwarf:

  • Note that --call-graph dwarf,1024 (where 1024 is the stack size) dumps first 1024 bytes of the stack to the record file, then use DWARF debug information to deduce the frames later.

    This is quite inefficient (because it dumps the whole stack instead of just the addresses for each sample), but more importantly, if the stack is too deep (1024 bytes is insufficient) then the result is [unknown] frames.

    So, either try increasing it to dwarf,65528 (which is the maximum on my machine), or if it still doesn't work, --call-graph lbr or --call-graph fp (the last one may need recompile).

Other things to try:

  • echo 0 |sudo tee /proc/sys/kernel/kptr_restrict (suggested in https://users.rust-lang.org/t/flamegraph-shows-every-caller-is-unknown/52408)

  • perf map file must be owned by the correct user (https://stackoverflow.com/a/39662781/5267751)

  • sudo sysctl kernel.perf_event_paranoid=-1 (perf script would print this out if needed)

  • Flame graph can be generated by

    perf script flamegraph -F 100 ./program args
    

    but you can also explicitly separate the recording and the reporting step (to aid with debugging) by

    perf record --call-graph lbr -F 100 ./program args
    perf script report flamegraph
    

Questions that needs to be cleaned up:

  • https://stackoverflow.com/questions/27842281/unknown-events-in-nodejs-v8-flamegraph-using-perf-events
  • https://stackoverflow.com/questions/10933408/how-can-i-get-perf-to-find-symbols-in-my-program
  • https://stackoverflow.com/questions/68259699/how-can-you-get-frame-pointer-perf-call-stacks-flamegraphs-involving-the-c-sta
  • https://unix.stackexchange.com/questions/276179/missing-stack-symbols-with-perf-events-perf-report-despite-fno-omit-frame-poi

References:

  • https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/monitoring_and_managing_system_status_and_performance/recording-and-analyzing-performance-profiles-with-perf_monitoring-and-managing-system-status-and-performance

Notes:

  • https://brendangregg.com/flamegraphs.html --- explains what is a flame chart (similar to flamegraph, but order the blocks by time instead of by size. I think perf doesn't support this...? Not sure if there's a way)

Other unrelated issues:

  • https://stackoverflow.com/questions/51157938/perf-doesnt-add-up-to-100

相关新闻

  • 读书笔记:一文搞懂Oracle全局临时表的统计信息管理
  • 故障处理:dul直接抽取exp文件
  • 2025-09-08 uniapp小程序赋值生效了但是页面却没变化?==》使用v-if+变量来控制元素的重新渲染

最新新闻

  • PyCaret低代码实现房价预测:从数据准备到模型上线全链路
  • 【Springboot毕设全套源码+文档】基于springboot的智慧仓库(丰富项目+远程调试+讲解+定制)
  • 2026年6月PE排水管企业推荐指南 - 多才菠萝
  • 全维度测评报告:2026 杭州黄金回收报价套路拆解,称重、验金、扣费猫腻逐项核验 - 奢侈品回收评测
  • DSP56800到DSP56800E代码移植:AGU寄存器加载策略与兼容性问题详解
  • Python自动化测试实战:从Selenium到Pytest的完整技术栈解析

日新闻

  • 2026年不锈钢卷板厂家推荐排行榜:冷轧热轧/304/201不锈钢卷板,高颜值耐腐蚀源头厂家实力精选 - 企业推荐官【官方】
  • FLUX.1-dev FP8模型实战指南:24GB以下显卡高效部署方案
  • 2026佛山长途搬家价目表:跨省跨市搬家费用完整计算指南 - 从来都是英雄出少年

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号