Gdb Error Detected On Stdin
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up gdb pipe redirection Error: (gdb) Hangup detected on fd 0 up vote 2 down vote favorite 1 Help, how do i fix this? I am unable to redirect command from stdin to gdb. I get this error: charmae@charmae-pc:~/workspace/AVT$ echo "list" | gdb a.out GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /home/charmae/workspace/AVT/a.out...done. (gdb) Hangup detected on fd 0 error detected on stdin linux shell gdb pipe gnu share|improve this question asked Nov 14 '11 at 12:48 gcharmae 648429 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote Another technique that works nicely is to redirect input to gdb using a here-document: gdb -quiet -nx << EndOfInput thread apply all bt quit EndOfInput This makes it possible to write a script which controls gdb without having to use temporary files. It seems to avoid the "Hangup detected" message completely. share|improve this answer answered May 21 '12 at 21:49 Justin 212 add a comment| up vote 0 down vote If your goal is to execute the command "list" when gdb starts up, the easiest way to do that is to use a .gdbinit startup file. For example: $ echo list > .gdbinig $ gdb a.out If you want gdb to exit after running the commands listed in .gdbinit, do: $ echo quit >> .gdbinit share|improve this answer answered Nov 14 '11 at 13:30 William Pursell 93k21154199 My goal is to fix the error shown above.. I'm doing some piping between my java program and gdb, and i'm stuck with it. –gcharmae Nov 14 '11 at 14:30 The problem with the example is that you are closing stdin. If you can keep the pipe open, gdb will be happy. For example, (this is a terrible hack), you could do "tail -f
error detected on stdin From: Vikash Jain To: gdb at sourceware dot org Date: Tue, 24 May 2011 18:56:48 +0530 Subject: GDB: error detected on stdin Hi All, I'm trying to pipe commands to gdb but I get http://stackoverflow.com/questions/8121823/gdb-pipe-redirection-error-gdb-hangup-detected-on-fd-0 the following messages. Will it cause any problems? How do i resolve the same? (gdb) Hangup detected on fd 0 error detected on stdin Python Script ============ #!/usr/local/bin/python import subprocess proc=subprocess.Popen('gdb',shell=True,stdin=su bprocess.PIPE,stdout=subprocess.PIPE,executable="/usr/local/bin/bash") proc.stdin.write('help') output=proc.communicate()[0] print output https://sourceware.org/ml/gdb/2011-05/msg00126.html Script Log ========== [XXX@test ~/CAT/example]$ python -u main.py GNU gdb (GDB) 7.2.50.20110328-cvs Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i386-unknown-freebsd6.3". For bug reporting instructions, please see: . (gdb) Hangup detected on fd 0 error detected on stdin Best Regards Vikash Jain Follow-Ups: Re: GDB: error detected on stdin From: Andreas Schwab Index Nav: [DateIndex] [SubjectIndex] [AuthorIndex] [ThreadIndex] Message Nav: [DatePrev][DateNext] [ThreadPrev][ThreadNext]
GDB: error detected on stdin From: Andreas Schwab To: Vikash Jain Cc: gdb at sourceware dot org, gdb-patches at sourceware https://www.cygwin.com/ml/gdb/2011-05/msg00128.html dot org Date: Tue, 24 May 2011 16:31:42 +0200 Subject: Re: GDB: error detected on stdin References: Vikash Jain writes: > I'm trying to pipe commands to gdb http://gdb.sourceware.narkive.com/hrlWZrtN/gdb-error-detected-on-stdin but I get the following messages. > Will it cause any problems? How do i resolve the same? 2011-05-24 Andreas Schwab * event-loop.c (handle_file_event): Don't handle POLLHUP as gdb error error. --- event-loop.c.~1.49.~ 2011-03-22 11:59:52.000000000 +0100 +++ event-loop.c 2011-05-24 16:27:28.614311098 +0200 @@ -759,7 +759,6 @@ handle_file_event (event_data data) int mask; #ifdef HAVE_POLL int error_mask; - int error_mask_returned; #endif int event_file_desc = data.integer; @@ -783,22 +782,19 @@ handle_file_event (event_data data) if (use_poll) { #ifdef HAVE_POLL + /* POLLHUP means EOF, but can be combined with POLLIN to + signal gdb error detected more data to read. */ error_mask = POLLHUP | POLLERR | POLLNVAL; - mask = (file_ptr->ready_mask & file_ptr->mask) | - (file_ptr->ready_mask & error_mask); - error_mask_returned = mask & error_mask; + mask = file_ptr->ready_mask & (file_ptr->mask | error_mask); - if (error_mask_returned != 0) + if ((mask & (POLLERR | POLLNVAL)) != 0) { /* Work in progress. We may need to tell somebody what kind of error we had. */ - if (error_mask_returned & POLLHUP) - printf_unfiltered (_("Hangup detected on fd %d\n"), - file_ptr->fd); - if (error_mask_returned & POLLERR) + if (mask & POLLERR) printf_unfiltered (_("Error detected on fd %d\n"), file_ptr->fd); - if (error_mask_returned & POLLNVAL) + if (mask & POLLNVAL) printf_unfiltered (_("Invalid or non-`poll'able fd %d\n"), file_ptr->fd); file_ptr->error = 1; Andreas. -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." Follow-Ups: Re: GDB: error detected on stdin From: Tom Tromey References: GDB: error detected on stdin From: Vikash Jain Index Nav: [DateIndex] [SubjectIndex] [AuthorIndex] [ThreadIndex] Message Nav: [DatePrev][DateNext] [ThreadPrev][ThreadNext]
do i resolve the same?(gdb) Hangup detected on fd 0error detected on stdinPython Script============#!/usr/local/bin/pythonimport subprocessproc=subprocess.Popen('gdb',shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,executable="/usr/local/bin/bash")proc.stdin.write('help')output=proc.communicate()[0]print outputScript Log==========[***@test ~/CAT/example]$ python -u main.pyGNU gdb (GDB) 7.2.50.20110328-cvsCopyright (C) 2011 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "i386-unknown-freebsd6.3".For bug reporting instructions, please see:.(gdb) Hangup detected on fd 0error detected on stdinBest RegardsVikash Jain Andreas Schwab 2011-05-24 14:31:42 UTC PermalinkRaw Message Post by Vikash JainI'm trying to pipe commands to gdb but I get the following messages.Will it cause any problems? How do i resolve the same?2011-05-24 Andreas Schwab <***@redhat.com>* event-loop.c (handle_file_event): Don't handle POLLHUP as error.--- event-loop.c.~1.49.~ 2011-03-22 11:59:52.000000000 +0100+++ event-loop.c 2011-05-24 16:27:28.614311098 +0200@@ -759,7 +759,6 @@ handle_file_event (event_data data)int mask;#ifdef HAVE_POLLint error_mask;- int error_mask_returned;#endifint event_file_desc = data.integer;@@ -783,22 +782,19 @@ handle_file_event (event_data data)if (use_poll){#ifdef HAVE_POLL+ /* POLLHUP means EOF, but can be combined with POLLIN to+ signal more data to read. */error_mask = POLLHUP | POLLERR | POLLNVAL;- mask = (file_ptr->ready_mask & file_ptr->mask) |- (file_ptr->ready_mask & error_mask);- error_mask_returned = mask & error_mask;+ mask = f