首页 技术 正文
技术 2022年11月16日
0 收藏 455 点赞 4,092 浏览 3797 个字
(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-meanThe 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 sidecd 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_ptFirst 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 VMIntel SDEIntel 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-sdeOther GDB methodsSee: 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 granularityrecord 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.
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,116
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,588
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,434
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,204
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,840
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,925