public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/13000] New: Return value with -batch is always 0
@ 2011-07-13 20:44 michel.metzger at st dot com
  2014-06-25 12:23 ` [Bug gdb/13000] " tuben at lysator dot liu.se
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: michel.metzger at st dot com @ 2011-07-13 20:44 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13000

           Summary: Return value with -batch is always 0
           Product: gdb
           Version: 7.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: michel.metzger@st.com
              Host: pc-linux-gnu
            Target: i686


The documentation states -batch has the following effect:
"Exit with status 0 after processing all the command files specified with `-x'
(and all commands from initialization files, if not inhibited with `-n'). Exit
with nonzero status if an error occurs in executing the gdb commands in the
command files."

The following test demonstrates that it is in fact not the case:

$ gdb -batch -x "gdb.script"

with a file gdb.script containing the line:
file toto

(of course toto doesn't exist, to raise an error).

The output is:
gdb.script:1: Error in sourced command file:
toto: No such file or directory.

Displaying the exit status shows that is is in fact 0.
$ echo $?
0

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug gdb/13000] Return value with -batch is always 0
  2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
@ 2014-06-25 12:23 ` tuben at lysator dot liu.se
  2015-06-04 13:35 ` arma2ff0 at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tuben at lysator dot liu.se @ 2014-06-25 12:23 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=13000

Johan Tufvesson <tuben at lysator dot liu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tuben at lysator dot liu.se

--- Comment #1 from Johan Tufvesson <tuben at lysator dot liu.se> ---
I needed the documented behavior but failed because of this bug. I tried it on:
x86_64-linux-gnu version 7.4.1
sparc-sun-solaris2.10 version 6.3
host=i686-pc-mingw32 target=arm-none-eabi version 7.5.1
host=i686-mingw32 target=arm-none-eabi version 7.2

All with the same (bad) result.

Since the original bug is quite old, is there a work-around?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug gdb/13000] Return value with -batch is always 0
  2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
  2014-06-25 12:23 ` [Bug gdb/13000] " tuben at lysator dot liu.se
@ 2015-06-04 13:35 ` arma2ff0 at gmail dot com
  2015-06-04 13:51 ` arma2ff0 at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: arma2ff0 at gmail dot com @ 2015-06-04 13:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=13000

Armando <arma2ff0 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arma2ff0 at gmail dot com

--- Comment #2 from Armando <arma2ff0 at gmail dot com> ---
Same here. I tested it with gdb 7.9.1 on Archlinux on a x86_64 laptop.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug gdb/13000] Return value with -batch is always 0
  2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
  2014-06-25 12:23 ` [Bug gdb/13000] " tuben at lysator dot liu.se
  2015-06-04 13:35 ` arma2ff0 at gmail dot com
@ 2015-06-04 13:51 ` arma2ff0 at gmail dot com
  2015-06-04 18:12 ` dje at google dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: arma2ff0 at gmail dot com @ 2015-06-04 13:51 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=13000

Armando <arma2ff0 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|7.2                         |7.9

--- Comment #3 from Armando <arma2ff0 at gmail dot com> ---
By quick analysis, it looks like the problem resides at line main.c:1137 (I am
looking at the source-code in gdb 7.9.1). It looks to me that the error values
returned by the catch_command_errors_const is ignored. In case of errors, the
file is parsed until the end no matter what, and gdb returns always 0 because
the script was executed until the end.

As a consequence, I believe that quit_force should, at least, return the last
error returned by the catch_command_errors_const, or "1" in case of an error.

If you are interested, I could try to provide a patch.

Thanks && Cheers.
A.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug gdb/13000] Return value with -batch is always 0
  2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
                   ` (2 preceding siblings ...)
  2015-06-04 13:51 ` arma2ff0 at gmail dot com
@ 2015-06-04 18:12 ` dje at google dot com
  2015-06-05 11:50 ` arma2ff0 at gmail dot com
  2023-12-31 12:23 ` ssbssa at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: dje at google dot com @ 2015-06-04 18:12 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=13000

dje at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at google dot com

--- Comment #4 from dje at google dot com ---
*** Bug 18488 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug gdb/13000] Return value with -batch is always 0
  2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
                   ` (3 preceding siblings ...)
  2015-06-04 18:12 ` dje at google dot com
@ 2015-06-05 11:50 ` arma2ff0 at gmail dot com
  2023-12-31 12:23 ` ssbssa at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: arma2ff0 at gmail dot com @ 2015-06-05 11:50 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=13000

--- Comment #5 from Armando <arma2ff0 at gmail dot com> ---
Created attachment 8343
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8343&action=edit
Attempt to fix the -batch issue

I am uploading an example of what could, in principle, fix the issue at least
in this case. I have tested the patch only on my laptop (Archlinux, x86_64) so
I do not pretend this is a general and acceptable solution. However, it should
help to prove my point.

I hope this can help further investigation in the issue.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug gdb/13000] Return value with -batch is always 0
  2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
                   ` (4 preceding siblings ...)
  2015-06-05 11:50 ` arma2ff0 at gmail dot com
@ 2023-12-31 12:23 ` ssbssa at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ssbssa at sourceware dot org @ 2023-12-31 12:23 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=13000

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |8.3
                 CC|                            |ssbssa at sourceware dot org

--- Comment #7 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to Sourceware Commits from comment #6)
> The master branch has been updated by Gary Benson <gary@sourceware.org>:
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=b0f492b90f3d13da8ac80437e6ecb9a87db4a75b
> 
> commit b0f492b90f3d13da8ac80437e6ecb9a87db4a75b
> Author: Gary Benson <gbenson@redhat.com>
> Date:   Wed Aug 29 16:11:50 2018 +0100
> 
>     Indicate batch mode failures by exiting with nonzero status
>     
>     This commit causes GDB in batch mode to exit with nonzero status
>     if the last command to be executed fails.
>     
>     gdb/ChangeLog:
>     
>     	PR gdb/13000:
>     	* gdb/main.c (captured_main_1): Exit with nonzero status
>     	in batch mode if the last command to be executed failed.
>     	* NEWS: Mention the above.
>     
>     gdb/testsuite/ChangeLog:
>     
>     	PR gdb/13000:
>     	* gdb.base/batch-exit-status.exp: New file.
>     	* gdb.base/batch-exit-status.good-commands: Likewise.
>     	* gdb.base/batch-exit-status.bad-commands: Likewise.

Was fixed with this commit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2023-12-31 12:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 20:44 [Bug gdb/13000] New: Return value with -batch is always 0 michel.metzger at st dot com
2014-06-25 12:23 ` [Bug gdb/13000] " tuben at lysator dot liu.se
2015-06-04 13:35 ` arma2ff0 at gmail dot com
2015-06-04 13:51 ` arma2ff0 at gmail dot com
2015-06-04 18:12 ` dje at google dot com
2015-06-05 11:50 ` arma2ff0 at gmail dot com
2023-12-31 12:23 ` ssbssa at sourceware dot org

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).