This is the mail archive of the gdb-patches@sourceware.org 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]

[commit] Fix "set debug arch 1" crash


Hello,

"set debug arch 1" is currently crashing because gdbarch_dump attempts 
to use paddr_nz to output CORE_ADDR values.  This routine tries to 
truncate the output to gdbarch_addr_bits (current_gdbarch) bits -- which
crashes, because current_gdbarch is NULL at this point.

In any case, it doesn't make much sense to try to truncate debug output
in the first place.  The patch below replaces this by core_addr_to_string_nz
(also two other places that do debug output in target.c).

Tested on powerpc-linux.  Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* gdbarch.sh (gdbarch_dump): Use core_addr_to_string_nz
	instead of paddr_nz.
	* gdbarch.c: Regenerate.

	* target.c (target_xfer_partial, debug_print_register): Use
	core_addr_to_string_nz instead of paddr_nz.

Index: gdb/gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.436
diff -c -p -r1.436 gdbarch.c
*** gdb/gdbarch.c	5 Sep 2008 11:42:31 -0000	1.436
--- gdb/gdbarch.c	5 Sep 2008 12:04:21 -0000
*************** gdbarch_dump (struct gdbarch *gdbarch, s
*** 743,756 ****
                        "gdbarch_dump: core_xfer_shared_libraries = <0x%lx>\n",
                        (long) gdbarch->core_xfer_shared_libraries);
    fprintf_unfiltered (file,
!                       "gdbarch_dump: decr_pc_after_break = 0x%s\n",
!                       paddr_nz (gdbarch->decr_pc_after_break));
    fprintf_unfiltered (file,
                        "gdbarch_dump: deprecated_fp_regnum = %s\n",
                        plongest (gdbarch->deprecated_fp_regnum));
    fprintf_unfiltered (file,
!                       "gdbarch_dump: deprecated_function_start_offset = 0x%s\n",
!                       paddr_nz (gdbarch->deprecated_function_start_offset));
    fprintf_unfiltered (file,
                        "gdbarch_dump: gdbarch_displaced_step_copy_insn_p() = %d\n",
                        gdbarch_displaced_step_copy_insn_p (gdbarch));
--- 743,756 ----
                        "gdbarch_dump: core_xfer_shared_libraries = <0x%lx>\n",
                        (long) gdbarch->core_xfer_shared_libraries);
    fprintf_unfiltered (file,
!                       "gdbarch_dump: decr_pc_after_break = %s\n",
!                       core_addr_to_string_nz (gdbarch->decr_pc_after_break));
    fprintf_unfiltered (file,
                        "gdbarch_dump: deprecated_fp_regnum = %s\n",
                        plongest (gdbarch->deprecated_fp_regnum));
    fprintf_unfiltered (file,
!                       "gdbarch_dump: deprecated_function_start_offset = %s\n",
!                       core_addr_to_string_nz (gdbarch->deprecated_function_start_offset));
    fprintf_unfiltered (file,
                        "gdbarch_dump: gdbarch_displaced_step_copy_insn_p() = %d\n",
                        gdbarch_displaced_step_copy_insn_p (gdbarch));
*************** gdbarch_dump (struct gdbarch *gdbarch, s
*** 818,825 ****
                        "gdbarch_dump: frame_align = <0x%lx>\n",
                        (long) gdbarch->frame_align);
    fprintf_unfiltered (file,
!                       "gdbarch_dump: frame_args_skip = 0x%s\n",
!                       paddr_nz (gdbarch->frame_args_skip));
    fprintf_unfiltered (file,
                        "gdbarch_dump: gdbarch_frame_num_args_p() = %d\n",
                        gdbarch_frame_num_args_p (gdbarch));
--- 818,825 ----
                        "gdbarch_dump: frame_align = <0x%lx>\n",
                        (long) gdbarch->frame_align);
    fprintf_unfiltered (file,
!                       "gdbarch_dump: frame_args_skip = %s\n",
!                       core_addr_to_string_nz (gdbarch->frame_args_skip));
    fprintf_unfiltered (file,
                        "gdbarch_dump: gdbarch_frame_num_args_p() = %d\n",
                        gdbarch_frame_num_args_p (gdbarch));
Index: gdb/gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.477
diff -c -p -r1.477 gdbarch.sh
*** gdb/gdbarch.sh	5 Sep 2008 11:42:31 -0000	1.477
--- gdb/gdbarch.sh	5 Sep 2008 12:04:22 -0000
*************** do
*** 318,325 ****
  	# An optional expression that convers MEMBER to a value
  	# suitable for formatting using %s.
  
! 	# If PRINT is empty, paddr_nz (for CORE_ADDR) or plongest
! 	# (anything else) is used.
  
      garbage_at_eol ) : ;;
  
--- 318,325 ----
  	# An optional expression that convers MEMBER to a value
  	# suitable for formatting using %s.
  
! 	# If PRINT is empty, core_addr_to_string_nz (for CORE_ADDR)
! 	# or plongest (anything else) is used.
  
      garbage_at_eol ) : ;;
  
*************** do
*** 1474,1481 ****
  	# It is a variable
  	case "${print}:${returntype}" in
  	    :CORE_ADDR )
! 		fmt="0x%s"
! 		print="paddr_nz (gdbarch->${function})"
  		;;
  	    :* )
  	        fmt="%s"
--- 1474,1481 ----
  	# It is a variable
  	case "${print}:${returntype}" in
  	    :CORE_ADDR )
! 		fmt="%s"
! 		print="core_addr_to_string_nz (gdbarch->${function})"
  		;;
  	    :* )
  	        fmt="%s"
Index: gdb/target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.180
diff -c -p -r1.180 target.c
*** gdb/target.c	5 Sep 2008 11:50:57 -0000	1.180
--- gdb/target.c	5 Sep 2008 12:04:22 -0000
*************** target_xfer_partial (struct target_ops *
*** 1168,1179 ****
        const unsigned char *myaddr = NULL;
  
        fprintf_unfiltered (gdb_stdlog,
! 			  "%s:target_xfer_partial (%d, %s, 0x%lx,  0x%lx,  0x%s, %s) = %s",
  			  ops->to_shortname,
  			  (int) object,
  			  (annex ? annex : "(null)"),
  			  (long) readbuf, (long) writebuf,
! 			  paddr_nz (offset), plongest (len), plongest (retval));
  
        if (readbuf)
  	myaddr = readbuf;
--- 1168,1180 ----
        const unsigned char *myaddr = NULL;
  
        fprintf_unfiltered (gdb_stdlog,
! 			  "%s:target_xfer_partial (%d, %s, 0x%lx,  0x%lx,  %s, %s) = %s",
  			  ops->to_shortname,
  			  (int) object,
  			  (annex ? annex : "(null)"),
  			  (long) readbuf, (long) writebuf,
! 			  core_addr_to_string_nz (offset),
! 			  plongest (len), plongest (retval));
  
        if (readbuf)
  	myaddr = readbuf;
*************** debug_print_register (const char * func,
*** 2565,2572 ****
        if (size <= sizeof (LONGEST))
  	{
  	  ULONGEST val = extract_unsigned_integer (buf, size);
! 	  fprintf_unfiltered (gdb_stdlog, " 0x%s %s",
! 			      paddr_nz (val), plongest (val));
  	}
      }
    fprintf_unfiltered (gdb_stdlog, "\n");
--- 2566,2573 ----
        if (size <= sizeof (LONGEST))
  	{
  	  ULONGEST val = extract_unsigned_integer (buf, size);
! 	  fprintf_unfiltered (gdb_stdlog, " %s %s",
! 			      core_addr_to_string_nz (val), plongest (val));
  	}
      }
    fprintf_unfiltered (gdb_stdlog, "\n");
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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