This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] overlay tests vs. harvard architectures.


The overlay test uses commands such as "print $foo_vma = &foo"
to record the addresses of functions for later comparison.

Unfortunately, on a harvard architecture, these expressons now
result in a conversion from address to pointer, often with loss
of information (32 bits crunched down to 16, for instance).

This change lets the test store the addresses in TCL variables, 
rather than in GDB variables, and avoids taking the address of
the function or running it thru an assignment, thereby avoiding
the address-to-pointer conversion.

2002-06-06  Michael Snyder  <msnyder@redhat.com>

	* gdb.base/overlays.exp: Record addresses of overlay
	functions in TCL variables rather than in GDB variables,
	to avoid having GDB convert them to pointers (with loss
	of information).

Index: overlays.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/overlays.exp,v
retrieving revision 1.3
diff -p -r1.3 overlays.exp
*** overlays.exp	13 Apr 2002 00:21:40 -0000	1.3
--- overlays.exp	6 Jun 2002 20:22:28 -0000
***************
*** 1,4 ****
! #   Copyright 1997, 1998 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
--- 1,4 ----
! #   Copyright 1997, 1998, 2002 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
*************** if ![runto_main] then {
*** 86,107 ****
  }
  
  # couple of convenience variables
! set fptrcast [string_to_regexp "(int (*)(int))"]
  set iptrcast [string_to_regexp "(int *)"]
  
  gdb_test "overlay manual" "" 
  gdb_test "overlay list" "No sections are mapped." "List with none mapped"
  
  # capture the LMA addresses of [foo bar baz grbx foox barx bazx grbxx]
  
! gdb_test "print \$foo_lma = &foo" \
! 	".* $fptrcast 0x.* <\\*foo\\*>"  "foo load addr"
! gdb_test "print \$bar_lma = &bar" \
! 	".* $fptrcast 0x.* <\\*bar\\*>"  "bar load addr"
! gdb_test "print \$baz_lma = &baz" \
! 	".* $fptrcast 0x.* <\\*baz\\*>"  "baz load addr"
! gdb_test "print \$grbx_lma = &grbx" \
! 	".* $fptrcast 0x.* <\\*grbx\\*>" "grbx load addr"
  gdb_test "print \$foox_lma = &foox" \
  	".* $iptrcast 0x.*"  "foox load addr"
  gdb_test "print \$barx_lma = &barx" \
--- 86,127 ----
  }
  
  # couple of convenience variables
! set fptrcast [string_to_regexp "{int (int)}"]
  set iptrcast [string_to_regexp "(int *)"]
+ set hexx "0x\[0-9abcdefABCDEF\]+"
  
  gdb_test "overlay manual" "" 
  gdb_test "overlay list" "No sections are mapped." "List with none mapped"
  
  # capture the LMA addresses of [foo bar baz grbx foox barx bazx grbxx]
  
! proc get_func_address { func func_sym msg } {
!     global gdb_prompt
!     global fptrcast
!     global hexx
! 
!     set func_addr 0
!     send_gdb "print $func\n" 
!     gdb_expect {
! 	-re "\\$\[0-9\]+ = $fptrcast (${hexx}) <$func_sym>.*$gdb_prompt $" {
! 	    set func_addr $expect_out(1,string)
! 	    pass "get $msg"
! 	}
! 	-re ".*$gdb_prompt $" {
! 	    fail "get $msg"
! 	}
! 	default {
! 	    fail "get $msg (timeout)"
! 	}
!     }
!     return $func_addr
! }
! 
! set foo_lma  [get_func_address "foo"  "\\*foo\\*"  "foo  load address"]
! set bar_lma  [get_func_address "bar"  "\\*bar\\*"  "bar  load address"]
! set baz_lma  [get_func_address "baz"  "\\*baz\\*"  "baz  load address"]
! set grbx_lma [get_func_address "grbx" "\\*grbx\\*" "grbx load address"]
! 
  gdb_test "print \$foox_lma = &foox" \
  	".* $iptrcast 0x.*"  "foox load addr"
  gdb_test "print \$barx_lma = &barx" \
*************** gdb_test "print \$grbxx_lma = &grbxx" \
*** 116,138 ****
  
  gdb_test "overlay map .ovly0" "" 
  gdb_test "overlay list" "Section .ovly0, loaded at.*, mapped at.*" "List ovly0"
! gdb_test "print \$foo_vma = &foo" \
! 	".* $fptrcast 0x.* <foo>"  "foo runtime addr"
  
  gdb_test "overlay map .ovly1" "" 
  gdb_test "overlay list" "Section .ovly1, loaded at.*, mapped at.*" "List ovly1"
! gdb_test "print \$bar_vma = &bar" \
! 	".* $fptrcast 0x.* <bar>"  "bar runtime addr"
  
  gdb_test "overlay map .ovly2" "" 
  gdb_test "overlay list" "Section .ovly2, loaded at.*, mapped at.*" "List ovly2"
! gdb_test "print \$baz_vma = &baz" \
! 	".* $fptrcast 0x.* <baz>"  "baz runtime addr"
  
  gdb_test "overlay map .ovly3" "" 
  gdb_test "overlay list" "Section .ovly3, loaded at.*, mapped at.*" "List ovly3"
! gdb_test "print \$grbx_vma = &grbx" \
! 	".* $fptrcast 0x.* <grbx>"  "grbx runtime addr"
  
  gdb_test "overlay map .data00" "" 
  gdb_test "overlay list" "Section .data00, loaded .*, mapped .*" "List data00"
--- 136,154 ----
  
  gdb_test "overlay map .ovly0" "" 
  gdb_test "overlay list" "Section .ovly0, loaded at.*, mapped at.*" "List ovly0"
! set foo_vma [get_func_address "foo"  "foo"  "foo  runtime address"]
  
  gdb_test "overlay map .ovly1" "" 
  gdb_test "overlay list" "Section .ovly1, loaded at.*, mapped at.*" "List ovly1"
! set bar_vma [get_func_address "bar"  "bar"  "bar  runtime address"]
  
  gdb_test "overlay map .ovly2" "" 
  gdb_test "overlay list" "Section .ovly2, loaded at.*, mapped at.*" "List ovly2"
! set baz_vma [get_func_address "baz"  "baz"  "baz  runtime address"]
  
  gdb_test "overlay map .ovly3" "" 
  gdb_test "overlay list" "Section .ovly3, loaded at.*, mapped at.*" "List ovly3"
! set grbx_vma [get_func_address "grbx" "grbx" "grbx runtime address"]
  
  gdb_test "overlay map .data00" "" 
  gdb_test "overlay list" "Section .data00, loaded .*, mapped .*" "List data00"
*************** gdb_test "print \$grbxx_vma = &grbxx" \
*** 156,165 ****
  
  # Verify that LMA != VMA
  
! gdb_test "print \$foo_lma   != \$foo_vma" ".* = 1"   "foo's LMA   != VMA"
! gdb_test "print \$bar_lma   != \$bar_vma" ".* = 1"   "bar's LMA   != VMA"
! gdb_test "print \$baz_lma   != \$baz_vma" ".* = 1"   "baz's LMA   != VMA"
! gdb_test "print \$grbx_lma  != \$grbx_vma" ".* = 1"  "grbx's LMA  != VMA"
  gdb_test "print \$foox_lma  != \$foox_vma" ".* = 1"  "foox's LMA  != VMA"
  gdb_test "print \$barx_lma  != \$barx_vma" ".* = 1"  "barx's LMA  != VMA"
  gdb_test "print \$bazx_lma  != \$bazx_vma" ".* = 1"  "bazx's LMA  != VMA"
--- 172,181 ----
  
  # Verify that LMA != VMA
  
! gdb_test "print $foo_lma   != $foo_vma" ".* = 1"   "foo's LMA   != VMA"
! gdb_test "print $bar_lma   != $bar_vma" ".* = 1"   "bar's LMA   != VMA"
! gdb_test "print $baz_lma   != $baz_vma" ".* = 1"   "baz's LMA   != VMA"
! gdb_test "print $grbx_lma  != $grbx_vma" ".* = 1"  "grbx's LMA  != VMA"
  gdb_test "print \$foox_lma  != \$foox_vma" ".* = 1"  "foox's LMA  != VMA"
  gdb_test "print \$barx_lma  != \$barx_vma" ".* = 1"  "barx's LMA  != VMA"
  gdb_test "print \$bazx_lma  != \$bazx_vma" ".* = 1"  "bazx's LMA  != VMA"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]