unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Miles Bader <miles.bader@necel.com>
Cc: emacs-devel@gnu.org
Subject: Re: My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments.
Date: Fri, 09 Mar 2007 17:08:16 +0200	[thread overview]
Message-ID: <uzm6mmp3z.fsf@gnu.org> (raw)
In-Reply-To: <buor6s02va5.fsf@dhapc248.dev.necel.com> (message from Miles Bader on Thu, 08 Mar 2007 13:50:42 +0900)

> From: Miles Bader <miles.bader@necel.com>
> Date: Thu, 08 Mar 2007 13:50:42 +0900
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> > If you use GCC, you are forced to debug and test with -O0, and then
> > ship a program compiled with -O2 which you didn't debug and test.
> 
> But that isn't true.  It sometimes takes extra work to debug because of
> optimization, but it's not some kind of impossible burden.

I submit that it _is_ an all but impossible burden, since even the
traceback shows many arguments passed to functions as "optimized
out".  How can you debug a program if you cannot see with what
arguments were the offending functions called?

And then there are functions that are inlined just because GCC thinks
it's a good idea, which defeats your ability to put breakpoints (GDB
will put a breakpoint where you asked it to, but the breakpoint will
never break).  Even without inlining, some code rearrangements also
make it impossible or at least impractical to put breakpoints on
source lines whose code happened to be rearranged.  A typical (but not
the only) example is that GCC folds several `return' statements into
one opcode; putting a breakpoint on all but a single `return' out of
all those that were folded runs a very high risk of not breaking.  The
only workaround is to disassemble and put breakpoints on addresses,
not source lines.  That is not my idea of source-level debugging.

Stepping is unreliable with rearranged code, and it's very easy to
miss that one step where the suspected code gets _really_ executed.

Etc., etc.  And this is with GCC and GDB, the two flagships of the GNU
project, which I once used to be proud of using, and proud of showing
off to users of other compilers.  How sad.

> > I couldn't convince GCC developers that debuggability is much more
> > important in the vast majority of cases than the extra 5%-7%
> > performance gains one gets by using all the tweaks -O2 does that
> > defeat debugging.  Sigh.
> 
> Convince them to do what?

To be user-friendlier to developers who want to debug optimized code.

> They give you a bazillion knobs which you can use to tune the
> tradeoffs made to your liking.

That argument is invalid.  First, there's no information in the GCC
documentation that tells you which debug problems can be solved by
what GCC switch.  Moreover, some of the above ``features'' cannot be
disabled individually, only by falling back on -O1 or -O0.

I once suggested something like -Odebug, but since GCC developers are
generally unsympathetic to the kind of gripes I presented, the
suggestion was hardly noticed, and I don't hold my breath to see it
implemented any time soon.

Nor do I have any reason to hope that the GCC manual will be fixed to
at least tell how to defeat the most wacky optimizations, in a way
that would make this information easily comprehended by someone who is
not a compiler expert, just a developer looking for ways to debug her
program.

> You can argue about the defaults, but -O2 _isn't the default_

The default is -O0, which is useless.  Did you ever look at the
horribly inefficient code produced by -O0?

Anyway, -O2 _is_, in fact, a kind of default, since most (if not all)
GNU packages use -O2 in their default builds.

  reply	other threads:[~2007-03-09 15:08 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06  6:30 My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Hongyi Zhao
2007-03-06  7:02 ` Kenichi Handa
2007-03-06  8:57   ` Hongyi Zhao
2007-03-06  8:06 ` Kenichi Handa
2007-03-06  8:41   ` Hongyi Zhao
2007-03-06 12:38     ` Kenichi Handa
2007-03-06 15:23       ` Hongyi Zhao
2007-03-06 14:10   ` David Kastrup
2007-03-07  1:01     ` Kenichi Handa
2007-03-07  2:37       ` Nick Roberts
2007-03-07  3:56         ` Hongyi Zhao
2007-03-07  4:01           ` Nick Roberts
2007-03-07  4:58             ` Hongyi Zhao
2007-03-07  5:10               ` Nick Roberts
2007-03-07  4:58           ` Kenichi Handa
2007-03-07  5:37             ` Display bug [Re: My Emacs unicode 2 crash again ...] Kenichi Handa
2007-03-07  6:26               ` Hongyi Zhao
2007-03-07  6:40                 ` Kenichi Handa
2007-03-07  7:38                   ` Hongyi Zhao
2007-03-07 17:26                 ` Richard Stallman
2007-03-08  3:50                   ` Hongyi Zhao
2007-03-08 21:47                     ` Richard Stallman
2007-03-07 17:25         ` My Emacs unicode 2 crash again when I do some *Replace String (M-%)*, I give the debug informations under gdb in the attachments Richard Stallman
2007-03-08  4:24           ` Eli Zaretskii
2007-03-08  4:50             ` Miles Bader
2007-03-09 15:08               ` Eli Zaretskii [this message]
2007-03-09 15:26                 ` Andreas Schwab
2007-03-09 15:51                   ` Eli Zaretskii
2007-03-09 15:56                   ` Eli Zaretskii
2007-03-09 21:26                 ` Richard Stallman
2007-03-10 19:18                   ` Eli Zaretskii
2007-03-09 22:59                 ` Stefan Monnier
2007-03-11 21:10                   ` Eli Zaretskii
2007-03-11 21:32                     ` David Kastrup
2007-03-11 21:56                       ` Eli Zaretskii
2007-03-11 21:59                         ` David Kastrup
2007-03-12  4:14                           ` Eli Zaretskii
2007-03-11 22:29                       ` Andreas Schwab
2007-03-12  6:11                         ` Stephen J. Turnbull
2007-03-12 22:08                           ` Eli Zaretskii
2007-03-13  3:36                             ` Stephen J. Turnbull
2007-03-13  7:54                               ` David Kastrup
2007-03-13 21:24                                 ` Eli Zaretskii
2007-03-12  7:04                         ` David Kastrup
2007-03-12 14:23                     ` Stefan Monnier
2007-03-12 21:50                       ` Eli Zaretskii
2007-03-13  1:33                         ` Stefan Monnier
2007-03-08  7:19             ` Stefan Monnier
2007-03-09 15:20               ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=uzm6mmp3z.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles.bader@necel.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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