Finding crash information using the MAP file

Linux: tools: crash: not a supported file format 这个原因是,通过比对每个format的magic数值,或者其他的信息,来看是否属于某个format,如果都不符合,就会出现这个错误。说明kernel的coredump文件,dump的有些问题。 阅读详情
Finding crash information using the MAP file: how to create and read the file

Introduction

Programming neat applications is one thing. But when a user informs you your software has crashed, you know it's best to fix this before adding other features. If you're lucky enough, the user will have a crash address. This will go a long way in solving the problem. But how can you determine what went wrong, using this crash address?

Creating a MAP file

Well first of all, you'll need a MAP file. If you don't have one, it will be nearly impossible to find where your application crashed using the crash address. So first, I'll show you how to create a good MAP file. For this, I will create a new project (MAPFILE). You can do the same, or adjust your own project. I create a new project using the Win32 Application option in VC++ 6.0, selecting the 'typical "Hello Word!" application' to keep the size of the MAP file reasonable for explanation.

Once created we need to adjust the project settings for the release version. In the C/C++ tab, select "Line Numbers Only" for Debug Info.

Many people forget this, but you'll need this option if you want a good MAP file. This will not affect your release in any way. Next is the Link tab. Here you need to select the "Generate mapfile" option. Also, type the switches /MAPINFO:LINES and /MAPINFO:EXPORTS in the Project Options edit box.

Now, you're ready to compile and link your project. After linking, you will find a .map file in your intermediate directory (together with your exe).

Reading the MAP file

After all this dull work, now comes the neat part: how to read the MAP file. We'll do this by using a crash example. So first: how to crash your application. I did this by adding these two lines at the end of the InitInstance() function:

Collapse | Copy Code
char* pEmpty = NULL;
*pEmpty = 'x';	// This is line 119

I'm sure you can find other instructions which will crash your application. Now recompile and link. If you start the application, it will crash and you'll get a message like this: 'The instruction at "0x004011a1" referenced memory at "0x00000000". The memory could not be "Written".' .

Now, it's time to open the MAP file with notepad or something similar. You MAP file will look like this:

The top of the MAP file contains the module name, the timestamp indicating the link of the project, and the preferred load address (which will probably be 0x00400000 unless you're using a dll). After the header comes the section information that shows which sections the linker brought in from the various OBJ and LIB files.

Collapse | Copy Code
MAPFILE

 Timestamp is 3df6394d (Tue Dec 10 19:58:21 2002)

 Preferred load address is 00400000

 Start         Length     Name                   Class
 0001:00000000 000038feH .text                   CODE
 0002:00000000 000000f4H .idata$5                DATA
 0002:000000f8 00000394H .rdata                  DATA
 0002:0000048c 00000028H .idata$2                DATA
 0002:000004b4 00000014H .idata$3                DATA
 0002:000004c8 000000f4H .idata$4                DATA
 0002:000005bc 0000040aH .idata$6                DATA
 0002:000009c6 00000000H .edata                  DATA
 0003:00000000 00000004H .CRT$XCA                DATA
 0003:00000004 00000004H .CRT$XCZ                DATA
 0003:00000008 00000004H .CRT$XIA                DATA
 0003:0000000c 00000004H .CRT$XIC                DATA
 0003:00000010 00000004H .CRT$XIZ                DATA
 0003:00000014 00000004H .CRT$XPA                DATA
 0003:00000018 00000004H .CRT$XPZ                DATA
 0003:0000001c 00000004H .CRT$XTA                DATA
 0003:00000020 00000004H .CRT$XTZ                DATA
 0003:00000030 00002490H .data                   DATA
 0003:000024c0 000005fcH .bss                    DATA
 0004:00000000 00000250H .rsrc$01                DATA
 0004:00000250 00000720H .rsrc$02                DATA

After the section information, you get the public function information. Notice the "public" part. If you have static-declared C functions, they won't show up in the MAP file. Fortunately, the line numbers will still reflect the static functions. The important parts of the public function information are the function names and the information in the Rva+Base column, which is the starting address of the function.

Collapse | Copy Code
  Address         Publics by Value              Rva+Base     Lib:Object

 0001:00000000       _WinMain@16                00401000 f   MAPFILE.obj
 0001:000000c0       ?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z 004010c0 f   MAPFILE.obj
 0001:00000150       ?InitInstance@@YAHPAUHINSTANCE__@@H@Z 00401150 f   MAPFILE.obj
 0001:000001b0       ?WndProc@@YGJPAUHWND__@@IIJ@Z 004011b0 f   MAPFILE.obj
 0001:00000310       ?About@@YGJPAUHWND__@@IIJ@Z 00401310 f   MAPFILE.obj
 0001:00000350       _WinMainCRTStartup         00401350 f   LIBC:wincrt0.obj
 0001:00000446       __amsg_exit                00401446 f   LIBC:wincrt0.obj
 0001:0000048f       __cinit                    0040148f f   LIBC:crt0dat.obj
 0001:000004bc       _exit                      004014bc f   LIBC:crt0dat.obj
 0001:000004cd       __exit                     004014cd f   LIBC:crt0dat.obj
 0001:00000591       __XcptFilter               00401591 f   LIBC:winxfltr.obj
 0001:00000715       __wincmdln                 00401715 f   LIBC:wincmdln.obj
 //SNIPPED FOR BETTER READING
 0003:00002ab4       __FPinit                   00408ab4     <common>
 0003:00002ab8       __acmdln                   00408ab8     <common>

 entry point at        0001:00000350

 Static symbols

 0001:000035d0       LeadUp1                    004045d0 f   LIBC:memmove.obj
 0001:000035fc       LeadUp2                    004045fc f   LIBC:memmove.obj
  //SNIPPED FOR BETTER READING
 0001:00000577       __initterm                 00401577 f   LIBC:crt0dat.obj
 0001:0000046b       _fast_error_exit           0040146b f   LIBC:wincrt0.obj

The public function part is followed by the line information (you got this if you used the /MAPINFO:LINES in the Link tab and selected the "Line numbers" in the C/C++ tab). After this, you will get the export information if your project contains exported functions and you included /MAPINFO:EXPORTS in the link tab.

Collapse | Copy Code
Line numbers for ./Release/MAPFILE.obj(F:/MAPFILE/MAPFILE.cpp) segment .text

    24 0001:00000000    30 0001:00000004    31 0001:0000001b    32 0001:00000027
    35 0001:0000002d    53 0001:00000041    40 0001:00000047    43 0001:00000050
    45 0001:00000077    47 0001:00000088    48 0001:0000008f    52 0001:000000ad
    53 0001:000000b3    71 0001:000000c0    80 0001:000000c3    81 0001:000000c8
    82 0001:000000ff    86 0001:00000114    88 0001:00000135    89 0001:00000145
   102 0001:00000150   108 0001:00000155   110 0001:00000188   122 0001:0000018d
   115 0001:0000018e   116 0001:0000019a   119 0001:000001a1   121 0001:000001a8
   122 0001:000001ae   135 0001:000001b0   143 0001:000001cc   172 0001:000001ee
   175 0001:0000020d   149 0001:00000216   157 0001:0000022c   175 0001:00000248
   154 0001:00000251   174 0001:0000025f   175 0001:00000261   151 0001:0000026a
   174 0001:00000287   175 0001:00000289   161 0001:00000294   164 0001:000002a8
   165 0001:000002b6   166 0001:000002d8   174 0001:000002e7   175 0001:000002e9
   169 0001:000002f2   174 0001:000002fa   175 0001:000002fc   179 0001:00000310
   186 0001:0000031e   193 0001:0000032e   194 0001:00000330   188 0001:00000333
   183 0001:00000344   194 0001:00000349

Now we will look up where the crash occurred. First, we'll determine which function contains the crash address. Look in the "Rva+Base" column and search the first function with an address bigger than the crash address. The preceding entry in the MAP file is the function that had the crash. In our example our crash address is 0x004011a1. This is between 0x00401150 and 0x004011b0 so we know the crash function is ?InitInstance@@YAHPAUHINSTANCE__@@H@Z . Any function name that starts with a question mark is a C++ decorated name. To translate the name, pass it as a command-line parameter to the Platform SDK program UNDNAME.EXE (in the bin dir). You won't need to do this most of the time as you might figure it out just by looking at it (here: InitInstance() in MAPFILE.obj).

This is a big step for bug tracking. But it gets even better: we can find out on which line the crash occurred! We need to do some basic hexadecimal mathematics, so people whom can't do this without a calculator: now is the time to use it. The first step is the following calculation: crash_address - preferred_load_address - 0x1000
Addresses are offsets from the beginning of the first code section, se we need to do this calculation. Subtracting the preferred load address is logical, but why do we need to substract another 0x1000? The crash address is an offset from the beginning of the code section, but the first part of the binary isn't the code section! The first part of the binary is the Portable Executable (PE), which is 0x1000 bytes long. Mystery solved. In our example, this is: 0x004011a1 - 0x00400000 - 0x1000 = 0x1a1

Now it's time to look in the line information section of the MAP file. The lines are shown like this: 30 0001:00000004. The first number is the line number, the second number is the offset from the beginning of the code section in which this line occurred. If we want to look for our line number, we just have to do the same thing we did for the function: determine the first occurrence of a bigger offset than the one we just calculated. The crash occurred in the preceding entry. In our example: 0x1a1 is before 0x1a8. So our crash occurred on line 119 in MAPFILE.CPP.

Keeping track of MAP files

Each release had it's own MAP file. It's not a bad idea to include the MAP file with the exe distribution. This way, you can be certain you have the correct MAP file for this exe. You could keep every MAP file with every exe on your system, but we all know this might give some troubles later on. The MAP file doesn't contain any information you wouldn't want the user to see (unless maybe class and function names ?) . A user would have no use with it, but at least you can ask for the MAP file if you don't have a copy yourself.

wallpaper_engine动态壁纸启动异常修复 WallPaper Engine(壁纸引擎)是steam上一款非常好玩的软件。它可以帮你把桌面壁纸换成动态效果,支持手动DIY作品,并且可通过创意工坊上传分享,是一个难得的优秀软件。小编整理了一些玩家上传的佳作,供有需要的玩家下载。 很多玩家在下载WallPaper Engine之后启动报DirectX错误问题。 立即下载

相关推荐

NFT图片批量合成及稀有度计算工具

一、制作背景 -当前NFT作品制作的大多方式都是使用部件拼接的形式,然后从大量的可能性结果取优; 二、解决问题 拼接合成的组合数量十分巨大,手工合成费时费力; 合成中对各个部件的使用次数不容易控制,部位出现的概率对作品的稀有度及评分影响较大; 对于生成的作品各个部位的信息(包括来源和使用率)统计繁琐,不利于对作品的介绍中体现; 三、程序功能介绍 1、功能自定义部位稀有度批量合成NFT作品 步骤一:创建各个合成部件文件夹,将图片放到文件夹内 步骤二:软件上设置各个部件对于的图片文件夹及出现的概率 步骤二

Keeping111的博客 4647

手动修复 rabbitmq 报错 “Crash dump is being written to“

(5) 查找 wal 文件路径,查找的路径来自步骤 (4)(3) 在 pod 节点上查看对应的物理设备。此步骤请慎重操作,建议将文件备份后再操作。(7) 删除 pod,重新启动 pod。(6) 删除 wal 文件。(4) 查看设备挂载目录。

Hello_NB1的博客 3724

DSP TMS320F280049之CCS工程的建立(库函数版)

TMS320F280049 DSP是TI最新出的一款C2000系列的DSP,主频为100MHZ,功能较为强大,具有较多的片上模拟外设。这一节主要讲述如何新建F280049的CCS工程。 Step1.下载文件: 下载C2000Ware软件并安装。下载地址如下: http://www.ti.com.cn/tool/cn/C2000WARE?keyMatch=C2000Ware%2...

fanxianyan1993的博客 1万+

Finding crash information using the MAP file 2

很奇怪,cppblog居然不能发表评论了,哭。。。所以就在发一篇了哦,呵呵。Finding crash information using the MAP filehttp://www.cppblog.com/jacky2019/archive/2007/04/09/21527.html上文中的关于小说明的第2点是有问题的偶又试了一次,发现lines number可能是有问题的,而且也不是我的

Kisser Loves C++ 938

在Ubuntu 18下安装SIMULIA Abaqus 2020

参考资料: https://github.com/imirzov/Install-Abaqus-2019-on-Ubuntu-18.04-LTS 安装环境: Ubuntu 18.4 LTS 软件版本: SIMULIA for Linux 2020 1 准备 安装光盘及破解文件 解压光盘至一目录,不能挂载,因为要修改文件内容 /home/sunwk/Downloads/abaqus2020 更改文件权限为最大 sudo chmod -R 777 abaqus2020/ * 复制libpng12

oak619的博客 1万+

stm32f103c8t6+esp8266在WiFi下通过手机控制外设

stm32f103c8t6+esp8266在WiFi下通过手机控制外设前言 前言 通过上一篇,介绍了esp8266的基本功能,这篇将用stm32c8t6配合esp8266进行数据交互,实现用手机通过无线的方式去控制外设、开关等;这里相当于把stm32作为上一篇的串口助手和esp8266进行通信; ...

weixin_45430735的博客 1万+

experiment:Finding crash information using the MAP file on vs2005

最近的工程在用vs2005进行调试, 现在可以Attach到Release版带调试符号的目标程序进行调试, 但是在非开发机上就没这条件了. 看了以下几篇资料, 做个实验. http://www.codeproject.com/KB/debug/mapfile.aspx?msg=1315494 Finding crash information using the MAP file h

博客标题不能为空 1850

数据产品需求文档(PRD)怎么写?阿里P8分享的模板+5个避坑点

作用:记录文档的版本、作者、评审信息,避免“文档混乱”。填写规范字段说明示例文档名称清晰反映产品名称,如“用户行为分析平台PRD”用户行为分析平台PRD_V1.0文档版本用“版本号+日期”,如V1.0_20240301编写人数据产品经理姓名+联系方式张三(138-XXXX-XXXX)评审人员业务负责人、开发经理、数据分析师、运维负责人李四(业务)、王五(开发)、赵六(数据)、周七(运维)评审时间评审日期2024-03-05评审意见。

架构师的AI之路,分享AI应用开发架构的学习与实践。 1586

How to handle crash problem?(2.Finding crash information using the MAP file 2)

本文转载,   Finding crash information using the MAP file 2 收藏 很奇怪,cppblog居然不能发表评论了,哭。。。所以就在发一篇了哦,呵呵。 Finding crash information using the MAP file http://www.cppblog.com/jacky2019/archive/2007/04/09/21527.html 上文中的关于小说明的第2点是有问题的 偶又试了一次,发现lines number

damoguyan8844的专栏 446

Windows服务器XMRig挖矿病毒深度清除实战指南

XMRig是一种广泛用于Monero(XMR)加密货币挖矿的开源工具,其在Windows环境中的持久化机制已远超传统木马范畴,融合WMI事件订阅、服务伪装、PowerShell无文件执行与注册表隐写等多重反检测技术。理解其基于行为而非特征的生存逻辑,是实现有效检测与根除的前提。该技术具备强隐蔽性、高自愈性与网络通信合法化特征,常见于RDP弱口令爆破、SMB共享泄露及PowerShell远程执行等非漏洞类入侵场景。本文聚焦Windows原生命令与Sysinternals工具链,提供覆盖进程定位、WMI清理、服

weixin_30535843的博客 741

CDD数据库文件制作(三)——服务配置(0x10)

根据诊断调查表进行每一步配置的详细操作,与背后逻辑解释 1.会话切换配置 1.1.根据诊断调查表进行信息提取(0x1001) 1.2.会话转换配置(0x1001) 1.3.根据诊断调查表进行信息提取(0x1002) 1.4.会话转换配置(0x1002) 1.5.根据诊断调查表进行信息提取(0x1003) 1.6.会话转换配置(0x1003) 1.7.会话切换配置完成后效果图 2.安全等级配置信息提取 2.1.安全访问配置(0x1001) 2.2.安全访问配置(0x1002) 2.3.安全访问配置(0x100

LOVE135149的博客 5847

iOS调优 | 深入理解Link Map File

Link Map File初识 我们编写的源码需要经过编译、链接,最终生成一个可执行文件。在编译阶段,每个类会生成对应的.o文件(目标文件)。在链接阶段,会把.o文件和动态库链接在一起。Link Map File就是这样一个记录链接相关信息的纯文本文件,里面记录了可执行文件的路径、CPU架构、目标文件、符号等信息。 为什么要理解Link Map File 理解Link Map File,可以...

Kiven's Program Space 1160

k8s篇之underlay网络和overlay区别

underlay和overlay

小橙子的笔记屋 2145

C++ 利用 windbg + dump + map + cod 文件分析 crash 原因

目录如何生成 dump 文件如何生成 map 文件VS生成cmake 命令如何生成 cod 文件VS 生成cmake 命令找 crash 地址step 1step2step3附 写代码路上踩过的坑,特此记录,以免忘记 网上全部都是有 pdb 文件。Release 没有 pdb 文件。本文适用于没有 pdb 文件,如何定位 如何生成 dump 文件 作为一个程序员,必现的 bug 容易排查,最怕遇见非必现 bug,尤其是那种在自己环境上测多少次都没问题,到用户环境偶尔会 crash,无从下手,让人瞬间抓狂。并

The Laughing Uncle的博客 1795

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

kdump crash

查看kdump状态为failed。 重启kdump服务失败,原因未知。 安装crash:sudo yum install crash 运行测试: [yubo.wang@localhost 4g-box]$ sudo crash a.out [sudo] password for yubo.wang: crash 7.2.3-8.el7 Copyright (C) 200...

TSZ0000的博客 1765

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

crash utility help page: kmem

crash utility help page: kmem NAME kmem - kernel memory内核内存 SYNOPSIS kmem [-f|-F|-c|-C|-i|-v|-V|-n|-z|-o|-h] [-p | -m member[,member]] [[-s|-S|-r] [slab] [-I slab[,slab]]] [-g [fla...

mounter625的专栏 1034

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Release版本程序定位Crash位置

Carsh 一、崩溃地址+MAP文件+COD文件 1. 生成应用程序MAP文件 MAP 文件是程序的全局符号、源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方、任何时候使用,不需要有额外的程序进行支持。而且,这是唯一能找出程序崩溃的地方的救星。   1.1 VC生成MAP文件 我们可以按下 Alt+F7 ,打开“Project Settings”选项页,选择 C/C++ 选项

b711183612的专栏 1084

jvm crash 的崩溃日志详细分析及注意点

生成 1. 生成error 文件的路径:你可以通过参数设置-XX:ErrorFile=/path/hs_error%p.log, 默认是在java运行的当前目录 [default: ./hs_err_pid%p.log] 2. 参数-XX:OnError  可以在crash退出的时候执行命令,格式是-XX:OnError=“string”,   可以是命令的集合,用分号做分隔符, 可以用"%p

沧海一粟 5万+
上一篇: ACM小技巧
下一篇: Ubantu10.04 不能升级解决办法
zh852
博客等级 码龄17年 64粉丝 10原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值