Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Berlin <dan@dberlin.org>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Let dwarf2 CFI's execute_stack_op be used outside of CFI
Date: Mon, 25 Mar 2002 15:57:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.44.0203251851190.6911-100000@dberlin.org> (raw)

This patch simply adds an external entry point (dwarf2_execute_stack_op), 
that doesn't require the CFA context. It also adds code so that when the 
context passed to execute_stack_op is NULL, we use read_register_gen to 
get registers.

Along the way, I made an obvious fix to DW_OP_deref_size that i'll commit 
separately, but included in the changelog/patch because i didn't want to 
hand edit it out.


I also added my name to the top of the file, since in reality, it's based 
on code I sent Jiri.

--Dan
2002-03-25  Daniel Berlin  <dan@dberlin.org>

	* dwarf2cfi.c (dwarf2_execute_stack_op): New function, external
	entry point to execute_stack_op that doesn't require context.
	(execute_stack_op): If context is NULL, don't use get_reg, use
	read_register_gen.
        Also fix bug in DW_OP_deref_size.

	* dwarf2cfi.h (dwarf2_execute_stack_op): New prototype.
Index: dwarf2cfi.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
retrieving revision 1.1
diff -c -3 -p -w -B -b -r1.1 dwarf2cfi.c
*** dwarf2cfi.c	2001/12/07 12:10:15	1.1
--- dwarf2cfi.c	2002/03/25 23:50:16
***************
*** 1,7 ****
  /* Stack unwinding code based on dwarf2 frame info for GDB, the GNU debugger.
!    Copyright 2001
     Free Software Foundation, Inc.
     Contributed by Jiri Smid, SuSE Labs.
  
     This file is part of GDB.
  
--- 1,8 ----
  /* Stack unwinding code based on dwarf2 frame info for GDB, the GNU debugger.
!    Copyright 2001, 2002
     Free Software Foundation, Inc.
     Contributed by Jiri Smid, SuSE Labs.
+    Based on code written by Daniel Berlin (dan@dberlin.org)
  
     This file is part of GDB.
  
*************** get_reg (char *reg, struct context *cont
*** 840,845 ****
--- 841,854 ----
      }
  }
  
+ /* External entry point for executing dwarf2 stack operations. */
+ CORE_ADDR
+ dwarf2_execute_stack_op (struct objfile *objfile, char *op_ptr,
+ 			 char *op_end, CORE_ADDR initial)
+ {
+   return execute_stack_op (objfile, op_ptr, op_end, NULL, initial);
+ }
+ 
  /* Decode a DW_OP stack program.  Return the top of stack.  Push INITIAL
     onto the stack to start.  */
  static CORE_ADDR
*************** execute_stack_op (struct objfile *objfil
*** 963,973 ****
--- 972,989 ----
  	case DW_OP_reg29:
  	case DW_OP_reg30:
  	case DW_OP_reg31:
+ 	  if (context)
  	    get_reg ((char *) &result, context, op - DW_OP_reg0);
+ 	  else
+ 	    read_register_gen (op - DW_OP_reg0, (char *)&result);
+ 	  
  	  break;
  	case DW_OP_regx:
  	  reg = read_uleb128 (objfile->obfd, &op_ptr);
+ 	  if (context)
  	    get_reg ((char *) &result, context, reg);
+ 	  else
+ 	    read_register_gen (reg, (char *)&result);
  	  break;
  
  	case DW_OP_breg0:
*************** execute_stack_op (struct objfile *objfil
*** 1003,1015 ****
--- 1019,1038 ----
  	case DW_OP_breg30:
  	case DW_OP_breg31:
  	  offset = read_sleb128 (objfile->obfd, &op_ptr);
+ 	  if (context)
  	    get_reg ((char *) &result, context, op - DW_OP_breg0);
+ 	  else
+ 	    read_register_gen (op - DW_OP_breg0, (char *)&result);
+ 	  
  	  result += offset;
  	  break;
  	case DW_OP_bregx:
  	  reg = read_uleb128 (objfile->obfd, &op_ptr);
  	  offset = read_sleb128 (objfile->obfd, &op_ptr);
+ 	  if (context)
  	    get_reg ((char *) &result, context, reg);
+ 	  else
+ 	    read_register_gen (reg, (char *)&result);
  	  result += offset;
  	  break;
  
*************** execute_stack_op (struct objfile *objfil
*** 1067,1080 ****
  	    {
  	    case DW_OP_deref:
  	      {
! 		char *ptr = (char *) result;
  		result = read_pointer (objfile->obfd, &ptr);
  	      }
  	      break;
  
  	    case DW_OP_deref_size:
  	      {
! 		char *ptr = (char *) result;
  		switch (*op_ptr++)
  		  {
  		  case 1:
--- 1090,1103 ----
  	    {
  	    case DW_OP_deref:
  	      {
! 		char *ptr = (char *) &result;
  		result = read_pointer (objfile->obfd, &ptr);
  	      }
  	      break;
  
  	    case DW_OP_deref_size:
  	      {
! 		char *ptr = (char *) &result;
  		switch (*op_ptr++)
  		  {
  		  case 1:
Index: dwarf2cfi.h
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.h,v
retrieving revision 1.1
diff -c -3 -p -w -B -b -r1.1 dwarf2cfi.h
*** dwarf2cfi.h	2001/12/07 12:10:15	1.1
--- dwarf2cfi.h	2002/03/25 23:50:16
*************** void cfi_get_saved_register (char *raw_b
*** 63,66 ****
--- 63,72 ----
  void cfi_virtual_frame_pointer (CORE_ADDR pc, int *frame_regnum,
  				LONGEST * frame_offset);
  
+ /*  Execute a set of DWARF2 stack operations, starting with INITIAL
+     as the address on the stack. */
+ CORE_ADDR dwarf2_execute_stack_op (struct objfile *objfile, 
+ 				   char *op_ptr, char *op_end,
+ 				   CORE_ADDR initial);
+ 
  #endif
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.2349
diff -c -3 -p -w -B -b -r1.2349 ChangeLog
*** ChangeLog	2002/03/25 19:47:39	1.2349
--- ChangeLog	2002/03/25 23:50:17
***************
*** 1,3 ****
--- 1,12 ----
+ 2002-03-25  Daniel Berlin  <dan@dberlin.org>
+ 
+ 	* dwarf2cfi.c (dwarf2_execute_stack_op): New function, external
+ 	entry point to execute_stack_op that doesn't require context.
+ 	(execute_stack_op): If context is NULL, don't use get_reg, use
+ 	read_register_gen.
+ 
+ 	* dwarf2cfi.h (dwarf2_execute_stack_op): New prototype.
+ 
  2002-03-25  Jeff Law (law@redhat.com)
  
  	* linux-proc.c (read_mapping): Scan up to end of line for filename.


             reply	other threads:[~2002-03-25 23:57 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-25 15:57 Daniel Berlin [this message]
2002-03-25 16:07 ` Andrew Cagney
2002-03-25 16:21   ` Daniel Berlin
2002-03-26  7:52     ` Daniel Berlin
2002-03-26  9:49     ` Andrew Cagney
2002-03-26  9:52       ` Daniel Berlin
2002-03-26 11:09       ` Daniel Berlin
2002-03-26 12:06         ` Andreas Jaeger
2002-03-26 17:59           ` Daniel Berlin
2002-03-27  0:09             ` Andreas Jaeger
2002-03-27  6:24               ` Andrew Cagney
2002-03-27  6:32                 ` Andreas Jaeger
2002-03-26 18:06       ` Andrew Cagney
2002-03-27 20:56         ` Richard Stallman
2002-03-26  9:27 ` Andrew Cagney
2002-03-26  9:49   ` Daniel Berlin
2002-03-26 11:59 ` Jim Blandy
2002-03-26 13:42 ` Jim Blandy
2002-03-26 14:43   ` Daniel Berlin
2002-03-26 14:53     ` Andrew Cagney
2002-03-26 15:26       ` Daniel Berlin
2002-03-26 17:09         ` Andrew Cagney
2002-03-26 17:18           ` Daniel Berlin
2002-03-26 18:12             ` Andrew Cagney
2002-03-26 18:19               ` Andrew Cagney
2002-03-26 18:26                 ` Daniel Berlin
2002-03-26 15:21     ` Jim Blandy
2002-03-26 19:17       ` Daniel Berlin
2002-03-28 13:12         ` Jim Blandy
2002-03-28 13:32           ` Daniel Berlin
2002-03-28 15:31             ` Jim Blandy
2002-03-29 17:06               ` Daniel Berlin
2002-04-01 11:00                 ` Jim Blandy
2002-04-02  6:59                   ` Daniel Berlin
2002-04-02 11:28                     ` Jim Blandy
2002-04-02 11:31                       ` Daniel Jacobowitz
2002-04-02 11:46                         ` Daniel Berlin
2002-04-02 11:57                           ` Daniel Jacobowitz
2002-04-02 13:12                             ` Daniel Berlin
2002-04-02 13:15                               ` Daniel Jacobowitz
2002-04-02 11:47                       ` Daniel Berlin
2002-04-02 18:55                       ` Daniel Berlin
2002-04-02 21:02                         ` Daniel Jacobowitz
2002-04-03 13:05                           ` Jim Blandy
2002-04-03 14:12                             ` Daniel Berlin
2002-04-03 12:58                         ` Stan Shebs
2002-04-03 18:59                 ` Andrew Cagney
2002-04-02  6:50               ` Petr Sorfa
2002-04-02  6:56                 ` Daniel Berlin
2002-04-02  8:19                   ` [PATCH] Let dwarf2 CFI's execute_stack_op be used outside ofCFI Petr Sorfa
2002-04-04 12:24               ` [PATCH] Let dwarf2 CFI's execute_stack_op be used outside of CFI Daniel Berlin
2002-04-04 12:30                 ` Daniel Jacobowitz
2002-04-04 13:11                 ` Jim Blandy
2002-03-28 15:03           ` Andrew Cagney
2002-03-27  7:50   ` Petr Sorfa
2002-03-27  8:09     ` Daniel Berlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0203251851190.6911-100000@dberlin.org \
    --to=dan@dberlin.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox