Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: Stephane Carrez <Stephane.Carrez@worldnet.fr>
Cc: Michael Snyder <msnyder@cygnus.com>,
	Keith Seitz <keiths@cygnus.com>,
	gdb-patches@sources.redhat.com
Subject: Re: [RFA]: Fix gdb.base/callfwmall.exp for platforms without malloc
Date: Mon, 21 May 2001 22:45:00 -0000	[thread overview]
Message-ID: <npg0dy7x7r.fsf@zwingli.cygnus.com> (raw)
In-Reply-To: <3B098795.1CD78B21@worldnet.fr>

Stephane Carrez <Stephane.Carrez@worldnet.fr> writes:
> Hum... if I understand, the only good fix is to fix GDB so that it
> no longer calls 'malloc'.  I would be very happy to see that fix in
> GDB.  You cannot rely on a possible 'malloc'.  I have two examples
> in mind here: 68HC11 programs and... ChorusOS kernel.
> 
> Do you have any patch or are you working on any fix so that GDB does
> not call 'malloc' any more?
> 
> For example, by allocating the string on the stack, as it does for
> the arguments.  Ok, it's more complex; you'll need a two-pass
> argument processing, one for string allocation, and one to really
> push the arguments.

That test file is a confused piece of code, and everyone who reads it
seems to get confused, too.  GDB can call any function just fine
without ever using malloc, and GDB may need to use malloc even when
the user has never entered a function call to evaluate.

GDB calls malloc in the inferior to evaluate even simple expressions
like this:

    (gdb) print str = "hi there"

(where `str' is a char *).  Allocating strings on the stack isn't an
acceptable implementation for uses like this: the inferior's code
might not be prepared to have its frame size changed, and you have no
way to know whether the string's lifetime is shorter than that of the
frame anyway.

Basically, in order to evaluate string literals, GDB must have some
reliable way to find storage in the inferior which will never be used
for anything else.  Calling malloc is one way to do this.  If malloc
isn't available, the target should provide an alternative, or GDB
should say, "Sorry, can't evaluate string literals on this target."

I think callfwmall.{exp,c} should simply be deleted.  They do a bad
job of testing functionality that GDB cannot promise to provide.  HP
created the test file because their run-time support is guaranteed to
include malloc; at the very least, callfwmall.{exp,c} should be moved
into gdb.hp.


  parent reply	other threads:[~2001-05-21 22:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3B07B042.6BAD93A0@worldnet.fr>
2001-05-21 10:43 ` Michael Snyder
2001-05-21 10:56   ` Keith Seitz
2001-05-21 11:10     ` Michael Snyder
2001-05-21 14:20       ` Stephane Carrez
2001-05-21 14:58         ` Michael Snyder
2001-05-21 22:45         ` Jim Blandy [this message]
2001-06-06  9:07         ` Andrew Cagney
2001-05-22  9:16 Michael Elizabeth Chastain

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=npg0dy7x7r.fsf@zwingli.cygnus.com \
    --to=jimb@zwingli.cygnus.com \
    --cc=Stephane.Carrez@worldnet.fr \
    --cc=gdb-patches@sources.redhat.com \
    --cc=keiths@cygnus.com \
    --cc=msnyder@cygnus.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox