Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Christof Warlich <cwarlich@gmx.de>
To: gdb@gnu.org
Subject: using pipe with command
Date: Mon, 15 Jul 2019 20:35:00 -0000	[thread overview]
Message-ID: <e63777bb-0ac4-5d6b-026f-68b20036c8a1@gmx.de> (raw)

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





             reply	other threads:[~2019-07-15 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 20:35 Christof Warlich [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e63777bb-0ac4-5d6b-026f-68b20036c8a1@gmx.de \
    --to=cwarlich@gmx.de \
    --cc=gdb@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox