* [testsuite] Really ensure printf/fprintf are available in dprintf.exp
@ 2012-06-01 12:48 Yao Qi
2012-06-01 13:03 ` Pierre Muller
2012-06-06 8:55 ` [committed]: " Yao Qi
0 siblings, 2 replies; 4+ messages in thread
From: Yao Qi @ 2012-06-01 12:48 UTC (permalink / raw)
To: gdb-patches
I noticed some fails of gdb.base/dprintf.exp on tic6x-elf-gdb testing.
FAIL: gdb.base/dprintf.exp: 1st dprintf, call
FAIL: gdb.base/dprintf.exp: 2nd dprintf, call
caused by unable to find symbol "printf" and "malloc",
(gdb) continue
Continuing.
kickoff
also to stderr
No symbol "printf" in current context.
If printf/fprintf only prints constant string, compiler will replace
them to puts/fwrite respectively, and actual printf/fprintf is not
linked into executable. This problem should affect other ELF gdb.
This patch simply add extra parameter in printf/fprintf to make sure
they are linked, instead of puts/fwrite.
I'll apply it in two or three days if no comments.
gdb/testsuite:
2012-06-01 Yao Qi <yao@codesourcery.com>
* gdb.base/dprintf.c (main): Add extra parameter.
(bar): New function. It is a dead function, but to ensure
'malloc' is linked explicitly.
---
gdb/testsuite/gdb.base/dprintf.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/gdb.base/dprintf.c b/gdb/testsuite/gdb.base/dprintf.c
index 283ff58..8140a3e 100644
--- a/gdb/testsuite/gdb.base/dprintf.c
+++ b/gdb/testsuite/gdb.base/dprintf.c
@@ -33,8 +33,8 @@ main (int argc, char *argv[])
int loc = 1234;
/* Ensure these functions are available. */
- printf ("kickoff\n");
- fprintf (stderr, "also to stderr\n");
+ printf ("kickoff %d\n", loc);
+ fprintf (stderr, "also to stderr %d\n", loc);
foo (loc++);
foo (loc++);
@@ -42,3 +42,17 @@ main (int argc, char *argv[])
return g;
}
+#include <stdlib.h>
+/* Make sure function 'malloc' is linked into program. One some bare-mental
+ port, if we don't use 'malloc', it will not be linked in program. 'malloc'
+ is needed, otherwise we'll see such error message
+
+ evaluation of this expression requires the program to have a function
+ "malloc". */
+void
+bar (void)
+{
+ void *p = malloc (16);
+
+ free (p);
+}
--
1.7.0.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [testsuite] Really ensure printf/fprintf are available in dprintf.exp
2012-06-01 12:48 [testsuite] Really ensure printf/fprintf are available in dprintf.exp Yao Qi
@ 2012-06-01 13:03 ` Pierre Muller
2012-06-01 13:13 ` Yao Qi
2012-06-06 8:55 ` [committed]: " Yao Qi
1 sibling, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2012-06-01 13:03 UTC (permalink / raw)
To: 'Yao Qi', gdb-patches
> +#include <stdlib.h>
> +/* Make sure function 'malloc' is linked into program. One some
bare-mental
> + port, if we don't use 'malloc', it will not be linked in program.
'malloc'
Hi Yao,
I was just wondering if this is an expression that I do not know, or if
you simply meant 'bare-metal'?
Also, about the addition of
+#include <stdlib.h>
in the middle of the source, I also had the impression that
traditionally, C sources group all include's at the top of the source,
but remember that I only program in C for GDB and I am a pascal code
developer otherwise...
Pierre Muller
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [testsuite] Really ensure printf/fprintf are available in dprintf.exp
2012-06-01 13:03 ` Pierre Muller
@ 2012-06-01 13:13 ` Yao Qi
0 siblings, 0 replies; 4+ messages in thread
From: Yao Qi @ 2012-06-01 13:13 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
On 06/01/2012 09:02 PM, Pierre Muller wrote:
> I was just wondering if this is an expression that I do not know, or if
> you simply meant 'bare-metal'?
>
Hi Pierre,
I meant 'bare-metal'. It was a typo.
> Also, about the addition of
> +#include <stdlib.h>
> in the middle of the source, I also had the impression that
> traditionally, C sources group all include's at the top of the source,
> but remember that I only program in C for GDB and I am a pascal code
> developer otherwise...
Usually, if I include a header for a small piece of code, I prefer to
place the include near by my code. Otherwise, I'd like to put include
at the top of source. It is just my personal habit. Generally, either
should be OK.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [committed]: [testsuite] Really ensure printf/fprintf are available in dprintf.exp
2012-06-01 12:48 [testsuite] Really ensure printf/fprintf are available in dprintf.exp Yao Qi
2012-06-01 13:03 ` Pierre Muller
@ 2012-06-06 8:55 ` Yao Qi
1 sibling, 0 replies; 4+ messages in thread
From: Yao Qi @ 2012-06-06 8:55 UTC (permalink / raw)
To: gdb-patches
On 06/01/2012 08:48 PM, Yao Qi wrote:
> 2012-06-01 Yao Qi <yao@codesourcery.com>
>
> * gdb.base/dprintf.c (main): Add extra parameter.
> (bar): New function. It is a dead function, but to ensure
> 'malloc' is linked explicitly.
Patch attached is what I committed (with the typo fixed).
http://sourceware.org/ml/gdb-cvs/2012-06/msg00045.html
--
Yao (é½å°§)
2012-06-06 Yao Qi <yao@codesourcery.com>
* gdb.base/dprintf.c (main): Add extra parameter when calling
printf and fprintf.
(bar): New function. It is a dead function, but to ensure
'malloc' is linked explicitly.
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/dprintf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- src/gdb/testsuite/gdb.base/dprintf.c 2012/05/14 15:38:41 1.1
+++ src/gdb/testsuite/gdb.base/dprintf.c 2012/06/06 08:51:22 1.2
@@ -33,8 +33,8 @@
int loc = 1234;
/* Ensure these functions are available. */
- printf ("kickoff\n");
- fprintf (stderr, "also to stderr\n");
+ printf ("kickoff %d\n", loc);
+ fprintf (stderr, "also to stderr %d\n", loc);
foo (loc++);
foo (loc++);
@@ -42,3 +42,17 @@
return g;
}
+#include <stdlib.h>
+/* Make sure function 'malloc' is linked into program. One some bare-metal
+ port, if we don't use 'malloc', it will not be linked in program. 'malloc'
+ is needed, otherwise we'll see such error message
+
+ evaluation of this expression requires the program to have a function
+ "malloc". */
+void
+bar (void)
+{
+ void *p = malloc (16);
+
+ free (p);
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-06 8:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 12:48 [testsuite] Really ensure printf/fprintf are available in dprintf.exp Yao Qi
2012-06-01 13:03 ` Pierre Muller
2012-06-01 13:13 ` Yao Qi
2012-06-06 8:55 ` [committed]: " Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox