Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14 15:12 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14 15:12 UTC (permalink / raw)
  To: chastain, ezannoni, kevinb; +Cc: fnasser, gdb-patches, keiths, msnyder

Kevin Buettner writes:

> I think the present behavior is acceptable.  It looks for malloc()
> anyway to see if it has snuck in via some other means; if it can't
> find it, it prints out a message to that effect.

OK with me.  I've never actually seen that message, but the code
in "fund_function_in_inferior" throws an error if the symbol is
not found:

  evaluation of this expression requires the program to have a function \"%s\".

Keith, are you getting these in your gdb.log?

> So...  what should become of callfwmall.exp?  As I recall, this test
> is identical to another test (callfuncs.exp) except that it simply
> lacks a call to malloc(), right?

Let me bust a diff:

  1c1
  < Running /vittone/fsf/2001-02-13/source-src/gdb/testsuite/gdb.base/callfuncs.exp ...
  ---
  > Running /vittone/fsf/2001-02-13/source-src/gdb/testsuite/gdb.base/callfwmall.exp ...
  7d6
  < PASS: next
  57d55
  < PASS: p t_call_add(add,3,4)
  58a57
  > PASS: p t_call_add(add,3,4)
  70d68
  < PASS: p cmp10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  78,86d75
  < PASS: gdb function calls preserve register contents
  < PASS: continue from call dummy breakpoint
  < PASS: bt after continuing from call dummy breakpoint
  < PASS: continue after stop in call dummy preserves register contents
  < PASS: finish from call dummy breakpoint returns correct value
  < PASS: bt after finishing from call dummy breakpoint
  < PASS: finish after stop in call dummy preserves register contents
  < PASS: back at main after return from call dummy breakpoint
  < PASS: return after stop in call dummy preserves register contents

Looks pretty subsetty to me.  Most of the differences are additions
to callfuncs.exp after callfwmall.exp was forked.

Somewhere we do need one test that builds an executable that does
not have malloc and then calls a function with implicit allocation --
to check that the error mechanism works properly.

> If that's the case, I think callfwmall.exp ought to go away.

I'm willing to file such a bug report.  Any objections?

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-16  9:48 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-16  9:48 UTC (permalink / raw)
  To: chastain, msnyder; +Cc: ac131313, fnasser, gdb-patches, jimb, keiths

Hi Michael,

> No, the check is not useful.  "call foo(10)" has nothing
> to do with malloc.

We've been through this.

How do you know that "call foo(10) does not use malloc"?
What is the source of your knowledge?

I know that "call foo(10) does not use malloc" because:

  . I inspected the code
  . I ran callfwmall.exp and it PASSed that test.

> Um -- Michael, did you get those two mixed up?

No.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-16  8:55 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-16  8:55 UTC (permalink / raw)
  To: chastain, jimb; +Cc: ac131313, fnasser, fnasser, gdb-patches, keiths

Hi Jim,

> So the real disagreement is whether this is a valuable thing to test
> for.  Since I cannot imagine any reasonable inferior function
> invocation mechanism that would rely on the existence of malloc, I
> think it's as useless to test for that as to test for, say, the
> ability of GDB to handle functions named `t_structs_i' (which
> callfwmall also tests for us!).

Ah, yeah, now we are talking about the same thing, just disagreeing.
Which is how I hope to leave it.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-16  8:41 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-16  8:41 UTC (permalink / raw)
  To: chastain, jimb; +Cc: ac131313, fnasser, gdb-patches, keiths

I was going to drop this, but ...

> This is irrelevant.  The GDB test suite exists to verify that GDB
> behaves as documented.  If a test checks for behavior which is not
> guaranteed, the test is in error, and should simply be removed.

callfwmalls.exp checks that "call foo(10)" works in a target program
that does not call malloc.  That check is useful.

It also checks that "call foo("bar")" works in a target program that
does not call malloc.  That check is useless.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15 19:05 Michael Elizabeth Chastain
  2001-02-16  8:36 ` Jim Blandy
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15 19:05 UTC (permalink / raw)
  To: chastain, jimb; +Cc: ac131313, fnasser, gdb-patches, keiths

[I thought about whether to reply to this ... I want to mention one data
 point, and that's all I will write].

Jim Blandy writes:
> Not if you link statically.

I did link statically.

  [chastain@delta chastain]$ cat bar.c
  main ()
  {
    write (1, "Howdy.\n", 7);
  }
  [chastain@delta chastain]$ gcc --version
  2.9-gnupro-99r1
  [chastain@delta chastain]$ gcc bar.c -o bar -g -static
  [chastain@delta chastain]$ gdb bar
  GNU gdb 4.18-gnupro-99r1
  Copyright 1998 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.  This version of GDB is supported
  for customers of Cygnus Solutions.  Type "show warranty" for details.
  This GDB was configured as "sparc-sun-solaris2.5"...
  (gdb) break main
  Breakpoint 1 at 0x101fc: file bar.c, line 3.
  (gdb) run
  Starting program: /home/chastain/bar 

  Breakpoint 1, main () at bar.c:3
  3         write (1, "Howdy.\n", 7);
  (gdb) write (1, "bye", 3);   
  Undefined command: "write".  Try "help".
  (gdb) call write (1, "bye", 3)
  bye$1 = 3
  (gdb) p malloc
  $2 = {<text variable, no debug info>} 0x140ac <malloc>

So malloc does get pulled in on my Solaris configuration.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15 12:58 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15 12:58 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, fnasser, gdb-patches, keiths

Fernando,

> And I think this thread is too long for such a small thing.
> I have better things to do.

Okay.  I give up, too.

> If this test file stays it will stay in its abbreviated form.

You're the maintainer.  You can do whatever you want to callfwmall.exp.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15 12:56 Michael Elizabeth Chastain
  2001-02-16  8:51 ` Jim Blandy
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15 12:56 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, fnasser, gdb-patches, keiths

Fernando,

chastain> How do you know whether calling an inferior function uses malloc or not?

fernando> If it does not call a string it does not.

This is a very literal question.

OK, so you know that when gdb calls an inferior function with no string
arguments (or arrays, or big structures, whatever), and the target
program does not itself call malloc(), that the call works properly.

*How* do you know?

I know because I ran callfwmall.exp, callfwmall.exp tested this behavior,
and told me that it PASSed.

I also know because I read the source code in gdb/valops.c, which is a
different avenue of knowledge.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15 12:30 Michael Elizabeth Chastain
  2001-02-15 12:48 ` Fernando Nasser
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15 12:30 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, fnasser, gdb-patches, keiths

Hi Fernando,

> And if he/she is a really good maintainer he/she will reject your patch
> as it would be adding a restriction to inferior function calls that we
> do not currently have.

This is bothering me.

I've seen some real "this is so embarrassing I should wear a brown
paper bag over my head" bugs:

  (gdb) set input-radix 2
  Input radix now set to decimal 4294967295, hex ffffffff, octal 37777777777.

Sorry if I make the author of that bug blush.   My point is that this
happens in software, and that it's the job of the test suite to detect
when it happens.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15 12:16 Michael Elizabeth Chastain
  2001-02-15 23:36 ` Eli Zaretskii
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15 12:16 UTC (permalink / raw)
  To: chastain, jimb; +Cc: ac131313, fnasser, gdb-patches, keiths

Hi Jim,

> I think it's simply a property of HP's system --- perhaps a
> characteristic of the dynamic linker, perhaps something else --- that
> malloc is always available to the debugger, whether the program uses
> it or not.

As Kevin Buettner pointed out, it's the normal behavior on Red Hat Linux
natives.

It's also the normal behavior on Solaris native.  (Tested on Solaris 2.6
native with 2.9-gnupro-99r1 and with Sun's cc 4.2).

It's the normal behavior on i586-sco-sysv5uw7.1.1, as shown in test
results where callfwmall.exp passes all its tests.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15 12:08 Michael Elizabeth Chastain
  2001-02-15 12:41 ` Fernando Nasser
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15 12:08 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, fnasser, gdb-patches, keiths

> Aren't we trying to be a little bit too pro-active here?  We are missing
> tests for things that are already in the code.  Adding tests for things
> that may or may not be in the code is somewhat new.

That's not pro-active.  callfwmall.exp already exists.  I'm explaining
what it tests, and why callfunc.exp does not test that.

> And if he/she is a really good maintainer he/she will reject your patch
> as it would be adding a restriction to inferior function calls that we
> do not currently have.

How do you know whether calling an inferior function uses malloc or not?

You know because callfwmall.exp tests it.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15  9:00 Michael Elizabeth Chastain
  2001-02-15 11:53 ` Fernando Nasser
  2001-02-15 11:56 ` Jim Blandy
  0 siblings, 2 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15  9:00 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, gdb-patches, keiths

> I don't get it.  malloc is not used at all when the argument is not a
> string.  So, what malloc() being available or not has to do with this
> situation?

The point is that use case #3 should keep working, even if
someone changes gdb.

Suppose I check in a patch tomorrow to allocate the call dummy in malloc'd
memory instead of the target's stack.

Would that be a problem?
If it is a problem, what test case can catch it?

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15  8:30 Michael Elizabeth Chastain
  2001-02-15  8:45 ` Fernando Nasser
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15  8:30 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, gdb-patches, keiths

Hi Fernando,

> Both Kevin and I are now proposing a minimal test for #4

Oops, I missed that in my recapitulation.  Yes, you are.

To be correct, that test should accept either "$1 = 3" or
"error: evalation ... requires ... "malloc"".

> (#3 does not depend on malloc() so it is already tested in callfuncs).

No.  Look at use case #3:

  Use case #3:

    . malloc is not available
    . the user types: call abs(-10)
    . gdb expected response: "$1 = 10"

callfuncs.c contains an explicit call to malloc.  Therefore, callfuncs.exp
does not check use case #3.  It checks use case #1.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15  7:54 Michael Elizabeth Chastain
  2001-02-15  8:09 ` Fernando Nasser
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15  7:54 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, gdb-patches, keiths

Hi Fernando,

> The other case to be tested is when there isn't a malloc() available at
> all (that is why the test Keith and you proposed is so nice).  But the
> FAILs are wrong.  Not having malloc() available is not GDB's fault and
> it may be just a limitation of the target environment.

I think there are four use cases.

Use case #1:

  . malloc is available
  . the user types: call abs(-10)
  . gdb expected response: "$1 = 10"

Use case #2:

  . malloc is available
  . the user types: call strlen("foo")
  . gdb expected response: "$1 = 3"

Use case #3:

  . malloc is not available
  . the user types: call abs(-10)
  . gdb expected response: "$1 = 10"

Use case #4:

  . malloc is not available
  . the user types: call strlen("foo")
  . gdb expected responses: either one of
    . "$1 = 3"
    . error: evaluation of this expression requires the program to have a function "malloc"

callfuncs.exp tests #1 and #2.
callfuncs.exp can never test #3 or #4.

callfwmall.exp, as written, tests use case #3 (on some platforms).

callfwmall.exp, as written, has an incorrect test for #4.  It accepts only
the first response, but gdb can produce either response, and the current
gdb produces the second response.

Keith's patch removes use case #4 from the test coverage.

Michael's patch makes callfwmall.exp verify that it gdb+inferior is in the
regime of #3 and #4.  If gdb+inferior is not, then callfwmall.exp returns
UNTESTED.  If gdb+inferior is in that regime (inferior has no malloc),
then it tests #3 only.  I could make it test #4 properly by adding more RE's.

Fernando's proposal is to remove coverage of #3 and #4.

Kevin's evidence is that Linux native, and probably every glibc platform,
never enters the regime of #3 and #4 anyways.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15  7:09 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15  7:09 UTC (permalink / raw)
  To: ac131313, fnasser; +Cc: ezannoni, fnasser, gdb-patches, keiths, kevinb, msnyder

Hi Fernando,

> Should we test GDB's ability to find malloc() from the shared libraries
> per se?  The little test code added by Keith and revamped by Michael
> could be used to do that.

Ah, I had that problem on hpux 10.20.  The section tables were messed up
and gdb was unable to call malloc().  It caused hundreds of FAILs.
So I think there is no need for a separate test.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-15  7:06 Michael Elizabeth Chastain
  2001-02-15  7:32 ` Fernando Nasser
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-15  7:06 UTC (permalink / raw)
  To: chastain, fnasser; +Cc: ac131313, gdb-patches, keiths

Hi Fernando,

> Unless the HP dependent code is capable of doing this, them we move it
> to gdb.hp with only the tests that are related to malloc() --

I can take care of this case.  If you look at valops.c, you can see that
there is no special code for hpux or any other target.  There is just one
implementation of value_allocate_space_in_inferior, and it always uses
"malloc".

I agree, if some target has special code, then it needs tests to
exercise the special code.

> But the reason we know that these tests will work without malloc() is
> because they independ on malloc().

So, suppose that next month someone changes call_function_by_hand so
that it always calls value_allocate_space_in_inferior.  callfuncs.exp
will not complain at all, but callfwmall.exp will raise a bunch of
FAILs.

That's what the test is for.  It tests that gdb can do "call foo(10)"
in a program that does not use malloc.  callfuncs.exp cannot test that.

> As there are no such targets I propose we get rid of callfwmall.exp.  I
> never liked the spelling anyway -- it is unpronounceable.

I'm not strongly attached to it.  It's OK with me if you kill it.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14 19:27 Michael Elizabeth Chastain
  2001-02-15  1:06 ` Fernando Nasser
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14 19:27 UTC (permalink / raw)
  To: ac131313, keiths; +Cc: gdb-patches

Here's a diff for consideration.

This script tests the following gdb features:

  [1] gdb can call functions in the inferior
  [2] gdb does not use the inferior's malloc to achieve feature [1].
      Thus, [1] works even for inferiors that have no malloc.

callfuncs.exp is incapable of testing [2] because it uses an inferior
program that is guaranteed to contain malloc.

If malloc is present in the inferior, then this script returns UNTESTED,
because it cannot verify [2] using this inferior program.  (Well,
it could, with enough work -- for instance, the script could set a
breakpoint on malloc and then FAIL if the breakpoint ever triggers).

If malloc is not present, the script proceeds to test a bunch of things
that we believe should work.  It does not test things that we know,
by design, don't work.

Keith, what do you think of this?  Does this work for you?

Michael

===

Index: callfwmall.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfwmall.exp,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 callfwmall.exp
*** callfwmall.exp	1999/09/09 00:00:21	1.1.1.3
--- callfwmall.exp	2001/02/15 03:18:14
*************** proc do_function_calls {} {
*** 169,183 ****
  
      gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
      gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
-     gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
-     gdb_test "p t_string_values(\"string 1\",string_val2)" " = 1"
-     gdb_test "p t_string_values(string_val1,\"string 2\")" " = 1"
  
      gdb_test "p t_char_array_values(char_array_val2,char_array_val1)" " = 0"
      gdb_test "p t_char_array_values(char_array_val1,char_array_val2)" " = 1"
-     gdb_test "p t_char_array_values(\"carray 1\",\"carray 2\")" " = 1"
-     gdb_test "p t_char_array_values(\"carray 1\",char_array_val2)" " = 1"
-     gdb_test "p t_char_array_values(char_array_val1,\"carray 2\")" " = 1"
  
      gdb_test "p doubleit(4)" " = 8"
      gdb_test "p add(4,5)" " = 9"
--- 169,177 ----
*************** proc do_function_calls {} {
*** 222,231 ****
      gdb_test "p t_enum_value2(enum_val2)" " = 1"
      gdb_test "p t_enum_value2(enum_val1)" " = 0"
  
-     gdb_test "p sum_args(1,{2})" " = 2"
-     gdb_test "p sum_args(2,{2,3})" " = 5"
-     gdb_test "p sum_args(3,{2,3,4})" " = 9"
-     gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
      gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
  
      gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
--- 216,221 ----
*************** if { $hp_aCC_compiler } {
*** 274,279 ****
--- 264,296 ----
  	    gdb_suppress_tests;
  	}
      }
+ }
+ 
+ # The point of this test script is to call a bunch of stuff in the inferior
+ # without using malloc in the inferior.  If malloc exists, then this test
+ # is pointless.
+ 
+ send_gdb "p malloc\n"
+ gdb_expect {
+   -re ".*No symbol \"malloc\".*$gdb_prompt $" {
+     # Cool, this is what I want.
+     pass "probe for malloc in inferior (malloc NOT present)"
+   }
+   -re ".*malloc.*$gdb_prompt $" {
+     untested "probe for malloc in inferior (malloc found, all tests skipped)"
+     remote_close host
+     return -1
+   }
+   -re ".*$gdb_prompt $" {
+     fail "probe for malloc in inferior"
+     remote_close host
+     return -1
+   }
+   timeout {
+     fail "probe for malloc in inferior (timeout)"
+     remote_class host
+     return -1
+   }
  }
  
  gdb_test "next" ".*"


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14 18:35 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14 18:35 UTC (permalink / raw)
  To: ac131313, chastain; +Cc: gdb-patches

Argh.  Let me say that again:

chastain> (1) Test for the presence of malloc the way Keith Seitz is doing
chastain>     (but put the test after runto_main).

cagney> it is testing exactly what it should be testing but the above would
cagney> disable malloc for this target.

I'm proposing that Keith move the "p malloc" line *after* the call
to "runto_main".  That would detect that malloc was available in the
inferior.

If malloc is available in the inferior, then callfwmall.exp should
stop execution.  If malloc is not available, then callfwmall.exp can
continue testing that gdb can make inferior calls in a target program
that does not have malloc.

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14 16:29 Michael Elizabeth Chastain
  2001-02-14 18:17 ` Andrew Cagney
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14 16:29 UTC (permalink / raw)
  To: gdb-patches

Another hour, another change of mind.

The point of callfwmall.exp is to show that gdb can call functions in
the inferior even if the inferior does not have "malloc".  callfuncs.exp
will never be able to do that.

So I think the right thing to do in callfwmall.exp is:

(1) Test for the presence of malloc the way Keith Seitz is doing
    (but put the test after runto_main).

(2) If malloc is present, disable the test script.

(3) If malloc is absent, go ahead and run the whole test script.

(4) Those lines like "call foo ("bar")" that do not work without malloc:

      send_gdb "call foo ("bar")\n"
      gdb_expect {
	-re "... works ok" ... {
	  pass ...
	}
	-re "unable to call target function 'malloc'" ... {
	  pass ...
	}
	default {
	  fail ...
	}
	timeout {
	  fail ... (timeout)
	}

In the interim, I'm in favor of Keith's patch (with the test after
runto_main).

Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14 14:17 Michael Elizabeth Chastain
  2001-02-14 14:37 ` Kevin Buettner
  0 siblings, 1 reply; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14 14:17 UTC (permalink / raw)
  To: ezannoni, kevinb; +Cc: fnasser, gdb-patches, keiths, msnyder

> There are a number of platforms which pass these tests, but only
> because malloc() is sneaks in because it's required by the dynamic
> linker.  If HPUX passes for a similar reason, this is cheating.  OTOH,
> if the HPUX port uses some other mechanism entirely, it might be a
> good idea for us to adapt this mechanism so that other targets can
> use it too.

I've got hpux scars all over my body which say that hpux 10.20 native
calls malloc() to do this.

I grepped around for "allocate_space_in_inferior" and it looks like the
malloc() call is the single hardwired implementation for every platform.
If that call doesn't work, gdb doesn't get the memory.

Forget the test script.  What should gdb do if:

  . I am on a platform with no malloc()
  . I type: print strlen("foo")

Should gdb have a target-specific mechanism to try?  For an embedded
target, it could have a scratch area which it manages itself.

And if there is no mechanism available, what should gdb print?

Michael


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14 13:41 Michael Elizabeth Chastain
  0 siblings, 0 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14 13:41 UTC (permalink / raw)
  To: fnasser, msnyder; +Cc: gdb-patches, keiths

> But how is it possible that GDB needs malloc() when the target does not
> have it?

(gdb) print strlen("foo")

GDB needs some mechanism to grab scratch memory in the target.
malloc() is the only mechanism that it has.

Michael

  /* gdb/valops.c */
  /* Allocate NBYTES of space in the inferior using the inferior's malloc
     and return a value that is a pointer to the allocated space. */

  value_ptr
  value_allocate_space_in_inferior (int len)
  {
    value_ptr blocklen;
    register value_ptr val = find_function_in_inferior ("malloc");

    blocklen = value_from_longest (builtin_type_int, (LONGEST) len);
    val = call_function_by_hand (val, 1, &blocklen);
    if (value_logical_not (val))
      {
	if (!target_has_execution)
	  error ("No memory available to program now: you need to start the target first");
	else
	  error ("No memory available to program: call to malloc failed");
      }
    return val;
  }


^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: [RFA] Assuming malloc exists in callfwmall.exp
@ 2001-02-14  9:06 Michael Elizabeth Chastain
  2001-02-14  9:07 ` Keith Seitz
  2001-02-14  9:11 ` Fernando Nasser
  0 siblings, 2 replies; 55+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-14  9:06 UTC (permalink / raw)
  To: gdb-patches, keiths

Hi Keith,

The idea looks good, but I see an implementation bug.  On a native
platform with shared libraries, "p malloc" fails because shared library
symbols are not available until the program starts running.

I'm seeing this on Red Hat Linux 7 native, FSF cvs gcc dated 2001-02-12,
FSF cvs gdb dated 2001-02-12 with some patches applied.

Can you move your "p malloc" test after the call to "runto_main"?

Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"

===

spawn /vittone/fsf/2001-02-12/gehman/build-src-native/gdb/testsuite/../../gdb/gdb -nw -nx ^M
GNU gdb 5.0^M
Copyright 2001 Free Software Foundation, Inc.^M
GDB is free software, covered by the GNU General Public License, and you are^M
welcome to change it and/or distribute copies of it under certain conditions.^M
Type "show copying" to see the conditions.^M
There is absolutely no warranty for GDB.  Type "show warranty" for details.^M
This GDB was configured as "i686-pc-linux-gnu".^M
(gdb) set height 0^M
(gdb) set width 0^M
(gdb) dir^M
Reinitialize source path to empty? (y or n) y^M
Source directories searched: $cdir:$cwd^M
(gdb) dir /vittone/fsf/2001-02-12/source-src/gdb/testsuite/gdb.base^M
Source directories searched: /vittone/fsf/2001-02-12/source-src/gdb/testsuite/gdb.base:$cdir:$cwd^M
(gdb) file /vittone/fsf/2001-02-12/gehman/build-src-native/gdb/testsuite/gdb.bas ^Me/callfwmall^M
Reading symbols from /vittone/fsf/2001-02-12/gehman/build-src-native/gdb/testsuite/gdb.base/callfwmall...done.^M
(gdb) set print sevenbit-strings^M
(gdb) PASS: gdb.base/callfwmall.exp: set print sevenbit-strings
set print address off^M
(gdb) PASS: gdb.base/callfwmall.exp: set print address off
set width 0^M
(gdb) PASS: gdb.base/callfwmall.exp: set width 0
p malloc^M
No symbol "malloc" in current context.^M


^ permalink raw reply	[flat|nested] 55+ messages in thread
[parent not found: <Pine.SOL.3.91.1010214082014.13194C-100000@ryobi.cygnus.com>]

end of thread, other threads:[~2001-02-16  9:48 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-14 15:12 [RFA] Assuming malloc exists in callfwmall.exp Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2001-02-16  9:48 Michael Elizabeth Chastain
2001-02-16  8:55 Michael Elizabeth Chastain
2001-02-16  8:41 Michael Elizabeth Chastain
2001-02-15 19:05 Michael Elizabeth Chastain
2001-02-16  8:36 ` Jim Blandy
2001-02-15 12:58 Michael Elizabeth Chastain
2001-02-15 12:56 Michael Elizabeth Chastain
2001-02-16  8:51 ` Jim Blandy
2001-02-15 12:30 Michael Elizabeth Chastain
2001-02-15 12:48 ` Fernando Nasser
2001-02-15 12:16 Michael Elizabeth Chastain
2001-02-15 23:36 ` Eli Zaretskii
2001-02-15 12:08 Michael Elizabeth Chastain
2001-02-15 12:41 ` Fernando Nasser
2001-02-15  9:00 Michael Elizabeth Chastain
2001-02-15 11:53 ` Fernando Nasser
2001-02-15 11:56 ` Jim Blandy
2001-02-15  8:30 Michael Elizabeth Chastain
2001-02-15  8:45 ` Fernando Nasser
2001-02-15  7:54 Michael Elizabeth Chastain
2001-02-15  8:09 ` Fernando Nasser
2001-02-15  7:09 Michael Elizabeth Chastain
2001-02-15  7:06 Michael Elizabeth Chastain
2001-02-15  7:32 ` Fernando Nasser
2001-02-14 19:27 Michael Elizabeth Chastain
2001-02-15  1:06 ` Fernando Nasser
2001-02-15  1:22   ` Fernando Nasser
2001-02-15  6:54     ` Kevin Buettner
2001-02-14 18:35 Michael Elizabeth Chastain
2001-02-14 16:29 Michael Elizabeth Chastain
2001-02-14 18:17 ` Andrew Cagney
2001-02-14 14:17 Michael Elizabeth Chastain
2001-02-14 14:37 ` Kevin Buettner
2001-02-14 13:41 Michael Elizabeth Chastain
2001-02-14  9:06 Michael Elizabeth Chastain
2001-02-14  9:07 ` Keith Seitz
2001-02-14  9:11 ` Fernando Nasser
     [not found] <Pine.SOL.3.91.1010214082014.13194C-100000@ryobi.cygnus.com>
2001-02-14  9:02 ` Fernando Nasser
2001-02-14 12:52   ` Michael Snyder
2001-02-14 13:10     ` Kevin Buettner
2001-02-14 13:28       ` Elena Zannoni
2001-02-14 13:41         ` Kevin Buettner
2001-02-14 14:00           ` Elena Zannoni
2001-02-14 20:13           ` Andrew Cagney
2001-02-15  1:14             ` Fernando Nasser
2001-02-15 10:34               ` Andrew Cagney
2001-02-14 14:33         ` Michael Snyder
2001-02-14 14:49           ` Elena Zannoni
2001-02-14 14:34       ` Michael Snyder
2001-02-14 13:12     ` Keith Seitz
2001-02-14 13:20     ` Fernando Nasser
2001-02-14 13:37       ` Stan Shebs
2001-02-14 13:46         ` Fernando Nasser
2001-02-14 14:35         ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox