Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
@ 2009-03-16 21:15 Jan Kratochvil
  2009-03-20 15:17 ` Joel Brobecker
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-16 21:15 UTC (permalink / raw)
  To: gdb-patches

Hi,

this patch is far from a perfect solution but it would be fine to check it in
if there is an approval as this patch is a regression-free GDB improvement:

for:
echo 'int main () { int x = 42; return x; }' | gcc -Wall -O2 -g -x c -

current GDB prints:
(gdb) p x
No symbol "x" in current context.
(gdb) ptype x
No symbol "x" in current context.

while patched GDB prints:
(gdb) p x
$1 = <value optimized out>
(gdb) ptype x
type = int

It can also happen for gcc-4.4 -O0 -g but that is more its bug (PR debug/39474).

With the current -O2 debugging situation I find the `No symbol ...' statements
even more confusing than pragmatic <value optimized out>.

Still this patch is just a fixup of the current incorrect GDB parsing code,
the proper solution should rewrite it from scratch.  But it has no regressions
on x86_64-unknown-linux-gnu so it is at least an improvement.

Existing problems even with this patch:

* zero-length DW_AT_location should be the same as missing DW_AT_location.
  https://fedorahosted.org/pipermail/elfutils-devel/2009-March/000180.html

  GCC seems to use zero-length DW_AT_location for optimized-out variables and
  no DW_AT_location if it fails to provide it for whatever reason.  But not
  always.

  If GDB would always use zero-length DW_AT_location for optimized-out symbols
  vs. no DW_AT_location for non-defining declarations this GDB patch would not
  be needed as this is the current (DWARF-noncompliant) GDB expectation.

* Missing DWARF3 2.13.2 Declarations Completing Non-Defining Declarations:
Current ignorance of LOC_OPTIMIZED_OUT symbols was used for C++ symbols
completion.  Fixing the LOC_OPTIMIZED_OUT symbols presents break C++ symbols
completion as the code then recognizes the first instance of the symbol (even
if it is LOC_OPTIMIZED_OUT) thus ignoring its later completion such as for:
 <3><247>: Abbrev Number: 18 (DW_TAG_variable)
    <248>   DW_AT_name        : cX
    <24d>   DW_AT_type        : <0xca>
    <251>   DW_AT_declaration : 1
 <1><5c5>: Abbrev Number: 37 (DW_TAG_variable)
    <5c6>   DW_AT_specification: <0x247>
    <5ca>   DW_AT_const_value : 6
The insert_symbol_hashed() part of the patch fixes up this specific case to
have no testsuite regressions on gcc.  Still a more general fix should be made.

* For external variables it still prints
    Address of symbol "foo" is unknown.
  while it should print
    <value optimized out>
  because (read_var_value <LOC_UNRESOLVED> <msym == NULL>) should return
  not_lval+set_value_optimized_out but providing such patch causes regression
  on other GDB C++ support code.

* The updated testcase is probably incompatible with Alpha (larger than 32bit
  file addresses), also it should test more types of symbol placements, `main'
  range is not correct, CU range is not correct etc.

Updated patch fixes for current GDB its new testcases:
FAIL: gdb.dwarf2/dw2-noloc.exp: print noloc_local  (file-scope optimized-out)
FAIL: gdb.dwarf2/dw2-noloc.exp: ptype noloc_local
FAIL: gdb.dwarf2/dw2-noloc.exp: print noloc_local2 (function-scope optimized-out)
FAIL: gdb.dwarf2/dw2-noloc.exp: ptype noloc_local2


Thanks,
Jan

gdb/
2009-03-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Recognize missing DW_AT_location as <value optimized out>.
	* dictionary.c (insert_symbol_hashed): New variables `iterp', `iter'.
	Remove non-defining declaration completed by later declarations.
	* dwarf2read.c
	(new_symbol <DW_TAG_variable> <!DW_AT_location> <!DW_AT_external>):
	Call add_symbol_to_list.

gdb/testsuite/
2009-03-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.dwarf2/dw2-noloc.exp: Compile main.c with nodebug.
	(print noloc): Rename to ...
	(print noloc_unresolvable): ... here.
	(print hasloc_direct, print hasloc_resolvable, print noloc_local)
	(print hasloc_direct2, print hasloc_resolvable2)
	(print noloc_unresolvable2, print noloc_local2): New.
	* gdb.dwarf2/dw2-noloc.S (main_end, hasloc_resolvable)
	(hasloc_resolvable2): New.
	(DW_AT_high_pc): Change it to `main_end'.
	(noloc): Rename to ...
	(noloc_unresolvable): ... here.
	(hasloc_direct, hasloc_resolvable, noloc_local, hasloc_direct2)
	(hasloc_resolvable2, noloc_unresolvable2, noloc_local2): New.

--- gdb/dictionary.c	3 Jan 2009 05:57:51 -0000	1.10
+++ gdb/dictionary.c	16 Mar 2009 18:18:49 -0000
@@ -670,10 +670,34 @@ insert_symbol_hashed (struct dictionary 
 		      struct symbol *sym)
 {
   unsigned int hash_index;
-  struct symbol **buckets = DICT_HASHED_BUCKETS (dict);
+  struct symbol **buckets = DICT_HASHED_BUCKETS (dict), **iterp, *iter;
 
   hash_index = (msymbol_hash_iw (SYMBOL_SEARCH_NAME (sym))
 		% DICT_HASHED_NBUCKETS (dict));
+
+  /* Remove non-defining declaration completed by later declarations
+     (DWARF3 2.13.2).  As there may be multiple symbols of the same
+     SYMBOL_SEARCH_NAME but different SYMBOL_CLASS replace only those that have
+     lower validity (in the order of LOC* > LOC_UNRESOLVED > LOC_OPTIMIZED_OUT).
+
+     dict_create_linear should also contain such code but the C++ declarations
+     completing in practice exists only for file/global symbols which are being
+     indexed only using this function insert_symbol_hashed.
+
+     As this function is called in a reverse order than the placement of the
+     symbols in the inferior the RETURN statement will ensure the symbol gets
+     replaced.  */
+
+  if (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT
+      || SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
+    for (iterp = &buckets[hash_index]; (iter = *iterp) != NULL;
+	 iterp = &iter->hash_next)
+      if (strcmp (SYMBOL_SEARCH_NAME (iter), SYMBOL_SEARCH_NAME (sym)) == 0
+	  && (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT
+	      || (SYMBOL_CLASS (sym) == LOC_UNRESOLVED
+		  && SYMBOL_CLASS (iter) == LOC_OPTIMIZED_OUT)))
+	return;
+
   sym->hash_next = buckets[hash_index];
   buckets[hash_index] = sym;
 }
--- gdb/dwarf2read.c	9 Mar 2009 18:53:48 -0000	1.296
+++ gdb/dwarf2read.c	16 Mar 2009 18:18:53 -0000
@@ -7658,6 +7658,11 @@ new_symbol (struct die_info *die, struct
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
 		  add_symbol_to_list (sym, &global_symbols);
 		}
+	      else
+		{
+		  /* Use the default LOC_OPTIMIZED_OUT class.  */
+		  add_symbol_to_list (sym, cu->list_in_scope);
+		}
 	    }
 	  break;
 	case DW_TAG_formal_parameter:
--- gdb/testsuite/gdb.dwarf2/dw2-noloc.S	3 Jan 2009 05:58:04 -0000	1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc.S	16 Mar 2009 18:18:54 -0000
@@ -26,6 +26,15 @@ func_cu1:
 	.size func_cu1, .-func_cu1
 .Lend_text1:
 
+	.equ	main_end, main + 0x100		/* Just an estimate.  */
+
+	.data
+	.globl hasloc_resolvable
+	.globl hasloc_resolvable2
+hasloc_resolvable:
+hasloc_resolvable2:
+	.4byte	1234567890
+
 /* Debug information */
 
 	.section .debug_info
@@ -40,7 +49,7 @@ func_cu1:
 	/* CU die */
 	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
 	.4byte	.Lline1_begin			/* DW_AT_stmt_list */
-	.4byte	.Lend_text1			/* DW_AT_high_pc */
+	.4byte	main_end			/* DW_AT_high_pc */
 	.4byte	.Lbegin_text1			/* DW_AT_low_pc */
 	.ascii	"file1.txt\0"			/* DW_AT_name */
 	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
@@ -64,11 +73,65 @@ func_cu1:
 	.byte		4			/* DW_AT_byte_size */
 	.byte		5			/* DW_AT_encoding */
 
-	.uleb128	4			/* Abbrev: DW_TAG_variable */
-	.ascii		"noloc\0"		/* DW_AT_name */
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"hasloc_direct\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:
+	.byte		3			/*   DW_OP_addr */
+	.4byte		hasloc_resolvable	/*   <addr> */
+2:
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"hasloc_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"noloc_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (local) */
+	.ascii		"noloc_local\0"		/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	/* main */
+	.uleb128	6			/* Abbrev: DW_TAG_subprogram */
+	.byte		1			/* DW_AT_decl_file */
+	.byte		2			/* DW_AT_decl_line */
+	.ascii		"main\0"		/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.4byte		main			/* DW_AT_low_pc */
+	.4byte		main_end		/* DW_AT_high_pc */
+	.byte		1			/* DW_AT_frame_base: length */
+	.byte		0x55			/* DW_AT_frame_base: DW_OP_reg5 */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"hasloc_direct2\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:
+	.byte		3			/*   DW_OP_addr */
+	.4byte		hasloc_resolvable	/*   <addr> */
+2:
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"hasloc_resolvable2\0"	/* DW_AT_name */
 	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
 	.byte		1			/* DW_AT_external */
 
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"noloc_unresolvable2\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (local) */
+	.ascii		"noloc_local2\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.byte		0			/* End of children of main */
+
 	.byte		0			/* End of children of CU */
 
 .Lcu1_end:
@@ -128,7 +191,7 @@ func_cu1:
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	4			/* Abbrev code */
+	.uleb128	4			/* Abbrev code (extern) */
 	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
@@ -140,6 +203,48 @@ func_cu1:
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
+	.uleb128	5			/* Abbrev code (local) */
+	.uleb128	0x34			/* DW_TAG_variable */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	6			/* Abbrev code */
+	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.byte		1			/* has_children */
+	.uleb128	0x3a			/* DW_AT_decl_file */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x3b			/* DW_AT_decl_line */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
+	.uleb128	0x11			/* DW_AT_low_pc */
+	.uleb128	0x1			/* DW_FORM_addr */
+	.uleb128	0x12			/* DW_AT_high_pc */
+	.uleb128	0x1			/* DW_FORM_addr */
+	.uleb128	0x40			/* DW_AT_frame_base */
+	.uleb128	0xa			/* DW_FORM_block1 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	7			/* Abbrev code (location) */
+	.uleb128	0x34			/* DW_TAG_variable */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
--- gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	3 Jan 2009 05:58:04 -0000	1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	16 Mar 2009 18:18:54 -0000
@@ -28,7 +28,7 @@ set testfile "dw2-noloc"
 set srcfile ${testfile}.S
 set binfile ${objdir}/${subdir}/${testfile}.x
 
-if  { [gdb_compile "${srcdir}/${subdir}/main.c" "main.o" object {debug}] != "" } {
+if  { [gdb_compile "${srcdir}/${subdir}/main.c" "main.o" object {nodebug}] != "" } {
     return -1
 }
 
@@ -45,4 +45,30 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-gdb_test "print noloc" "Address of symbol \"noloc\" is unknown." "print noloc"
+gdb_test "print hasloc_direct" "= 1234567890"
+gdb_test "ptype hasloc_direct" "type = int"
+
+gdb_test "print hasloc_resolvable" "= 1234567890"
+gdb_test "ptype hasloc_resolvable" "type = int"
+
+gdb_test "print noloc_unresolvable" "Address of symbol \"noloc_unresolvable\" is unknown\\."
+gdb_test "ptype noloc_unresolvable" "type = int"
+
+gdb_test "print noloc_local" "= <value optimized out>"
+gdb_test "ptype noloc_local" "type = int"
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_test "print hasloc_direct2" "= 1234567890"
+gdb_test "ptype hasloc_direct2" "type = int"
+
+gdb_test "print hasloc_resolvable2" "= 1234567890"
+gdb_test "ptype hasloc_resolvable2" "type = int"
+
+gdb_test "print noloc_unresolvable2" "Address of symbol \"noloc_unresolvable2\" is unknown\\."
+gdb_test "ptype noloc_unresolvable2" "type = int"
+
+gdb_test "print noloc_local2" "= <value optimized out>"
+gdb_test "ptype noloc_local2" "type = int"


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-16 21:15 [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols Jan Kratochvil
@ 2009-03-20 15:17 ` Joel Brobecker
  2009-03-20 15:51   ` Joel Brobecker
  2009-03-20 18:39   ` Joel Brobecker
  0 siblings, 2 replies; 16+ messages in thread
From: Joel Brobecker @ 2009-03-20 15:17 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

Hi Jan,

> * zero-length DW_AT_location should be the same as missing DW_AT_location.
>   https://fedorahosted.org/pipermail/elfutils-devel/2009-March/000180.html

I agree.

I have been trying to understand what is going on in this patch, so
can you bear with me?

The first observation is that dwarf2read treats zero-length DW_AT_location
lists as LOC_OPTIMIZED_OUT. See var_decode_location:

  /* A DW_AT_location attribute with no contents indicates that a
     variable has been optimized away.  */
  if (attr_form_is_block (attr) && DW_BLOCK (attr)->size == 0)
    {
      SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
      return;
    }

I'll see if I can reproduce using the testcase you provided (I don't
have gcc-4.4 handy, so I can't use the C example you gave).

-- 
Joel


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-20 15:17 ` Joel Brobecker
@ 2009-03-20 15:51   ` Joel Brobecker
  2009-03-20 18:22     ` Jan Kratochvil
  2009-03-20 18:39   ` Joel Brobecker
  1 sibling, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2009-03-20 15:51 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> The first observation is that dwarf2read treats zero-length DW_AT_location
> lists as LOC_OPTIMIZED_OUT. See var_decode_location:

OK - got it, now. The problem is when the DW_AT_location is missing
entirely. Aha...

-- 
Joel


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-20 15:51   ` Joel Brobecker
@ 2009-03-20 18:22     ` Jan Kratochvil
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-20 18:22 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

On Fri, 20 Mar 2009 16:02:48 +0100, Joel Brobecker wrote:
> I have been trying to understand what is going on in this patch, so
> can you bear with me?
On Fri, 20 Mar 2009 16:17:11 +0100, Joel Brobecker wrote:
> OK - got it, now. The problem is when the DW_AT_location is missing
> entirely. Aha...

Yes, so assuming this question is gone.


> I'll see if I can reproduce using the testcase you provided (I don't
> have gcc-4.4 handy, so I can't use the C example you gave).

That gcc-4.4 problem is gone - fixed by Jakub Jelinek gcc PR debug/39474.
It has now just a meaning for the debugging of a -O2 optimized code.


Thanks,
Jan


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-20 15:17 ` Joel Brobecker
  2009-03-20 15:51   ` Joel Brobecker
@ 2009-03-20 18:39   ` Joel Brobecker
  2009-03-20 18:51     ` [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols] Jan Kratochvil
  2009-03-20 19:18     ` Joel Brobecker
  1 sibling, 2 replies; 16+ messages in thread
From: Joel Brobecker @ 2009-03-20 18:39 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]

> > * zero-length DW_AT_location should be the same as missing DW_AT_location.
> >   https://fedorahosted.org/pipermail/elfutils-devel/2009-March/000180.html

Here a few thoughts after looking more closely at this. After reproducing
the problem thanks to your testsuite patch, I initially did the same thing
as you did, which was to add the symbol for local symbols as well.

But that caused the regressions you mentioned in one of the C++ testcases.
It's about a variable that's declared inside an anonymous namespaces.
I think that our mistake was to add all non-external variables without
checking that they were "complete" yet. Thus, I changed the patch to
the attached. Basically, if it is a non-external symbol but at the same
time a "declaration", then we should wait for the "defining" declaration
before adding it to the current local scope.

That fixes the C++ problem, and I was fairly confident about it but
a testcase run seems to indicate the following regressions:

+------------+------------+----------------------------------------------------+
|       PASS | FAIL       | callfuncs.exp: gdb function calls preserve reg ... |
|            |            | ... ister contents                                 |
|       PASS | FAIL       | callfuncs.exp: continue after stop in call dum ... |
|            |            | ... my preserves register contents                 |
|       PASS | FAIL       | callfuncs.exp: finish after stop in call dummy ... |
|            |            | ...  preserves register contents                   |
|       PASS | FAIL       | callfuncs.exp: return after stop in call dummy ... |
|            |            | ...  preserves register contents                   |
|       PASS | FAIL       | callfuncs.exp: nested call dummies preserve re ... |
|            |            | ... gister contents                                |
+------------+------------+----------------------------------------------------+

I'm a little surprised at these regressions, as I don't see how
the dwarf2read change we're making can have an impact on this.
It's particularly more puzzling that I did a diff of the exact
output of before and after taken from the gdb.log file, and diff
said there was no difference. I'm rerunning the testsuite now,
to see if it might be transient, but I'm wondering if I'm looking
at the right reference output....

-- 
Joel

[-- Attachment #2: loc.diff --]
[-- Type: text/x-diff, Size: 666 bytes --]

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index feb57b0..cba9d75 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7658,6 +7658,12 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
 		  add_symbol_to_list (sym, &global_symbols);
 		}
+              else if (!die_is_declaration (die, cu))
+                {
+                  /* Use the default LOC_OPTIMIZED_OUT class.  */
+                  gdb_assert (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT);
+                  add_symbol_to_list (sym, cu->list_in_scope);
+                }
 	    }
 	  break;
 	case DW_TAG_formal_parameter:

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

* [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp  [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols]
  2009-03-20 18:39   ` Joel Brobecker
@ 2009-03-20 18:51     ` Jan Kratochvil
  2009-03-20 19:54       ` Joel Brobecker
  2009-03-20 19:18     ` Joel Brobecker
  1 sibling, 1 reply; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-20 18:51 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Fri, 20 Mar 2009 19:22:15 +0100, Joel Brobecker wrote:
> That fixes the C++ problem, and I was fairly confident about it

Thanks for the analysis, going to check more the pros/cons of your patch.


> but a testcase run seems to indicate the following regressions:
> 
> +------------+------------+----------------------------------------------------+
> |       PASS | FAIL       | callfuncs.exp: gdb function calls preserve reg ... |
> |            |            | ... ister contents                                 |
> |       PASS | FAIL       | callfuncs.exp: continue after stop in call dum ... |
> |            |            | ... my preserves register contents                 |
> |       PASS | FAIL       | callfuncs.exp: finish after stop in call dummy ... |
> |            |            | ...  preserves register contents                   |
> |       PASS | FAIL       | callfuncs.exp: return after stop in call dummy ... |
> |            |            | ...  preserves register contents                   |
> |       PASS | FAIL       | callfuncs.exp: nested call dummies preserve re ... |
> |            |            | ... gister contents                                |
> +------------+------------+----------------------------------------------------+

Is the attached testsuite fix from
  http://cvs.fedora.redhat.com/viewvc/rpms/gdb/devel/gdb-6.7-testsuite-stable-results.patch?revision=1.6
OK to check-in?


Thanks,
Jan


gdb/testsuite/
2009-03-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix a racy FAIL.
	* gdb.base/auxv.exp (fetch_auxv): Fix trailing newlines consumption.
	* gdb.base/callfuncs.exp (fetch_all_registers): Likewise.

--- ./gdb/testsuite/gdb.base/auxv.exp	2009-02-11 00:54:54.000000000 +0100
+++ ./gdb/testsuite/gdb.base/auxv.exp	2009-02-11 00:51:30.000000000 +0100
@@ -78,8 +78,10 @@ proc fetch_auxv {test} {
 
     set auxv_lines {}
     set bad -1
+    # Former trailing `\[\r\n\]+' may eat just \r leaving \n in the buffer
+    # corrupting the next matches.
     if {[gdb_test_multiple "info auxv" $test {
-	-re "info auxv\[\r\n\]+" {
+	-re "info auxv\r\n" {
 	    exp_continue
 	}
 	-ex "The program has no auxiliary information now" {
@@ -94,20 +96,20 @@ proc fetch_auxv {test} {
 	    set bad 1
 	    exp_continue
 	}
-	-re "^\[0-9\]+\[ \t\]+(AT_\[^ \t\]+)\[^\r\n\]+\[\r\n\]+" {
+	-re "^\[0-9\]+\[ \t\]+(AT_\[^ \t\]+)\[^\r\n\]+\r\n" {
 	    lappend auxv_lines $expect_out(0,string)
 	    exp_continue
 	}
-	-re "^\[0-9\]+\[ \t\]+\\?\\?\\?\[^\r\n\]+\[\r\n\]+" {
+	-re "^\[0-9\]+\[ \t\]+\\?\\?\\?\[^\r\n\]+\r\n" {
 	    warning "Unrecognized tag value: $expect_out(0,string)"
 	    set bad 1
 	    lappend auxv_lines $expect_out(0,string)
 	    exp_continue
 	}
-	-re ".*$gdb_prompt $" {
+	-re "$gdb_prompt $" {
 	    incr bad
 	}
-	-re "^\[^\r\n\]+\[\r\n\]+" {
+	-re "^\[^\r\n\]+\r\n" {
 	    if {!$bad} {
 		warning "Unrecognized output: $expect_out(0,string)"
 		set bad 1
--- ./gdb/testsuite/gdb.base/callfuncs.exp	2009-01-03 06:58:03.000000000 +0100
+++ ./gdb/testsuite/gdb.base/callfuncs.exp	2009-02-11 00:51:42.000000000 +0100
@@ -249,15 +249,17 @@ proc fetch_all_registers {test} {
 
     set all_registers_lines {}
     set bad -1
+    # Former trailing `\[\r\n\]+' may eat just \r leaving \n in the buffer
+    # corrupting the next matches.
     if {[gdb_test_multiple "info all-registers" $test {
-	-re "info all-registers\[\r\n\]+" {
+	-re "info all-registers\r\n" {
 	    exp_continue
 	}
 	-ex "The program has no registers now" {
 	    set bad 1
 	    exp_continue
 	}
-	-re "^bspstore\[ \t\]+\[^\r\n\]+\[\r\n\]+" {
+	-re "^bspstore\[ \t\]+\[^\r\n\]+\r\n" {
 	    if [istarget "ia64-*-*"] {
 		# Filter out bspstore which is specially tied to bsp,
 		# giving spurious differences.
@@ -266,14 +268,14 @@ proc fetch_all_registers {test} {
 	    }
 	    exp_continue
 	}
-	-re "^\[^ \t\]+\[ \t\]+\[^\r\n\]+\[\r\n\]+" {
+	-re "^\[^ \t\]+\[ \t\]+\[^\r\n\]+\r\n" {
 	    lappend all_registers_lines $expect_out(0,string)
 	    exp_continue
 	}
-	-re ".*$gdb_prompt $" {
+	-re "$gdb_prompt $" {
 	    incr bad
 	}
-	-re "^\[^\r\n\]+\[\r\n\]+" {
+	-re "^\[^\r\n\]+\r\n" {
 	    if {!$bad} {
 		warning "Unrecognized output: $expect_out(0,string)"
 		set bad 1


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-20 18:39   ` Joel Brobecker
  2009-03-20 18:51     ` [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols] Jan Kratochvil
@ 2009-03-20 19:18     ` Joel Brobecker
  1 sibling, 0 replies; 16+ messages in thread
From: Joel Brobecker @ 2009-03-20 19:18 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> I'm a little surprised at these regressions, as I don't see how
> the dwarf2read change we're making can have an impact on this.
> It's particularly more puzzling that I did a diff of the exact
> output of before and after taken from the gdb.log file, and diff
> said there was no difference. I'm rerunning the testsuite now,
> to see if it might be transient, but I'm wondering if I'm looking
> at the right reference output....

I just reran the testsuite one more time, and this time no regression.
I guess a transient artifact, or something...

-- 
Joel


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

* Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp  [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols]
  2009-03-20 18:51     ` [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols] Jan Kratochvil
@ 2009-03-20 19:54       ` Joel Brobecker
  2009-03-20 21:54         ` Daniel Jacobowitz
  2009-03-23 17:36         ` Joel Brobecker
  0 siblings, 2 replies; 16+ messages in thread
From: Joel Brobecker @ 2009-03-20 19:54 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> gdb/testsuite/
> 2009-03-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Fix a racy FAIL.
> 	* gdb.base/auxv.exp (fetch_auxv): Fix trailing newlines consumption.
> 	* gdb.base/callfuncs.exp (fetch_all_registers): Likewise.

This looks OK to me.

But I have a question: Does anyone know who is responsible for us
getting CR/LF as line-endings even on Unix? Is that expect? dejagnu?
our gdb-testsuite framework? I can't find any information on the web
nor find a clue in gdb/testsuite/lib :-(.

-- 
Joel


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

* Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp  [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols]
  2009-03-20 19:54       ` Joel Brobecker
@ 2009-03-20 21:54         ` Daniel Jacobowitz
  2009-03-23 17:36         ` Joel Brobecker
  1 sibling, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2009-03-20 21:54 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Jan Kratochvil, gdb-patches

On Fri, Mar 20, 2009 at 03:18:41PM -0400, Joel Brobecker wrote:
> But I have a question: Does anyone know who is responsible for us
> getting CR/LF as line-endings even on Unix? Is that expect? dejagnu?
> our gdb-testsuite framework? I can't find any information on the web
> nor find a clue in gdb/testsuite/lib :-(.

It's expect.  Expect creates a pseudo-terminal (pty).  The kernel does
normal terminal processing on it, which includes carriage returns.
I'm not sure how this works out on Cygwin, but I assume the principle
is the same and only the actors are different.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp  [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols]
  2009-03-20 19:54       ` Joel Brobecker
  2009-03-20 21:54         ` Daniel Jacobowitz
@ 2009-03-23 17:36         ` Joel Brobecker
  2009-03-23 17:45           ` Jan Kratochvil
  1 sibling, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2009-03-23 17:36 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> > gdb/testsuite/
> > 2009-03-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	Fix a racy FAIL.
> > 	* gdb.base/auxv.exp (fetch_auxv): Fix trailing newlines consumption.
> > 	* gdb.base/callfuncs.exp (fetch_all_registers): Likewise.
> 
> This looks OK to me.

Just to confirm, this patch is OK. (many thanks to Daniel for providing
the info about expect)

And thank you for contributing this patch :)
-- 
Joel


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

* Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp  [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols]
  2009-03-23 17:36         ` Joel Brobecker
@ 2009-03-23 17:45           ` Jan Kratochvil
  2009-03-23 22:52             ` Joel Brobecker
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-23 17:45 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Mon, 23 Mar 2009 18:31:15 +0100, Joel Brobecker wrote:
> > > gdb/testsuite/
> > > 2009-03-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > > 
> > > 	Fix a racy FAIL.
> > > 	* gdb.base/auxv.exp (fetch_auxv): Fix trailing newlines consumption.
> > > 	* gdb.base/callfuncs.exp (fetch_all_registers): Likewise.
> > 
> > This looks OK to me.
> 
> Just to confirm, this patch is OK. (many thanks to Daniel for providing
> the info about expect)

OK, checked-in, thanks.

(And therefore assuming one should always confirm the check-in in this list.)

(the original patch for optimized-out variables is being tested and looks OK)


Regards,
Jan


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

* Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp  [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols]
  2009-03-23 17:45           ` Jan Kratochvil
@ 2009-03-23 22:52             ` Joel Brobecker
  2009-03-24 23:50               ` [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols [Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp] Jan Kratochvil
  0 siblings, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2009-03-23 22:52 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> (the original patch for optimized-out variables is being tested and looks OK)

Excellent! How about officially resubmitting the latest version of
the patch, to give everyone a chance to look at it again, before
we decide to check it in?

-- 
Joel


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols  [Re: [patch] Racy FAIL: gdb.base/auxv.exp +  gdb.base/callfuncs.exp]
  2009-03-23 22:52             ` Joel Brobecker
@ 2009-03-24 23:50               ` Jan Kratochvil
  2009-03-25 10:03                 ` [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols Jan Kratochvil
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-24 23:50 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Mon, 23 Mar 2009 23:47:36 +0100, Joel Brobecker wrote:
> > (the original patch for optimized-out variables is being tested and looks OK)
> 
> Excellent! How about officially resubmitting the latest version of
> the patch, to give everyone a chance to look at it again, before
> we decide to check it in?

I was not completely convinced that time I would like to submit it that way.

Written there a rationale as I do not find the reasons for the
die_is_declaration() condition there to be obvious.

Also submitted to http://dwarfstd.org/Issues.php that DWARF3 section 2.13.2 is
IMO ambiguous as was discussed at:
  http://sourceware.org/ml/gdb-patches/2004-04/threads.html#00296
suggesting to add:
  DW_AT_declaration and DW_AT_sibling attributes are not being inherited from
  the debugging information entry referenced by the specification attribute.

The testcase probably breaks on Alpha (as its default executable addresses do
not fit in 32 bits) compared to its original variant.

No regressions on x86_64-unknown-linux-gnu, tested also on gcc-4.4 (Fedora 11).


Thanks,
Jan


gdb/
2009-03-24  Joel Brobecker  <brobecker@adacore.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Recognize missing DW_AT_location as <value optimized out>.
	* dwarf2read.c
	(new_symbol <DW_TAG_variable> <!DW_AT_location> <!DW_AT_external>):
	Call add_symbol_to_list.

gdb/testsuite/
2009-03-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.dwarf2/dw2-noloc-main.c: New file.
	* gdb.dwarf2/dw2-noloc.S (.text): Remove.
	(.data): New.
	(DW_AT_stmt_list, .debug_line, DW_AT_frame_base): Remove.
	(DW_AT_low_pc, DW_AT_high_pc): Reference `dw2-noloc-main.c'.
	(DW_TAG_subprogram func_cu1, noloc): Remove.
	(file_location, file_optimized_out, extern_location, extern_resolvable)
	(extern_unresolvable, main, func_location, func_optimized_out)
	(func_extern_location, func_extern_resolvable)
	(func_extern_unresolvable): New.
	* gdb.dwarf2/dw2-noloc.exp: Use prepare_for_testing, compile also
	`dw2-noloc-main.c'.  Test the new DIEs from `dw2-noloc.S'.
	(globals): New procedure.

--- gdb/dwarf2read.c	20 Mar 2009 22:00:10 -0000	1.297
+++ gdb/dwarf2read.c	24 Mar 2009 21:05:16 -0000
@@ -7659,6 +7659,26 @@ new_symbol (struct die_info *die, struct
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
 		  add_symbol_to_list (sym, &global_symbols);
 		}
+	      /* Catch local optimized-out variables but do not create symbols
+		 for DIEs later being completed (by their DW_AT_location or
+		 DW_AT_const_value).
+
+		 C++ declaration refering to a definition in the same file (and
+		 therefore not using DW_AT_external) would be
+		 DW_TAG_imported_declaration (not DW_TAG_variable) as the
+		 target DIE can be referenced as it is in the same CU.
+
+		 Therefore such DW_TAG_variable having DW_AT_declaration would
+		 be present only to be later completed through
+		 DW_AT_specification.  As GDB looks up the first symbol in its
+		 scope we will rather defer creating the symbol to the later
+		 DIE completing this DIE.  */
+	      else if (!die_is_declaration (die, cu))
+		{
+		  /* Use the default LOC_OPTIMIZED_OUT class.  */
+		  gdb_assert (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT);
+		  add_symbol_to_list (sym, cu->list_in_scope);
+		}
 	    }
 	  break;
 	case DW_TAG_formal_parameter:
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc-main.c	24 Mar 2009 21:05:16 -0000
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+asm (".globl cu_text_start");
+asm ("cu_text_start:");
+
+int
+main (void)
+{
+  return 0;
+}
+
+asm (".globl cu_text_end");
+asm ("cu_text_end:");
--- gdb/testsuite/gdb.dwarf2/dw2-noloc.S	3 Jan 2009 05:58:04 -0000	1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc.S	24 Mar 2009 21:05:16 -0000
@@ -15,16 +15,13 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-	.text
-.Lbegin_text1:
-	.globl func_cu1
-	.type func_cu1, %function
-func_cu1:
-.Lbegin_func_cu1:
-	.int 0
-.Lend_func_cu1:
-	.size func_cu1, .-func_cu1
-.Lend_text1:
+	.data
+	.globl	func_extern_resolvable
+func_extern_resolvable:
+	.globl	extern_resolvable
+extern_resolvable:
+resolvable:
+	.4byte	1234567890
 
 /* Debug information */
 
@@ -39,36 +36,89 @@ func_cu1:
 
 	/* CU die */
 	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
-	.4byte	.Lline1_begin			/* DW_AT_stmt_list */
-	.4byte	.Lend_text1			/* DW_AT_high_pc */
-	.4byte	.Lbegin_text1			/* DW_AT_low_pc */
+	.4byte	cu_text_end			/* DW_AT_high_pc */
+	.4byte	cu_text_start			/* DW_AT_low_pc */
 	.ascii	"file1.txt\0"			/* DW_AT_name */
 	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
 	.byte	1				/* DW_AT_language (C) */
 
-	/* func_cu1 */
-	.uleb128	2			/* Abbrev: DW_TAG_subprogram */
-	.byte		1			/* DW_AT_external */
-	.byte		1			/* DW_AT_decl_file */
-	.byte		2			/* DW_AT_decl_line */
-	.ascii		"func_cu1\0"		/* DW_AT_name */
-	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
-	.4byte		.Lbegin_func_cu1	/* DW_AT_low_pc */
-	.4byte		.Lend_func_cu1		/* DW_AT_high_pc */
-	.byte		1			/* DW_AT_frame_base: length */
-	.byte		0x55			/* DW_AT_frame_base: DW_OP_reg5 */
-
 .Ltype_int:
 	.uleb128	3			/* Abbrev: DW_TAG_base_type */
 	.ascii		"int\0"			/* DW_AT_name */
 	.byte		4			/* DW_AT_byte_size */
 	.byte		5			/* DW_AT_encoding */
 
-	.uleb128	4			/* Abbrev: DW_TAG_variable */
-	.ascii		"noloc\0"		/* DW_AT_name */
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_location\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"file_optimized_out\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"extern_location\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"extern_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	/* This variable is optimized-out.  */
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"extern_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	/* main */
+	.uleb128	6			/* Abbrev: DW_TAG_subprogram */
+	.byte		1			/* DW_AT_decl_file */
+	.byte		2			/* DW_AT_decl_line */
+	.ascii		"main\0"		/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.4byte		cu_text_start		/* DW_AT_low_pc */
+	.4byte		cu_text_end		/* DW_AT_high_pc */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"func_location\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"func_optimized_out\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"func_extern_location\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"func_extern_resolvable\0"	/* DW_AT_name */
 	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
 	.byte		1			/* DW_AT_external */
 
+	/* This variable is optimized-out.  */
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"func_extern_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.byte		0			/* End of children of main */
+
 	.byte		0			/* End of children of CU */
 
 .Lcu1_end:
@@ -79,8 +129,6 @@ func_cu1:
 	.uleb128	1			/* Abbrev code */
 	.uleb128	0x11			/* DW_TAG_compile_unit */
 	.byte		1			/* has_children */
-	.uleb128	0x10			/* DW_AT_stmt_list */
-	.uleb128	0x6			/* DW_FORM_data4 */
 	.uleb128	0x12			/* DW_AT_high_pc */
 	.uleb128	0x1			/* DW_FORM_addr */
 	.uleb128	0x11			/* DW_AT_low_pc */
@@ -94,11 +142,43 @@ func_cu1:
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	2			/* Abbrev code */
-	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.uleb128	3			/* Abbrev code */
+	.uleb128	0x24			/* DW_TAG_base_type */
 	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0xb			/* DW_AT_byte_size */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x3e			/* DW_AT_encoding */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	4			/* Abbrev code (extern) */
+	.uleb128	0x34			/* DW_TAG_variable */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
 	.uleb128	0x3f			/* DW_AT_external */
 	.uleb128	0xc			/* DW_FORM_flag */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	5			/* Abbrev code (bare) */
+	.uleb128	0x34			/* DW_TAG_variable */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	6			/* Abbrev code */
+	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.byte		1			/* has_children */
 	.uleb128	0x3a			/* DW_AT_decl_file */
 	.uleb128	0xb			/* DW_FORM_data1 */
 	.uleb128	0x3b			/* DW_AT_decl_line */
@@ -111,30 +191,30 @@ func_cu1:
 	.uleb128	0x1			/* DW_FORM_addr */
 	.uleb128	0x12			/* DW_AT_high_pc */
 	.uleb128	0x1			/* DW_FORM_addr */
-	.uleb128	0x40			/* DW_AT_frame_base */
-	.uleb128	0xa			/* DW_FORM_block1 */
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	3			/* Abbrev code */
-	.uleb128	0x24			/* DW_TAG_base_type */
+	.uleb128	7			/* Abbrev code (location) */
+	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
 	.uleb128	0x8			/* DW_FORM_string */
-	.uleb128	0xb			/* DW_AT_byte_size */
-	.uleb128	0xb			/* DW_FORM_data1 */
-	.uleb128	0x3e			/* DW_AT_encoding */
-	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	4			/* Abbrev code */
+	.uleb128	8			/* Abbrev code (location+extern) */
 	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
 	.uleb128	0x8			/* DW_FORM_string */
 	.uleb128	0x49			/* DW_AT_type */
 	.uleb128	0x13			/* DW_FORM_ref4 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
 	.uleb128	0x3f			/* DW_AT_external */
 	.uleb128	0xc			/* DW_FORM_flag */
 	.byte		0x0			/* Terminator */
@@ -142,69 +222,3 @@ func_cu1:
 
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
-
-/* Line table */
-	.section .debug_line
-.Lline1_begin:
-	.4byte		.Lline1_end - .Lline1_start	/* Initial length */
-.Lline1_start:
-	.2byte		2			/* Version */
-	.4byte		.Lline1_lines - .Lline1_hdr	/* header_length */
-.Lline1_hdr:
-	.byte		1			/* Minimum insn length */
-	.byte		1			/* default_is_stmt */
-	.byte		1			/* line_base */
- 	.byte		1			/* line_range */
-	.byte		0x10			/* opcode_base */
-
-	/* Standard lengths */
-	.byte		0
-	.byte		1
-	.byte		1
-	.byte		1
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		0
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		0
-
-	/* Include directories */
-	.byte		0
-
-	/* File names */
-	.ascii		"file1.txt\0"
-	.uleb128	0
-	.uleb128	0
-	.uleb128	0
-
-	.byte		0
-
-.Lline1_lines:
-	.byte		0	/* DW_LNE_set_address */
-	.uleb128	5
-	.byte		2
-	.4byte		.Lbegin_func_cu1
-
-	.byte		3	/* DW_LNS_advance_line */
-	.sleb128	3	/* ... to 4 */
-
-	.byte		1	/* DW_LNS_copy */
-
-	.byte		1	/* DW_LNS_copy (second time as an end-of-prologue marker) */
-
-	.byte		0	/* DW_LNE_set_address */
-	.uleb128	5
-	.byte		2
-	.4byte		.Lend_func_cu1
-
-	.byte		0	/* DW_LNE_end_of_sequence */
-	.uleb128	1
-	.byte		1
-
-.Lline1_end:
--- gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	3 Jan 2009 05:58:04 -0000	1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	24 Mar 2009 21:05:16 -0000
@@ -24,25 +24,55 @@ if {![istarget *-*-linux*]
     return 0  
 }
 
-set testfile "dw2-noloc"
-set srcfile ${testfile}.S
-set binfile ${objdir}/${subdir}/${testfile}.x
-
-if  { [gdb_compile "${srcdir}/${subdir}/main.c" "main.o" object {debug}] != "" } {
+if { [prepare_for_testing dw2-noloc.exp "dw2-noloc" {dw2-noloc-main.c dw2-noloc.S} {nodebug}] } {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${testfile}.o" object {nodebug}] != "" } {
-    return -1
+proc globals {type} {
+    global pf_prefix
+    set old_prefix $pf_prefix
+    lappend pf_prefix "$type:"
+
+    gdb_test "print file_location" "= 1234567890"
+    gdb_test "ptype file_location" "type = int"
+
+    gdb_test "print file_optimized_out" "= <value optimized out>"
+    gdb_test "ptype file_optimized_out" "type = int"
+
+    gdb_test "print extern_location" "= 1234567890"
+    gdb_test "ptype extern_location" "type = int"
+
+    gdb_test "print extern_resolvable" "= 1234567890"
+    gdb_test "ptype extern_resolvable" "type = int"
+
+    # This variable should be printed as optimized-out.
+    gdb_test "print extern_unresolvable" "Address of symbol \"extern_unresolvable\" is unknown\\."
+    gdb_test "ptype extern_unresolvable" "type = int"
+
+    set pf_prefix $old_prefix
 }
 
-if  { [gdb_compile "${testfile}.o main.o" "${binfile}" executable {debug}] != "" } {
+globals no-run
+
+if ![runto_main] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+globals in-main
+
+
+gdb_test "print func_location" "= 1234567890"
+gdb_test "ptype func_location" "type = int"
+
+gdb_test "print func_optimized_out" "= <value optimized out>"
+gdb_test "ptype func_optimized_out" "type = int"
+
+gdb_test "print func_extern_location" "= 1234567890"
+gdb_test "ptype func_extern_location" "type = int"
+
+gdb_test "print func_extern_resolvable" "= 1234567890"
+gdb_test "ptype func_extern_resolvable" "type = int"
 
-gdb_test "print noloc" "Address of symbol \"noloc\" is unknown." "print noloc"
+# This variable should be printed as optimized-out.
+gdb_test "print func_extern_unresolvable" "Address of symbol \"func_extern_unresolvable\" is unknown\\."
+gdb_test "ptype func_extern_unresolvable" "type = int"


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-24 23:50               ` [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols [Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp] Jan Kratochvil
@ 2009-03-25 10:03                 ` Jan Kratochvil
  2009-03-26  0:38                   ` Joel Brobecker
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-25 10:03 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

just updated the testcase to be more complete.  Filed a KFAIL tracker:
http://sourceware.org/bugzilla/show_bug.cgi?id=10002


Thanks,
Jan


gdb/
2009-03-24  Joel Brobecker  <brobecker@adacore.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Recognize missing DW_AT_location as <value optimized out>.
	* dwarf2read.c
	(new_symbol <DW_TAG_variable> <!DW_AT_location> <!DW_AT_external>):
	Call add_symbol_to_list.

gdb/testsuite/
2009-03-25  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.dwarf2/dw2-noloc-main.c: New file.
	* gdb.dwarf2/dw2-noloc.S: New symbols matrix.
	(.text): Remove.
	(.data): New.
	(DW_AT_stmt_list, .debug_line, DW_AT_frame_base): Remove.
	(DW_AT_low_pc, DW_AT_high_pc): Reference `dw2-noloc-main.c'.
	(DW_TAG_subprogram func_cu1, noloc): Remove.
	(main): New.
	* gdb.dwarf2/dw2-noloc.exp: Use prepare_for_testing, compile also
	`dw2-noloc-main.c'.  Test the new DIEs from `dw2-noloc.S'.
	(file_symbols): New procedure.

--- gdb/dwarf2read.c	20 Mar 2009 22:00:10 -0000	1.297
+++ gdb/dwarf2read.c	25 Mar 2009 08:58:19 -0000
@@ -7659,6 +7659,26 @@ new_symbol (struct die_info *die, struct
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
 		  add_symbol_to_list (sym, &global_symbols);
 		}
+	      /* Catch local optimized-out variables but do not create symbols
+		 for DIEs later being completed (by their DW_AT_location or
+		 DW_AT_const_value).
+
+		 C++ declaration refering to a definition in the same file (and
+		 therefore not using DW_AT_external) would be
+		 DW_TAG_imported_declaration (not DW_TAG_variable) as the
+		 target DIE can be referenced as it is in the same CU.
+
+		 Therefore such DW_TAG_variable having DW_AT_declaration would
+		 be present only to be later completed through
+		 DW_AT_specification.  As GDB looks up the first symbol in its
+		 scope we will rather defer creating the symbol to the later
+		 DIE completing this DIE.  */
+	      else if (!die_is_declaration (die, cu))
+		{
+		  /* Use the default LOC_OPTIMIZED_OUT class.  */
+		  gdb_assert (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT);
+		  add_symbol_to_list (sym, cu->list_in_scope);
+		}
 	    }
 	  break;
 	case DW_TAG_formal_parameter:
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc-main.c	25 Mar 2009 08:58:22 -0000
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+asm (".globl cu_text_start");
+asm ("cu_text_start:");
+
+int
+main (void)
+{
+  return 0;
+}
+
+asm (".globl cu_text_end");
+asm ("cu_text_end:");
--- gdb/testsuite/gdb.dwarf2/dw2-noloc.S	3 Jan 2009 05:58:04 -0000	1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc.S	25 Mar 2009 08:58:22 -0000
@@ -15,16 +15,35 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-	.text
-.Lbegin_text1:
-	.globl func_cu1
-	.type func_cu1, %function
-func_cu1:
-.Lbegin_func_cu1:
-	.int 0
-.Lend_func_cu1:
-	.size func_cu1, .-func_cu1
-.Lend_text1:
+	.data
+
+	.globl	file_locaddr_resolvable
+file_locaddr_resolvable:
+	.globl	file_locempty_resolvable
+file_locempty_resolvable:
+	.globl	file_locno_resolvable
+file_locno_resolvable:
+	.globl	file_extern_locaddr_resolvable
+file_extern_locaddr_resolvable:
+	.globl	file_extern_locempty_resolvable
+file_extern_locempty_resolvable:
+	.globl	file_extern_locno_resolvable
+file_extern_locno_resolvable:
+	.globl	main_local_locaddr_resolvable
+main_local_locaddr_resolvable:
+	.globl	main_local_locempty_resolvable
+main_local_locempty_resolvable:
+	.globl	main_local_locno_resolvable
+main_local_locno_resolvable:
+	.globl	main_extern_locaddr_resolvable
+main_extern_locaddr_resolvable:
+	.globl	main_extern_locno_resolvable
+main_extern_locno_resolvable:
+	.globl	main_extern_locempty_resolvable
+main_extern_locempty_resolvable:
+
+resolvable:
+	.4byte	1234567890
 
 /* Debug information */
 
@@ -39,36 +58,169 @@ func_cu1:
 
 	/* CU die */
 	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
-	.4byte	.Lline1_begin			/* DW_AT_stmt_list */
-	.4byte	.Lend_text1			/* DW_AT_high_pc */
-	.4byte	.Lbegin_text1			/* DW_AT_low_pc */
+	.4byte	cu_text_end			/* DW_AT_high_pc */
+	.4byte	cu_text_start			/* DW_AT_low_pc */
 	.ascii	"file1.txt\0"			/* DW_AT_name */
 	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
 	.byte	1				/* DW_AT_language (C) */
 
-	/* func_cu1 */
-	.uleb128	2			/* Abbrev: DW_TAG_subprogram */
-	.byte		1			/* DW_AT_external */
-	.byte		1			/* DW_AT_decl_file */
-	.byte		2			/* DW_AT_decl_line */
-	.ascii		"func_cu1\0"		/* DW_AT_name */
-	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
-	.4byte		.Lbegin_func_cu1	/* DW_AT_low_pc */
-	.4byte		.Lend_func_cu1		/* DW_AT_high_pc */
-	.byte		1			/* DW_AT_frame_base: length */
-	.byte		0x55			/* DW_AT_frame_base: DW_OP_reg5 */
-
 .Ltype_int:
 	.uleb128	3			/* Abbrev: DW_TAG_base_type */
 	.ascii		"int\0"			/* DW_AT_name */
 	.byte		4			/* DW_AT_byte_size */
 	.byte		5			/* DW_AT_encoding */
 
-	.uleb128	4			/* Abbrev: DW_TAG_variable */
-	.ascii		"noloc\0"		/* DW_AT_name */
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locaddr_resolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locaddr_unresolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locempty_resolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locempty_unresolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"file_locno_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"file_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locaddr_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locaddr_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locempty_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locempty_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"file_extern_locno_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"file_extern_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	/* main */
+	.uleb128	6			/* Abbrev: DW_TAG_subprogram */
+	.byte		1			/* DW_AT_decl_file */
+	.byte		2			/* DW_AT_decl_line */
+	.ascii		"main\0"		/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.4byte		cu_text_start		/* DW_AT_low_pc */
+	.4byte		cu_text_end		/* DW_AT_high_pc */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locaddr_resolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locaddr_unresolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locempty_resolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locempty_unresolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"main_local_locno_resolvable\0"	/* DW_AT_name */
 	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"main_local_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locaddr_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locaddr_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locempty_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locempty_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
 	.byte		1			/* DW_AT_external */
 
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"main_extern_locno_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"main_extern_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.byte		0			/* End of children of main */
+
 	.byte		0			/* End of children of CU */
 
 .Lcu1_end:
@@ -79,8 +231,6 @@ func_cu1:
 	.uleb128	1			/* Abbrev code */
 	.uleb128	0x11			/* DW_TAG_compile_unit */
 	.byte		1			/* has_children */
-	.uleb128	0x10			/* DW_AT_stmt_list */
-	.uleb128	0x6			/* DW_FORM_data4 */
 	.uleb128	0x12			/* DW_AT_high_pc */
 	.uleb128	0x1			/* DW_FORM_addr */
 	.uleb128	0x11			/* DW_AT_low_pc */
@@ -94,11 +244,43 @@ func_cu1:
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	2			/* Abbrev code */
-	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.uleb128	3			/* Abbrev code */
+	.uleb128	0x24			/* DW_TAG_base_type */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0xb			/* DW_AT_byte_size */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x3e			/* DW_AT_encoding */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	4			/* Abbrev code (extern) */
+	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
 	.uleb128	0x3f			/* DW_AT_external */
 	.uleb128	0xc			/* DW_FORM_flag */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	5			/* Abbrev code (bare) */
+	.uleb128	0x34			/* DW_TAG_variable */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	6			/* Abbrev code */
+	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.byte		1			/* has_children */
 	.uleb128	0x3a			/* DW_AT_decl_file */
 	.uleb128	0xb			/* DW_FORM_data1 */
 	.uleb128	0x3b			/* DW_AT_decl_line */
@@ -111,30 +293,30 @@ func_cu1:
 	.uleb128	0x1			/* DW_FORM_addr */
 	.uleb128	0x12			/* DW_AT_high_pc */
 	.uleb128	0x1			/* DW_FORM_addr */
-	.uleb128	0x40			/* DW_AT_frame_base */
-	.uleb128	0xa			/* DW_FORM_block1 */
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	3			/* Abbrev code */
-	.uleb128	0x24			/* DW_TAG_base_type */
+	.uleb128	7			/* Abbrev code (location) */
+	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
 	.uleb128	0x8			/* DW_FORM_string */
-	.uleb128	0xb			/* DW_AT_byte_size */
-	.uleb128	0xb			/* DW_FORM_data1 */
-	.uleb128	0x3e			/* DW_AT_encoding */
-	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	4			/* Abbrev code */
+	.uleb128	8			/* Abbrev code (location+extern) */
 	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
 	.uleb128	0x8			/* DW_FORM_string */
 	.uleb128	0x49			/* DW_AT_type */
 	.uleb128	0x13			/* DW_FORM_ref4 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
 	.uleb128	0x3f			/* DW_AT_external */
 	.uleb128	0xc			/* DW_FORM_flag */
 	.byte		0x0			/* Terminator */
@@ -142,69 +324,3 @@ func_cu1:
 
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
-
-/* Line table */
-	.section .debug_line
-.Lline1_begin:
-	.4byte		.Lline1_end - .Lline1_start	/* Initial length */
-.Lline1_start:
-	.2byte		2			/* Version */
-	.4byte		.Lline1_lines - .Lline1_hdr	/* header_length */
-.Lline1_hdr:
-	.byte		1			/* Minimum insn length */
-	.byte		1			/* default_is_stmt */
-	.byte		1			/* line_base */
- 	.byte		1			/* line_range */
-	.byte		0x10			/* opcode_base */
-
-	/* Standard lengths */
-	.byte		0
-	.byte		1
-	.byte		1
-	.byte		1
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		0
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		0
-
-	/* Include directories */
-	.byte		0
-
-	/* File names */
-	.ascii		"file1.txt\0"
-	.uleb128	0
-	.uleb128	0
-	.uleb128	0
-
-	.byte		0
-
-.Lline1_lines:
-	.byte		0	/* DW_LNE_set_address */
-	.uleb128	5
-	.byte		2
-	.4byte		.Lbegin_func_cu1
-
-	.byte		3	/* DW_LNS_advance_line */
-	.sleb128	3	/* ... to 4 */
-
-	.byte		1	/* DW_LNS_copy */
-
-	.byte		1	/* DW_LNS_copy (second time as an end-of-prologue marker) */
-
-	.byte		0	/* DW_LNE_set_address */
-	.uleb128	5
-	.byte		2
-	.4byte		.Lend_func_cu1
-
-	.byte		0	/* DW_LNE_end_of_sequence */
-	.uleb128	1
-	.byte		1
-
-.Lline1_end:
--- gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	3 Jan 2009 05:58:04 -0000	1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	25 Mar 2009 08:58:22 -0000
@@ -24,25 +24,122 @@ if {![istarget *-*-linux*]
     return 0  
 }
 
-set testfile "dw2-noloc"
-set srcfile ${testfile}.S
-set binfile ${objdir}/${subdir}/${testfile}.x
-
-if  { [gdb_compile "${srcdir}/${subdir}/main.c" "main.o" object {debug}] != "" } {
+if { [prepare_for_testing dw2-noloc.exp "dw2-noloc" {dw2-noloc-main.c dw2-noloc.S} {nodebug}] } {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${testfile}.o" object {nodebug}] != "" } {
-    return -1
+# Symbols have the form: {file,main}_loc{addr,empty,no}_{,un}resolvable
+# file: Symbol DIE is placed in DW_TAG_compile_unit.
+# main: Symbol DIE is placed in DW_TAG_subprogram.
+# locaddr: DW_AT_location is using DW_FORM_block DW_OP_addr <addr>.
+# locempty: DW_AT_location has zero DW_FORM_block size.
+# locno: DW_AT_location is not present.
+# resolvable: .symtab entry exists for this symbol name.
+# unresolvable: .symtab entry does not exist for this symbol name.
+
+proc file_symbols {type} {
+    global pf_prefix
+    set old_prefix $pf_prefix
+    lappend pf_prefix "$type:"
+
+    global gdb_prompt
+
+    gdb_test "print file_locaddr_resolvable" "= 1234567890"
+    gdb_test "ptype file_locaddr_resolvable" "type = int"
+
+    gdb_test "print file_locaddr_unresolvable" "= 1234567890"
+    gdb_test "ptype file_locaddr_unresolvable" "type = int"
+
+    gdb_test "print file_locempty_resolvable" "= <value optimized out>"
+    gdb_test "ptype file_locempty_resolvable" "type = int"
+
+    gdb_test "print file_locempty_unresolvable" "= <value optimized out>"
+    gdb_test "ptype file_locempty_unresolvable" "type = int"
+
+    gdb_test "print file_locno_resolvable" "= <value optimized out>"
+    gdb_test "ptype file_locno_resolvable" "type = int"
+
+    gdb_test "print file_locno_unresolvable" "= <value optimized out>"
+    gdb_test "ptype file_locno_unresolvable" "type = int"
+
+    gdb_test "print file_extern_locaddr_resolvable" "= 1234567890"
+    gdb_test "ptype file_extern_locaddr_resolvable" "type = int"
+
+    gdb_test "print file_extern_locaddr_unresolvable" "= 1234567890"
+    gdb_test "ptype file_extern_locaddr_unresolvable" "type = int"
+
+    gdb_test "print file_extern_locempty_resolvable" "= <value optimized out>"
+    gdb_test "ptype file_extern_locempty_resolvable" "type = int"
+
+    gdb_test "print file_extern_locempty_unresolvable" "= <value optimized out>"
+    gdb_test "ptype file_extern_locempty_unresolvable" "type = int"
+
+    gdb_test "print file_extern_locno_resolvable" "= 1234567890"
+    gdb_test "ptype file_extern_locno_resolvable" "type = int"
+
+    set test "print file_extern_locno_unresolvable"
+    gdb_test_multiple $test $test {
+        -re "Address of symbol \"file_extern_locno_unresolvable\" is unknown\\.\r\n$gdb_prompt $" {
+	    kfail gdb/10002 $test
+	}
+	-re "= <value optimized out>\r\n$gdb_prompt $" {
+	    pass $test
+	}
+    }
+    gdb_test "ptype file_extern_locno_unresolvable" "type = int"
+
+    set pf_prefix $old_prefix
 }
 
-if  { [gdb_compile "${testfile}.o main.o" "${binfile}" executable {debug}] != "" } {
+file_symbols no-run
+
+if ![runto_main] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+file_symbols in-main
+
+
+gdb_test "print main_local_locaddr_resolvable" "= 1234567890"
+gdb_test "ptype main_local_locaddr_resolvable" "type = int"
+
+gdb_test "print main_local_locaddr_unresolvable" "= 1234567890"
+gdb_test "ptype main_local_locaddr_unresolvable" "type = int"
+
+gdb_test "print main_local_locempty_resolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locempty_resolvable" "type = int"
+
+gdb_test "print main_local_locempty_unresolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locempty_unresolvable" "type = int"
+
+gdb_test "print main_local_locno_resolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locno_resolvable" "type = int"
 
-gdb_test "print noloc" "Address of symbol \"noloc\" is unknown." "print noloc"
+gdb_test "print main_local_locno_unresolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locno_unresolvable" "type = int"
+
+gdb_test "print main_extern_locaddr_resolvable" "= 1234567890"
+gdb_test "ptype main_extern_locaddr_resolvable" "type = int"
+
+gdb_test "print main_extern_locaddr_unresolvable" "= 1234567890"
+gdb_test "ptype main_extern_locaddr_unresolvable" "type = int"
+
+gdb_test "print main_extern_locempty_resolvable" "= <value optimized out>"
+gdb_test "ptype main_extern_locempty_resolvable" "type = int"
+
+gdb_test "print main_extern_locempty_unresolvable" "= <value optimized out>"
+gdb_test "ptype main_extern_locempty_unresolvable" "type = int"
+
+gdb_test "print main_extern_locno_resolvable" "= 1234567890"
+gdb_test "ptype main_extern_locno_resolvable" "type = int"
+
+set test "print main_extern_locno_unresolvable"
+gdb_test_multiple $test $test {
+    -re "Address of symbol \"main_extern_locno_unresolvable\" is unknown\\.\r\n$gdb_prompt $" {
+	kfail gdb/10002 $test
+    }
+    -re "= <value optimized out>\r\n$gdb_prompt $" {
+	pass $test
+    }
+}
+gdb_test "ptype main_extern_locno_unresolvable" "type = int"


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-25 10:03                 ` [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols Jan Kratochvil
@ 2009-03-26  0:38                   ` Joel Brobecker
  2009-03-26 17:02                     ` Jan Kratochvil
  0 siblings, 1 reply; 16+ messages in thread
From: Joel Brobecker @ 2009-03-26  0:38 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

Hi Jan,

> gdb/
> 2009-03-24  Joel Brobecker  <brobecker@adacore.com>
> 	    Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Recognize missing DW_AT_location as <value optimized out>.
> 	* dwarf2read.c
> 	(new_symbol <DW_TAG_variable> <!DW_AT_location> <!DW_AT_external>):
> 	Call add_symbol_to_list.

I don't understand what you are trying to explain in your comment.
The way I came to the conclusion that we shouldn't create a symbol
for DIEs that have a non-zero DW_AT_declaration is that the DWARF
reference calls them as "incomplete, or non-defining" declarations.
As such, we don't have all the information about our variable yet,
and the absence of a DW_AT_location attribute can be normal. Normally,
the full definition should be provided elsewhere and this what we will
use to create the associated symbol.

In your comment, you are hinting at a C++ situation, so I'm guessing
that this situation is relevant to this thread and gave you a little bit
of trouble. Would you like to elaborate?

If you want to, we can commit the patch as is, with or without the
comment, and then work on a comment that we can both understand.
I would tend towards committing the patch without the comment. I'd
rather have no comment than a comment I don't understand.

> gdb/testsuite/
> 2009-03-25  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.dwarf2/dw2-noloc-main.c: New file.
> 	* gdb.dwarf2/dw2-noloc.S: New symbols matrix.
> 	(.text): Remove.
> 	(.data): New.
> 	(DW_AT_stmt_list, .debug_line, DW_AT_frame_base): Remove.
> 	(DW_AT_low_pc, DW_AT_high_pc): Reference `dw2-noloc-main.c'.
> 	(DW_TAG_subprogram func_cu1, noloc): Remove.
> 	(main): New.
> 	* gdb.dwarf2/dw2-noloc.exp: Use prepare_for_testing, compile also
> 	`dw2-noloc-main.c'.  Test the new DIEs from `dw2-noloc.S'.
> 	(file_symbols): New procedure.

This part looks OK to me as well.

-- 
Joel


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

* Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out>  symbols
  2009-03-26  0:38                   ` Joel Brobecker
@ 2009-03-26 17:02                     ` Jan Kratochvil
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Kratochvil @ 2009-03-26 17:02 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

On Thu, 26 Mar 2009 01:29:40 +0100, Joel Brobecker wrote:
> I don't understand what you are trying to explain in your comment.
> The way I came to the conclusion that we shouldn't create a symbol
> for DIEs that have a non-zero DW_AT_declaration is that the DWARF
> reference calls them as "incomplete, or non-defining" declarations.

thanks for this hint, I read now the DWARF3 section 4.1 points 3+4 again and
I did not consider a _declaration_ just cannot decide if its target object is
optimized out or not.

Now your simple condition (!die_is_declaration (die, cu)) makes sense to me as
it is in fact just directly written down in C the DWARF citation:
  that is, with no DW_AT_declaration attribute


> In your comment, you are hinting at a C++ situation, so I'm guessing
> that this situation is relevant to this thread and gave you a little bit
> of trouble. Would you like to elaborate?

If you start creating `optimized-out definitions' out of some declarations the
situation gets complicated to keep the whole testsuite regression free
especially wrt C++ code.

To be more specific I considered it risky for example for the case of:
namespace A { static int var = 2; }
int main (void)
{
  int var = 1;
  /* Access `var' containing 1.  */
  {
    using A::var;
    /* Access `var' now containing 2.  */
  }
  return 0;
}
So that starting to ignore the inner `var' declaration' would make `var==1'
accessible in the inner block from GDB.

But in this case innermost `var' is not DW_AT_variable but
DW_TAG_imported_declaration instead so my suspection was wrong.


I find tricky that cross-CU DW_AT_external _declaration_ should
add_symbol_to_list but non-DW_AT_external declaration should not.  This
discrepancy probably comes out of that DWARF does not use
DW_TAG_imported_declaration for cross-CU imports.  Going to post a separate
mail/patch for it.


Closed PR gdb/10002 is invalid as it was affected by my DW_AT_declaration
misunderstanding (as it is using DW_AT_declaration but DWARF is talking only
about the case for DW_AT_declaration not present)..

Also removed this KFAIL on gdb/10002 and wrote in gdb.dwarf2/dw2-noloc.exp:
    # `print file_extern_locno_unresolvable' currently prints
    # Address of symbol "file_extern_locno_unresolvable" is unknown.
    # As DW_AT_declaration is not present in this DIE
    # it should print <value optimized out>.  As usefulness of such DIE is not
    # clear its resolution is not being tested.
Maybe this testcase could also test the combination with DW_AT_declaration...


> If you want to, we can commit the patch as is, with or without the
> comment,

Checked-in without the comment.  Just changed gdb.dwarf2/dw2-noloc.exp as
described above:
http://sourceware.org/ml/gdb-cvs/2009-03/msg00203.html


Thanks,
Jan


gdb/
2009-03-26  Joel Brobecker  <brobecker@adacore.com>

	Recognize missing DW_AT_location as <value optimized out>.
	* dwarf2read.c
	(new_symbol <DW_TAG_variable> <!DW_AT_location> <!DW_AT_external>):
	Call add_symbol_to_list.

gdb/testsuite/
2009-03-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.dwarf2/dw2-noloc-main.c: New file.
	* gdb.dwarf2/dw2-noloc.S: New symbols matrix.
	(.text): Remove.
	(.data): New.
	(DW_AT_stmt_list, .debug_line, DW_AT_frame_base): Remove.
	(DW_AT_low_pc, DW_AT_high_pc): Reference `dw2-noloc-main.c'.
	(DW_TAG_subprogram func_cu1, noloc): Remove.
	(main): New.
	* gdb.dwarf2/dw2-noloc.exp: Use prepare_for_testing, compile also
	`dw2-noloc-main.c'.  Test the new DIEs from `dw2-noloc.S'.
	(file_symbols): New procedure.

--- src/gdb/dwarf2read.c	2009/03/20 22:00:10	1.297
+++ src/gdb/dwarf2read.c	2009/03/26 14:47:18	1.298
@@ -7659,6 +7659,12 @@
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
 		  add_symbol_to_list (sym, &global_symbols);
 		}
+	      else if (!die_is_declaration (die, cu))
+		{
+		  /* Use the default LOC_OPTIMIZED_OUT class.  */
+		  gdb_assert (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT);
+		  add_symbol_to_list (sym, cu->list_in_scope);
+		}
 	    }
 	  break;
 	case DW_TAG_formal_parameter:
--- src/gdb/testsuite/gdb.dwarf2/dw2-noloc-main.c
+++ src/gdb/testsuite/gdb.dwarf2/dw2-noloc-main.c	2009-03-26 14:49:00.626311000 +0000
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+asm (".globl cu_text_start");
+asm ("cu_text_start:");
+
+int
+main (void)
+{
+  return 0;
+}
+
+asm (".globl cu_text_end");
+asm ("cu_text_end:");
--- src/gdb/testsuite/gdb.dwarf2/dw2-noloc.S	2009/01/03 05:58:04	1.4
+++ src/gdb/testsuite/gdb.dwarf2/dw2-noloc.S	2009/03/26 14:47:19	1.5
@@ -15,16 +15,35 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-	.text
-.Lbegin_text1:
-	.globl func_cu1
-	.type func_cu1, %function
-func_cu1:
-.Lbegin_func_cu1:
-	.int 0
-.Lend_func_cu1:
-	.size func_cu1, .-func_cu1
-.Lend_text1:
+	.data
+
+	.globl	file_locaddr_resolvable
+file_locaddr_resolvable:
+	.globl	file_locempty_resolvable
+file_locempty_resolvable:
+	.globl	file_locno_resolvable
+file_locno_resolvable:
+	.globl	file_extern_locaddr_resolvable
+file_extern_locaddr_resolvable:
+	.globl	file_extern_locempty_resolvable
+file_extern_locempty_resolvable:
+	.globl	file_extern_locno_resolvable
+file_extern_locno_resolvable:
+	.globl	main_local_locaddr_resolvable
+main_local_locaddr_resolvable:
+	.globl	main_local_locempty_resolvable
+main_local_locempty_resolvable:
+	.globl	main_local_locno_resolvable
+main_local_locno_resolvable:
+	.globl	main_extern_locaddr_resolvable
+main_extern_locaddr_resolvable:
+	.globl	main_extern_locno_resolvable
+main_extern_locno_resolvable:
+	.globl	main_extern_locempty_resolvable
+main_extern_locempty_resolvable:
+
+resolvable:
+	.4byte	1234567890
 
 /* Debug information */
 
@@ -39,36 +58,169 @@
 
 	/* CU die */
 	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
-	.4byte	.Lline1_begin			/* DW_AT_stmt_list */
-	.4byte	.Lend_text1			/* DW_AT_high_pc */
-	.4byte	.Lbegin_text1			/* DW_AT_low_pc */
+	.4byte	cu_text_end			/* DW_AT_high_pc */
+	.4byte	cu_text_start			/* DW_AT_low_pc */
 	.ascii	"file1.txt\0"			/* DW_AT_name */
 	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
 	.byte	1				/* DW_AT_language (C) */
 
-	/* func_cu1 */
-	.uleb128	2			/* Abbrev: DW_TAG_subprogram */
-	.byte		1			/* DW_AT_external */
-	.byte		1			/* DW_AT_decl_file */
-	.byte		2			/* DW_AT_decl_line */
-	.ascii		"func_cu1\0"		/* DW_AT_name */
-	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
-	.4byte		.Lbegin_func_cu1	/* DW_AT_low_pc */
-	.4byte		.Lend_func_cu1		/* DW_AT_high_pc */
-	.byte		1			/* DW_AT_frame_base: length */
-	.byte		0x55			/* DW_AT_frame_base: DW_OP_reg5 */
-
 .Ltype_int:
 	.uleb128	3			/* Abbrev: DW_TAG_base_type */
 	.ascii		"int\0"			/* DW_AT_name */
 	.byte		4			/* DW_AT_byte_size */
 	.byte		5			/* DW_AT_encoding */
 
-	.uleb128	4			/* Abbrev: DW_TAG_variable */
-	.ascii		"noloc\0"		/* DW_AT_name */
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locaddr_resolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locaddr_unresolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locempty_resolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"file_locempty_unresolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"file_locno_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"file_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locaddr_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locaddr_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locempty_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"file_extern_locempty_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"file_extern_locno_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"file_extern_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	/* main */
+	.uleb128	6			/* Abbrev: DW_TAG_subprogram */
+	.byte		1			/* DW_AT_decl_file */
+	.byte		2			/* DW_AT_decl_line */
+	.ascii		"main\0"		/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.4byte		cu_text_start		/* DW_AT_low_pc */
+	.4byte		cu_text_end		/* DW_AT_high_pc */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locaddr_resolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locaddr_unresolvable\0"	/* DW_AT_name */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locempty_resolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	7			/* Abbrev: DW_TAG_variable (location) */
+	.ascii		"main_local_locempty_unresolvable\0"	/* DW_AT_name */
+	.byte		0			/* DW_AT_location */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"main_local_locno_resolvable\0"	/* DW_AT_name */
 	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	5			/* Abbrev: DW_TAG_variable (bare) */
+	.ascii		"main_local_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locaddr_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locaddr_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		2f - 1f			/* DW_AT_location */
+1:	.byte		3			/*   DW_OP_addr */
+	.4byte		resolvable		/*   <addr> */
+2:	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locempty_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	8			/* Abbrev: DW_TAG_variable (location+extern) */
+	.ascii		"main_extern_locempty_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		0			/* DW_AT_location */
 	.byte		1			/* DW_AT_external */
 
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"main_extern_locno_resolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.uleb128	4			/* Abbrev: DW_TAG_variable (extern) */
+	.ascii		"main_extern_locno_unresolvable\0"	/* DW_AT_name */
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
+	.byte		1			/* DW_AT_external */
+
+	.byte		0			/* End of children of main */
+
 	.byte		0			/* End of children of CU */
 
 .Lcu1_end:
@@ -79,8 +231,6 @@
 	.uleb128	1			/* Abbrev code */
 	.uleb128	0x11			/* DW_TAG_compile_unit */
 	.byte		1			/* has_children */
-	.uleb128	0x10			/* DW_AT_stmt_list */
-	.uleb128	0x6			/* DW_FORM_data4 */
 	.uleb128	0x12			/* DW_AT_high_pc */
 	.uleb128	0x1			/* DW_FORM_addr */
 	.uleb128	0x11			/* DW_AT_low_pc */
@@ -94,11 +244,43 @@
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	2			/* Abbrev code */
-	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.uleb128	3			/* Abbrev code */
+	.uleb128	0x24			/* DW_TAG_base_type */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0xb			/* DW_AT_byte_size */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x3e			/* DW_AT_encoding */
+	.uleb128	0xb			/* DW_FORM_data1 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	4			/* Abbrev code (extern) */
+	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
 	.uleb128	0x3f			/* DW_AT_external */
 	.uleb128	0xc			/* DW_FORM_flag */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	5			/* Abbrev code (bare) */
+	.uleb128	0x34			/* DW_TAG_variable */
+	.byte		0			/* has_children */
+	.uleb128	0x3			/* DW_AT_name */
+	.uleb128	0x8			/* DW_FORM_string */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
+	.byte		0x0			/* Terminator */
+	.byte		0x0			/* Terminator */
+
+	.uleb128	6			/* Abbrev code */
+	.uleb128	0x2e			/* DW_TAG_subprogram */
+	.byte		1			/* has_children */
 	.uleb128	0x3a			/* DW_AT_decl_file */
 	.uleb128	0xb			/* DW_FORM_data1 */
 	.uleb128	0x3b			/* DW_AT_decl_line */
@@ -111,30 +293,30 @@
 	.uleb128	0x1			/* DW_FORM_addr */
 	.uleb128	0x12			/* DW_AT_high_pc */
 	.uleb128	0x1			/* DW_FORM_addr */
-	.uleb128	0x40			/* DW_AT_frame_base */
-	.uleb128	0xa			/* DW_FORM_block1 */
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	3			/* Abbrev code */
-	.uleb128	0x24			/* DW_TAG_base_type */
+	.uleb128	7			/* Abbrev code (location) */
+	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
 	.uleb128	0x8			/* DW_FORM_string */
-	.uleb128	0xb			/* DW_AT_byte_size */
-	.uleb128	0xb			/* DW_FORM_data1 */
-	.uleb128	0x3e			/* DW_AT_encoding */
-	.uleb128	0xb			/* DW_FORM_data1 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
+	.uleb128	0x49			/* DW_AT_type */
+	.uleb128	0x13			/* DW_FORM_ref4 */
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
 
-	.uleb128	4			/* Abbrev code */
+	.uleb128	8			/* Abbrev code (location+extern) */
 	.uleb128	0x34			/* DW_TAG_variable */
 	.byte		0			/* has_children */
 	.uleb128	0x3			/* DW_AT_name */
 	.uleb128	0x8			/* DW_FORM_string */
 	.uleb128	0x49			/* DW_AT_type */
 	.uleb128	0x13			/* DW_FORM_ref4 */
+	.uleb128	0x2			/* DW_AT_location */
+	.uleb128	0xa			/* DW_FORM_block1 */
 	.uleb128	0x3f			/* DW_AT_external */
 	.uleb128	0xc			/* DW_FORM_flag */
 	.byte		0x0			/* Terminator */
@@ -142,69 +324,3 @@
 
 	.byte		0x0			/* Terminator */
 	.byte		0x0			/* Terminator */
-
-/* Line table */
-	.section .debug_line
-.Lline1_begin:
-	.4byte		.Lline1_end - .Lline1_start	/* Initial length */
-.Lline1_start:
-	.2byte		2			/* Version */
-	.4byte		.Lline1_lines - .Lline1_hdr	/* header_length */
-.Lline1_hdr:
-	.byte		1			/* Minimum insn length */
-	.byte		1			/* default_is_stmt */
-	.byte		1			/* line_base */
- 	.byte		1			/* line_range */
-	.byte		0x10			/* opcode_base */
-
-	/* Standard lengths */
-	.byte		0
-	.byte		1
-	.byte		1
-	.byte		1
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		0
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		1
-	.byte		0
-	.byte		0
-	.byte		0
-
-	/* Include directories */
-	.byte		0
-
-	/* File names */
-	.ascii		"file1.txt\0"
-	.uleb128	0
-	.uleb128	0
-	.uleb128	0
-
-	.byte		0
-
-.Lline1_lines:
-	.byte		0	/* DW_LNE_set_address */
-	.uleb128	5
-	.byte		2
-	.4byte		.Lbegin_func_cu1
-
-	.byte		3	/* DW_LNS_advance_line */
-	.sleb128	3	/* ... to 4 */
-
-	.byte		1	/* DW_LNS_copy */
-
-	.byte		1	/* DW_LNS_copy (second time as an end-of-prologue marker) */
-
-	.byte		0	/* DW_LNE_set_address */
-	.uleb128	5
-	.byte		2
-	.4byte		.Lend_func_cu1
-
-	.byte		0	/* DW_LNE_end_of_sequence */
-	.uleb128	1
-	.byte		1
-
-.Lline1_end:
--- src/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	2009/01/03 05:58:04	1.4
+++ src/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp	2009/03/26 14:47:19	1.5
@@ -24,25 +24,109 @@
     return 0  
 }
 
-set testfile "dw2-noloc"
-set srcfile ${testfile}.S
-set binfile ${objdir}/${subdir}/${testfile}.x
-
-if  { [gdb_compile "${srcdir}/${subdir}/main.c" "main.o" object {debug}] != "" } {
+if { [prepare_for_testing dw2-noloc.exp "dw2-noloc" {dw2-noloc-main.c dw2-noloc.S} {nodebug}] } {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${testfile}.o" object {nodebug}] != "" } {
-    return -1
+# Symbols have the form: {file,main}_loc{addr,empty,no}_{,un}resolvable
+# file: Symbol DIE is placed in DW_TAG_compile_unit.
+# main: Symbol DIE is placed in DW_TAG_subprogram.
+# locaddr: DW_AT_location is using DW_FORM_block DW_OP_addr <addr>.
+# locempty: DW_AT_location has zero DW_FORM_block size.
+# locno: DW_AT_location is not present.
+# resolvable: .symtab entry exists for this symbol name.
+# unresolvable: .symtab entry does not exist for this symbol name.
+# DW_AT_declaration is not present in any of these DIEs.
+
+proc file_symbols {type} {
+    global pf_prefix
+    set old_prefix $pf_prefix
+    lappend pf_prefix "$type:"
+
+    global gdb_prompt
+
+    gdb_test "print file_locaddr_resolvable" "= 1234567890"
+    gdb_test "ptype file_locaddr_resolvable" "type = int"
+
+    gdb_test "print file_locaddr_unresolvable" "= 1234567890"
+    gdb_test "ptype file_locaddr_unresolvable" "type = int"
+
+    gdb_test "print file_locempty_resolvable" "= <value optimized out>"
+    gdb_test "ptype file_locempty_resolvable" "type = int"
+
+    gdb_test "print file_locempty_unresolvable" "= <value optimized out>"
+    gdb_test "ptype file_locempty_unresolvable" "type = int"
+
+    gdb_test "print file_locno_resolvable" "= <value optimized out>"
+    gdb_test "ptype file_locno_resolvable" "type = int"
+
+    gdb_test "print file_locno_unresolvable" "= <value optimized out>"
+    gdb_test "ptype file_locno_unresolvable" "type = int"
+
+    gdb_test "print file_extern_locaddr_resolvable" "= 1234567890"
+    gdb_test "ptype file_extern_locaddr_resolvable" "type = int"
+
+    gdb_test "print file_extern_locaddr_unresolvable" "= 1234567890"
+    gdb_test "ptype file_extern_locaddr_unresolvable" "type = int"
+
+    gdb_test "print file_extern_locempty_resolvable" "= <value optimized out>"
+    gdb_test "ptype file_extern_locempty_resolvable" "type = int"
+
+    gdb_test "print file_extern_locempty_unresolvable" "= <value optimized out>"
+    gdb_test "ptype file_extern_locempty_unresolvable" "type = int"
+
+    gdb_test "print file_extern_locno_resolvable" "= 1234567890"
+    gdb_test "ptype file_extern_locno_resolvable" "type = int"
+
+    # `print file_extern_locno_unresolvable' currently prints
+    # Address of symbol "file_extern_locno_unresolvable" is unknown.
+    # As DW_AT_declaration is not present in this DIE
+    # it should print <value optimized out>.  As usefulness of such DIE is not
+    # clear its resolution is not being tested.
+
+    set pf_prefix $old_prefix
 }
 
-if  { [gdb_compile "${testfile}.o main.o" "${binfile}" executable {debug}] != "" } {
+file_symbols no-run
+
+if ![runto_main] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+file_symbols in-main
+
+
+gdb_test "print main_local_locaddr_resolvable" "= 1234567890"
+gdb_test "ptype main_local_locaddr_resolvable" "type = int"
+
+gdb_test "print main_local_locaddr_unresolvable" "= 1234567890"
+gdb_test "ptype main_local_locaddr_unresolvable" "type = int"
+
+gdb_test "print main_local_locempty_resolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locempty_resolvable" "type = int"
+
+gdb_test "print main_local_locempty_unresolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locempty_unresolvable" "type = int"
+
+gdb_test "print main_local_locno_resolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locno_resolvable" "type = int"
+
+gdb_test "print main_local_locno_unresolvable" "= <value optimized out>"
+gdb_test "ptype main_local_locno_unresolvable" "type = int"
+
+gdb_test "print main_extern_locaddr_resolvable" "= 1234567890"
+gdb_test "ptype main_extern_locaddr_resolvable" "type = int"
+
+gdb_test "print main_extern_locaddr_unresolvable" "= 1234567890"
+gdb_test "ptype main_extern_locaddr_unresolvable" "type = int"
+
+gdb_test "print main_extern_locempty_resolvable" "= <value optimized out>"
+gdb_test "ptype main_extern_locempty_resolvable" "type = int"
+
+gdb_test "print main_extern_locempty_unresolvable" "= <value optimized out>"
+gdb_test "ptype main_extern_locempty_unresolvable" "type = int"
+
+gdb_test "print main_extern_locno_resolvable" "= 1234567890"
+gdb_test "ptype main_extern_locno_resolvable" "type = int"
 
-gdb_test "print noloc" "Address of symbol \"noloc\" is unknown." "print noloc"
+# For `main_extern_locno_unresolvable' see `file_extern_locno_unresolvable'.


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

end of thread, other threads:[~2009-03-26 15:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-16 21:15 [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols Jan Kratochvil
2009-03-20 15:17 ` Joel Brobecker
2009-03-20 15:51   ` Joel Brobecker
2009-03-20 18:22     ` Jan Kratochvil
2009-03-20 18:39   ` Joel Brobecker
2009-03-20 18:51     ` [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp [Re: [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols] Jan Kratochvil
2009-03-20 19:54       ` Joel Brobecker
2009-03-20 21:54         ` Daniel Jacobowitz
2009-03-23 17:36         ` Joel Brobecker
2009-03-23 17:45           ` Jan Kratochvil
2009-03-23 22:52             ` Joel Brobecker
2009-03-24 23:50               ` [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols [Re: [patch] Racy FAIL: gdb.base/auxv.exp + gdb.base/callfuncs.exp] Jan Kratochvil
2009-03-25 10:03                 ` [patch/rfc] Recognize non-DW_AT_location <value optimized out> symbols Jan Kratochvil
2009-03-26  0:38                   ` Joel Brobecker
2009-03-26 17:02                     ` Jan Kratochvil
2009-03-20 19:18     ` Joel Brobecker

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