Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* How to show instructions in one record
@ 2016-09-06 14:14 慕冬亮
  2016-09-06 14:59 ` Metzger, Markus T
       [not found] ` <20160906150017.GA22508@host1.jankratochvil.net>
  0 siblings, 2 replies; 6+ messages in thread
From: 慕冬亮 @ 2016-09-06 14:14 UTC (permalink / raw)
  To: gdb

Dear all,

I encounter the following problem when I show instructions in one record,

(gdb) b main
Breakpoint 1 at 0x80483f3: file simple.c, line 7.
(gdb) r
Starting program: /home/vagrant/simple/simple

Breakpoint 1, main (argc=1, argv=0xbffff7a4) at simple.c:7
7    crash = buff;
(gdb) record
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x08048420 in main (argc=1, argv=0xbffff7a4) at simple.c:10
10    for (p=buff,q=argv[1];(*q);p++,q++)
(gdb) record
btrace                 full                   goto
save
delete                 function-call-history  instruction-history
stop
(gdb) record instruction-history
You can't do that when your target is `record-full'

Then I try "record-core", the same result.
At last, I try "record-btrace", my system does not support branch tracing.
So how to show instructions in one record?

--
My best regards to you.

     No System Is Safe!
     Dongliang Mu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: How to show instructions in one record
  2016-09-06 14:14 How to show instructions in one record 慕冬亮
@ 2016-09-06 14:59 ` Metzger, Markus T
       [not found] ` <20160906150017.GA22508@host1.jankratochvil.net>
  1 sibling, 0 replies; 6+ messages in thread
From: Metzger, Markus T @ 2016-09-06 14:59 UTC (permalink / raw)
  To: mudongliangabcd, gdb

> -----Original Message-----
> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On
> Behalf Of ???
> Sent: Tuesday, September 6, 2016 4:14 PM
> To: gdb@sourceware.org
> Subject: How to show instructions in one record

Hello Dongliang,

> I encounter the following problem when I show instructions in one record,
> 
> (gdb) b main
> Breakpoint 1 at 0x80483f3: file simple.c, line 7.
> (gdb) r
> Starting program: /home/vagrant/simple/simple
> 
> Breakpoint 1, main (argc=1, argv=0xbffff7a4) at simple.c:7
> 7    crash = buff;
> (gdb) record
> (gdb) c
> Continuing.
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x08048420 in main (argc=1, argv=0xbffff7a4) at simple.c:10
> 10    for (p=buff,q=argv[1];(*q);p++,q++)
> (gdb) record
> btrace                 full                   goto
> save
> delete                 function-call-history  instruction-history
> stop
> (gdb) record instruction-history
> You can't do that when your target is `record-full'
> 
> Then I try "record-core", the same result.
> At last, I try "record-btrace", my system does not support branch tracing.
> So how to show instructions in one record?

The "record instruction-history" and "record function-call-history" commands
are only available for "record btrace" (and "record bts" and "record pt").

If you are using "record full" (or just "record"), you may use the "disassemble"
command to disassemble the current function and the "reverse-stepi" command
to step backwards through the recorded instructions.

Regards,
Markus.

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to show instructions in one record
       [not found] ` <20160906150017.GA22508@host1.jankratochvil.net>
@ 2016-09-06 15:43   ` 慕冬亮
  2016-09-06 16:04     ` Jan Kratochvil
  0 siblings, 1 reply; 6+ messages in thread
From: 慕冬亮 @ 2016-09-06 15:43 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb

2016-09-06 11:00 GMT-04:00 Jan Kratochvil <jan.kratochvil@redhat.com>:
> On Tue, 06 Sep 2016 16:13:52 +0200, 慕冬亮 wrote:
>> So how to show instructions in one record?
>
> I do not fully understand what "instructions in one record" mean but some
> demo:
>
I just want all the instructions which have already executed in one
execution path. Take the following demo as example,

What I need is the instruction list:

203             movq     %r9, 16(%rdi)
203             movq     %r9, 16(%rdi)
202             movq     %r8,  8(%rdi)
201             movq    %rax,   (%rdi)
199             movq    24(%rsi), %r10
198             movq    16(%rsi), %r9
......
If there are loops, I need all the instructions in the loop.
I don't know whether process record/replay could achieve this goal.

> (gdb) start
> [...]
> (gdb) record
> (gdb) c
> Continuing.
> Program received signal SIGINT, Interrupt.
> __memcpy_sse2 () at ../sysdeps/x86_64/memcpy.S:203
> 203             movq     %r9, 16(%rdi)
> (gdb) info record
> Active record target: record-full
> Record mode:
> Lowest recorded instruction number is 1.
> Highest recorded instruction number is 100092.
> Log contains 100092 instructions.
> Max logged instructions is 10000000.
> (gdb) reverse-stepi
> 203             movq     %r9, 16(%rdi)
> (gdb)
> 202             movq     %r8,  8(%rdi)
> (gdb)
> 201             movq    %rax,   (%rdi)
> (gdb)
> 199             movq    24(%rsi), %r10
> (gdb)
> 198             movq    16(%rsi), %r9
> (gdb) info record
> Active record target: record-full
> Replay mode:
> Lowest recorded instruction number is 1.
> Current instruction number is 100087.
> Highest recorded instruction number is 100092.
> Log contains 100092 instructions.
> Max logged instructions is 10000000.
> (gdb) frame
> #0  __memcpy_sse2 () at ../sysdeps/x86_64/memcpy.S:198
> 198             movq    16(%rsi), %r9
> (gdb) x/i $pc
> => 0x7ffff50311e9 <__memcpy_sse2+217>:  mov    0x10(%rsi),%r9
> (gdb) _


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to show instructions in one record
  2016-09-06 15:43   ` 慕冬亮
@ 2016-09-06 16:04     ` Jan Kratochvil
       [not found]       ` <CAD-N9QUaaNjG=rmH+PXyni=KBt7eNcbT54XhAr1bzCXb6KZoTw@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2016-09-06 16:04 UTC (permalink / raw)
  To: 慕冬亮; +Cc: gdb

On Tue, 06 Sep 2016 17:43:06 +0200, 慕冬亮 wrote:
> I just want all the instructions which have already executed in one
> execution path. Take the following demo as example,

One can do some:
	start
	record
	cont
	<ctrl-c>
	reverse-continue
	while 1
	stepi
	x/i $pc
	end


> What I need is the instruction list:
> 
> 203             movq     %r9, 16(%rdi)
> 203             movq     %r9, 16(%rdi)
> 202             movq     %r8,  8(%rdi)
> 201             movq    %rax,   (%rdi)
> 199             movq    24(%rsi), %r10
> 198             movq    16(%rsi), %r9
> ......
> If there are loops, I need all the instructions in the loop.
> I don't know whether process record/replay could achieve this goal.

But I think in thise case you should follow Markus Metzger's advice as the
output from 'record instruction-history' may be more appropriate for your
requirement.

Besides building GDB yourself you can use also Fedora 23 (and better Fedora
24) GDB which does have libipt support.

Be aware with btrace you cannot investigate any data or registers during the
recorded execution.


TBH I see this "display all recorded history" common request from GDB users
but IMO more effective approach is to place there watchpoints, breakpoints and
even breakpoint-attached command lists to catch the interesting moment during
execution.  The recorded history is huge and so one needs to filter it somehow
automatically afterwards anyway which the watchpoints solve on their own
already during execution.  Sure it may not be applicable for your case.


Jan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to show instructions in one record
       [not found]       ` <CAD-N9QUaaNjG=rmH+PXyni=KBt7eNcbT54XhAr1bzCXb6KZoTw@mail.gmail.com>
@ 2016-09-06 17:15         ` Jan Kratochvil
       [not found]           ` <CAD-N9QU4Ru6VDLB=bSQt5gpFN_YXgn+it3+PnW4rvYkoANVvNQ@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2016-09-06 17:15 UTC (permalink / raw)
  To: 慕冬亮; +Cc: gdb

On Tue, 06 Sep 2016 18:42:33 +0200, 慕冬亮 wrote:
> I am using Debian Testing which ships extremely new software and is
> rolling to some extent.

Both Debian Testing and Unstable have gdb_7.11.1-2 and there is nothing
related to libipt/intel-pt.  I also see no libipt support in
gdb_7.11.90.20160824-0ubuntu2.


> Debian has the support for libipt and I have installed this package.

GDB does not have support for dlopen of libipt, libipt (libipt-dev) must be
present already during GDB configure+build.

It is a bit interesting why Debian has packaged libipt as there is AFAIK no
other use for libipt than GDB (but I may be wrong).


Jan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to show instructions in one record
       [not found]           ` <CAD-N9QU4Ru6VDLB=bSQt5gpFN_YXgn+it3+PnW4rvYkoANVvNQ@mail.gmail.com>
@ 2016-09-06 17:35             ` Jan Kratochvil
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kratochvil @ 2016-09-06 17:35 UTC (permalink / raw)
  To: 慕冬亮; +Cc: gdb

On Tue, 06 Sep 2016 19:29:46 +0200, 慕冬亮 wrote:
> You mean I need to download the latest gdb and compile it with
> "--with-intel-pt" even if I have installed gdb, libipt and kernel 4.6 from
> Debian Software Repo?

Yes.


Jan


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-06 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 14:14 How to show instructions in one record 慕冬亮
2016-09-06 14:59 ` Metzger, Markus T
     [not found] ` <20160906150017.GA22508@host1.jankratochvil.net>
2016-09-06 15:43   ` 慕冬亮
2016-09-06 16:04     ` Jan Kratochvil
     [not found]       ` <CAD-N9QUaaNjG=rmH+PXyni=KBt7eNcbT54XhAr1bzCXb6KZoTw@mail.gmail.com>
2016-09-06 17:15         ` Jan Kratochvil
     [not found]           ` <CAD-N9QU4Ru6VDLB=bSQt5gpFN_YXgn+it3+PnW4rvYkoANVvNQ@mail.gmail.com>
2016-09-06 17:35             ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox