(EDIT: per the first answer below the current "trick" seems to be using an Atom processor. 
But I hope some gdb guru can answer if this is a fundamental limitation, or whether there adding support for other processors is on the roadmap?) Reverse execution seems to be working in my environment: I can reverse-continue, see a plausible record log, and move around within it: (gdb) start
...Temporary breakpoint at 0x8048460: file bang.cpp, line .
Starting program: /home/thomasg/temp/./bang Temporary breakpoint , main () at bang.cpp:
f();
(gdb) record
(gdb) continue
Continuing. Breakpoint , f (d=) at bang.cpp:
if(d) {
(gdb) info record
Active record target: record-full
Record mode:
Lowest recorded instruction number is .
Highest recorded instruction number is .
Log contains instructions.
Max logged instructions is .
(gdb) reverse-continue
Continuing. Breakpoint , f (d=) at bang.cpp:
if(d) {
(gdb) record goto end
Go forward to insn number
# f (d=) at bang.cpp:
if(d) {
However the instruction and function histories aren't available: (gdb) record instruction-history
You can't do that when your target is `record-full'
(gdb) record function-call-history
You can't do that when your target is `record-full'
And the only target type available is full, the other documented type "btrace" fails with "Target does not support branch tracing." So quite possibly it just isn't supported for this target, but as it's a mainstream modern one
(gdb 7.6.-ubuntu, on amd64 Linux Mint "Petra" running an "Intel(R) Core(TM) i5-3570") I'm hoping that I've overlooked a crucial step or config?
t seems that there is no other solution except a CPU that supports it.

More precisely, your kernel has to support Intel Processor Tracing (Intel PT). This can be checked in Linux with:

grep intel_pt /proc/cpuinfo
See also: http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean The commands only works in record btrace mode. In the GDB source commit beab5d9, it is nat/linux-btrace.c:kernel_supports_pt that checks if we can enter btrace. The following checks are carried out: check if /sys/bus/event_source/devices/intel_pt/type exists and read the type
do a syscall (SYS_perf_event_open, &attr, child, -, -, ); with the read type, and see if it returns >=. TODO: why not use the C wrapper?
The first check fails for me: the file does not exist. Kernel side cd into the kernel 4.1 source and: git grep '"intel_pt"'
we find arch/x86/kernel/cpu/perf_event_intel_pt.c which sets up that file. In particular, it does: if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
goto fail;
so intel_pt is a pre-requisite. How I've found kernel_supports_pt First grep for: git grep 'Target does not support branch tracing.'
which leads us to btrace.c:btrace_enable. After a quick debug with: gdb -q -ex start -ex 'b btrace_enable' -ex c --args /home/ciro/git/binutils-gdb/install/bin/gdb --batch -ex start -ex 'record btrace' ./hello_world.out
Virtual box does not support it either: Extract execution log from gdb record in a VirtualBox VM Intel SDE Intel SDE 7.21 already has this CPU feature, checked with: ./sde64 -- cpuid | grep 'Intel processor trace'
But I'm not sure if the Linux kernel can be run on it:
http://superuser.com/questions/950992/how-to-run-the-linux-kernel-on-intel-software-development-emulator-sde Other GDB methods See: gdb - list of all function calls made in an application
At least a partial answer (for the "am I doing it wrong" aspect) - from gdb-7.6.50.20140108/gdb/NEWS

* A new record target "record-btrace" has been added.  The new target
uses hardware support to record the control-flow of a process. It
does not support replaying the execution, but it implements the
below new commands for investigating the recorded execution log.
This new recording method can be enabled using: record btrace The "record-btrace" target is only available on Intel Atom processors
and requires a Linux kernel 2.6. or later. * Two new commands have been added for record/replay to give information
about the recorded execution without having to replay the execution.
The commands are only supported by "record btrace". record instruction-history prints the execution history at
instruction granularity record function-call-history prints the execution history at
function granularity
It's not often that I envy the owner of an Atom processor ;-) I'll edit the question to refocus upon the question of workarounds or plans for future support.

在GDB 中如何记录 instruction-history and function-call-history的更多相关文章

  1. 新手如何在gdb中存活

    网络上已经有很多gdb调试的文章了,为什么我还要写这篇文章呢,因为本文是写给gdb新手的,目的就是通过一个简单的例子来让新手很快上手.一旦上手入门了,其他的问题就可以自己去搜索搞定了.右边是gdb的L ...

  2. GDB中汇编调试

    GDB中汇编调试 1.输入代码 2.使用gcc - g example.c -o example -m32指令在64位的机器上产生32位汇编,时遇到问题使用-m32指令报错,参考卢肖明同学博客知道这是 ...

  3. history 清空历史记录 或 history不记录历史命令

    # vi ~/.bash_history 清空里面的记录,并退出当前shell # exit(一定要退出当前shell) # history 1 vi ~/.bash_history 2 histor ...

  4. MYSQL操作数据表中的记录

    36:操作数据表中的记录插入记录   INSERT INTO 表名  VALUES();   或者INSERT 表名  VALUES();  UPDATE更新记录(单表更新)  DELETE删除记录( ...

  5. GDB中应该知道的几个调试方法 来自陈皓

    GDB中应该知道的几个调试方法 2011年2月10日陈皓发表评论阅读评论62,325 人阅读   七.八年前写过一篇<用GDB调试程序>,于是,从那以后,很多朋友在MSN上以及给我发邮件询 ...

  6. Oracle数据库中有关记录个数的查询

    一.查询表中全部的记录个数 可用两种方法,一种是在oracle的系统表中统计,另一种需要写存储过程统计,方法分别如下. 1.系统表中统计: SELECT sum(num_rows) FROM user ...

  7. GDB中应该知道的几个调试方法

    七.八年前写过一篇<用GDB调试程序>,于是,从那以后,很多朋友在MSN上以及给我发邮件询问我关于GDB的问题,一直到今天,还有人在问GDB的相关问题.这么多年来,有一些问题是大家反复在问 ...

  8. 《转》GDB中应该知道的几个调试方法

    原文:http://coolshell.cn/articles/3643.html 七.八年前写过一篇<用GDB调试程序>,于是,从那以后,很多朋友在MSN上以及给我发邮件询问我关于GDB ...

  9. 【转贴】gdb中的信号(signal)相关调试技巧

    一篇不错的帖子,讲的是gdb中的信号(signal)相关调试技巧 转自Magic C++论坛  http://www.magicunix.com/index_ch.html  http://www.m ...

随机推荐

  1. 横向浅谈移动技术------( 原生,混合,web --- 谁能问鼎移动开发的明天)

    目前移动互联网基本采用了NativeApp.WebApp.HybridApp三种开发模式,很难说这三种模式那种更优越,目前的情况可以说是三分天下吧,不同的开发者可以根据自己的实际情况选择不同的开发模式 ...

  2. 移除Sourcesafe与VC6的绑定

    整理日: 2015年2月16日 HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Source Control\Disabled

  3. constant属性详解

    /**是否使用开发模式,不在开发模式下变为false*/ (常用) <constant name = "struts.devmode" value = "true& ...

  4. [BZOJ 3564] [SHOI2014] 信号增幅仪 【最小圆覆盖】

    题目链接:BZOJ - 3564 题目分析 求最小椭圆覆盖,题目给定了椭圆的长轴与 x 轴正方向的夹角,给定了椭圆长轴与短轴的比值. 那么先将所有点旋转一个角度,使椭圆长轴与 x 轴平行,再将所有点的 ...

  5. ios7新特性3-Map Kit新特性

    Map Kit 框架 (MapKit.framework) 包含了大量的改进以及为基于地图的程序提供了新特性.利用地图显示位置信息的应用现在可以使用Maps这个程序用到的3D地图,包括控制程序控制视线 ...

  6. Android GradientDrawable类的详解,设置activity的背景颜色渐变效果

    看到这个例子的标题RoundRects,我的第一感觉是介绍RoundRectShape, 打开例子看了代码却是使用GradientDrawable来实现的. GradientDrawable 支持使用 ...

  7. Storm学习笔记

    1.如何让一个spout并行读取多个流? 方法:任何spout.bolts组件都可以访问TopologyContext.利用这个特性可以让Spouts的实例之间划分流. 示例:获取到storm集群sp ...

  8. c++virtual inline 是否冲突

    关于inline关键字:effective c++ item33:明智运用inlining.说到:inline指令就像register指令一样,只是对编译器的一种提示,而不是一个强制命令,意思是编译器 ...

  9. bzoj1820

    水dp,状态表示三个司机当前在哪所用最小耗油,因为有一个一定在当前点所以可以压掉一维 ..,..] of longint;     a:..] of longint;     x,y,i,j,k,n, ...

  10. SolrJ总结

    1.solrJ概念 solrJ是Java连接solr进行查询检索和索引更新维护的jar包. 2.项目引入solrJ相关jar包 对于maven工程,直接将下面内容加入到pom文件中即可. <de ...