public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* using pipe with command
@ 2019-07-15 20:35 Christof Warlich
  2019-07-28 22:13 ` Philippe Waroquiers
  0 siblings, 1 reply; 5+ messages in thread
From: Christof Warlich @ 2019-07-15 20:35 UTC (permalink / raw)
  To: gdb

Hi,

I just got quite exited when I saw the newly introduced "pipe" command.
But a closer look reveals that it does somewhat only work
"occasionally". Fortunately, "occasionally" here means that the issue is
at least reproducible. Here are some examples that show the problem.
Note that the code (of GNU make) that I'm using is compiled with "-f 
instrument-function" with appropriate function definitions. But I'd
assume that the issue occurs with any code being debugged.

In the following example, file "xxx" remains empty, although it should
contain the output of the "up" command:

    ...
    Reading symbols from make...
    (gdb) b __cyg_profile_func_enter
    Breakpoint 1 at 0x41d6d5: file src/main.c, line 54.
    (gdb) command 1
    Type commands for breakpoint(s) 1, one per line.
    End with a line saying just "end".
     >pipe up | cat - >xxx
     >end
    (gdb) run
    Starting program: /home/christof/Local/Repos/make/make

    Breakpoint 1, __cyg_profile_func_enter (func_address=0x41df5d
    <main>, call_site=0x7ffff7801b97 <__libc_start_main+231>) at
    src/main.c:54
    54    }
    #1  0x000000000041dfa1 in main (argc=1, argv=0x7fffffffe0c8,
    envp=0x7fffffffe0d8) at src/main.c:1074
    1074    {
    (gdb) !cat xxx
    (gdb)

Strange enough, almost the same setup works when replacing the "up"
command with the "bt" command: File xxx contains a backtrace as expected.

    ...
    Reading symbols from make...
    (gdb) b __cyg_profile_func_enter
    Breakpoint 1 at 0x41d6d5: file src/main.c, line 54.
    (gdb) command 1
    Type commands for breakpoint(s) 1, one per line.
    End with a line saying just "end".
     >pipe bt | cat - >xxx
     >end
    (gdb) run
    Starting program: /home/christof/Local/Repos/make/make

    Breakpoint 1, __cyg_profile_func_enter (func_address=0x41df5d
    <main>, call_site=0x7ffff7801b97 <__libc_start_main+231>) at
    src/main.c:54
    54    }
    (gdb) !cat xxx
    #0  __cyg_profile_func_enter (func_address=0x41df5d <main>,
    call_site=0x7ffff7801b97 <__libc_start_main+231>) at src/main.c:54
    #1  0x000000000041dfa1 in main (argc=1, argv=0x7fffffffe0c8,
    envp=0x7fffffffe0d8) at src/main.c:1074
    (gdb)


To make things even more weird, piping the output of the "up" command
directly (i.e. outside of the "command" command) works as well as expected:

    ...
    Reading symbols from make...
    (gdb) b __cyg_profile_func_enter
    Breakpoint 1 at 0x41d6d5: file src/main.c, line 54.
    (gdb) run
    Starting program: /home/christof/Local/Repos/make/make

    Breakpoint 1, __cyg_profile_func_enter (func_address=0x41df5d
    <main>, call_site=0x7ffff7801b97 <__libc_start_main+231>) at
    src/main.c:54
    54    }
    (gdb) pipe up | cat - >xxx
    (gdb) !cat xxx
    #1  0x000000000041dfa1 in main (argc=1, argv=0x7fffffffe0c8,
    envp=0x7fffffffe0d8) at src/main.c:1074
    1074    {
    (gdb)

I'm aware that the "pipe" command may still be "in development", but
maybe this early report may help to fix a lingering issue ... And I
certainly would be more than happy to test any patch :-).

Cheers,

Chris




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

end of thread, other threads:[~2019-11-24 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15 20:35 using pipe with command Christof Warlich
2019-07-28 22:13 ` Philippe Waroquiers
2019-07-29 19:32   ` Christof Warlich
2019-11-23 14:19     ` Philippe Waroquiers
2019-11-24 15:54       ` Christof Warlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).