Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@red-bean.com>
To: Eli Zaretskii <eliz@gnu.org>, Michael Snyder <msnyder@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Fwd: Obvious: doc fix for 'struct memrange' in tracepoints.c
Date: Sun, 20 Nov 2005 05:44:00 -0000	[thread overview]
Message-ID: <8f2776cb0511191115l7e52d993rb82efb944d27d3d1@mail.gmail.com> (raw)
In-Reply-To: <uek5chpln.fsf@gnu.org>

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

On 11/19/05, Eli Zaretskii <eliz@gnu.org> wrote:
> How about introducing a macro, so that the code speaks for itself?

How does this look?

gdb/ChangeLog:
2005-11-19  Jim Blandy  <jimb@redhat.com>

	* tracepoint.c (memrange_absolute): New enum constant.
	(struct memrange, memrange_cmp, add_memrange, collect_symbol,
	stringify_collection_list, encode_actions): Use it instead of '-1'
	to indicate an fixed-address memory range.
	(Suggested by Eli Zaretskii.)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: jimb.gdb-tracepoints-memrange-absolute-enum.patch --]
[-- Type: text/x-patch; name="jimb.gdb-tracepoints-memrange-absolute-enum.patch", Size: 4997 bytes --]

gdb/ChangeLog:
2005-11-19  Jim Blandy  <jimb@redhat.com>

	* tracepoint.c (memrange_absolute): New enum constant.
	(struct memrange, memrange_cmp, add_memrange, collect_symbol,
	stringify_collection_list, encode_actions): Use it instead of '-1'
	to indicate an fixed-address memory range.
	(Suggested by Eli Zaretskii.)

Index: gdb/tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.81
diff -c -p -r1.81 tracepoint.c
*** gdb/tracepoint.c	19 Nov 2005 18:57:28 -0000	1.81
--- gdb/tracepoint.c	19 Nov 2005 19:13:29 -0000
*************** make_cleanup_free_actions (struct tracep
*** 1069,1077 ****
    return make_cleanup (do_free_actions_cleanup, t);
  }
  
  struct memrange
  {
!   int type;		/* -1 for absolute memory range, else basereg number */
    bfd_signed_vma start;
    bfd_signed_vma end;
  };
--- 1069,1082 ----
    return make_cleanup (do_free_actions_cleanup, t);
  }
  
+ enum {
+   memrange_absolute = -1
+ };
+ 
  struct memrange
  {
!   int type;		/* memrange_absolute for absolute memory range,
!                            else basereg number */
    bfd_signed_vma start;
    bfd_signed_vma end;
  };
*************** memrange_cmp (const void *va, const void
*** 1103,1109 ****
      return -1;
    if (a->type > b->type)
      return 1;
!   if (a->type == 0)
      {
        if ((bfd_vma) a->start < (bfd_vma) b->start)
  	return -1;
--- 1108,1114 ----
      return -1;
    if (a->type > b->type)
      return 1;
!   if (a->type == memrange_absolute)
      {
        if ((bfd_vma) a->start < (bfd_vma) b->start)
  	return -1;
*************** add_memrange (struct collection_list *me
*** 1175,1181 ****
        printf_filtered (",%ld)\n", len);
      }
  
!   /* type: -1 == memory, n == basereg */
    memranges->list[memranges->next_memrange].type = type;
    /* base: addr if memory, offset if reg relative.  */
    memranges->list[memranges->next_memrange].start = base;
--- 1180,1186 ----
        printf_filtered (",%ld)\n", len);
      }
  
!   /* type: memrange_absolute == memory, other n == basereg */
    memranges->list[memranges->next_memrange].type = type;
    /* base: addr if memory, offset if reg relative.  */
    memranges->list[memranges->next_memrange].start = base;
*************** add_memrange (struct collection_list *me
*** 1189,1195 ****
  				  memranges->listsize);
      }
  
!   if (type != -1)		/* Better collect the base register!  */
      add_register (memranges, type);
  }
  
--- 1194,1200 ----
  				  memranges->listsize);
      }
  
!   if (type != memrange_absolute)		/* Better collect the base register!  */
      add_register (memranges, type);
  }
  
*************** collect_symbol (struct collection_list *
*** 1226,1232 ****
  			   DEPRECATED_SYMBOL_NAME (sym), len, 
  			   tmp /* address */);
  	}
!       add_memrange (collect, -1, offset, len);	/* -1 == memory */
        break;
      case LOC_REGISTER:
      case LOC_REGPARM:
--- 1231,1237 ----
  			   DEPRECATED_SYMBOL_NAME (sym), len, 
  			   tmp /* address */);
  	}
!       add_memrange (collect, memrange_absolute, offset, len);
        break;
      case LOC_REGISTER:
      case LOC_REGPARM:
*************** stringify_collection_list (struct collec
*** 1441,1449 ****
          bfd_signed_vma length = list->list[i].end - list->list[i].start;
  
          /* The "%X" conversion specifier expects an unsigned argument,
!            so passing -1 to it directly gives you "FFFFFFFF" (or more,
!            depending on sizeof (unsigned)).  Special-case it.  */
!         if (list->list[i].type == -1)
            sprintf (end, "M-1,%s,%lX", tmp2, (long) length);
          else
            sprintf (end, "M%X,%s,%lX", list->list[i].type, tmp2, (long) length);
--- 1446,1455 ----
          bfd_signed_vma length = list->list[i].end - list->list[i].start;
  
          /* The "%X" conversion specifier expects an unsigned argument,
!            so passing -1 (memrange_absolute) to it directly gives you
!            "FFFFFFFF" (or more, depending on sizeof (unsigned)).
!            Special-case it.  */
!         if (list->list[i].type == memrange_absolute)
            sprintf (end, "M-1,%s,%lX", tmp2, (long) length);
          else
            sprintf (end, "M%X,%s,%lX", list->list[i].type, tmp2, (long) length);
*************** encode_actions (struct tracepoint *t, ch
*** 1605,1611 ****
  		      tempval = evaluate_expression (exp);
  		      addr = VALUE_ADDRESS (tempval) + value_offset (tempval);
  		      len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
! 		      add_memrange (collect, -1, addr, len);
  		      break;
  
  		    case OP_VAR_VALUE:
--- 1611,1617 ----
  		      tempval = evaluate_expression (exp);
  		      addr = VALUE_ADDRESS (tempval) + value_offset (tempval);
  		      len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
! 		      add_memrange (collect, memrange_absolute, addr, len);
  		      break;
  
  		    case OP_VAR_VALUE:

  reply	other threads:[~2005-11-19 19:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-19  4:45 Jim Blandy
2005-11-19  5:26 ` Daniel Jacobowitz
2005-11-19 12:42   ` Jim Blandy
     [not found]     ` <437E89C1.7050104@redhat.com>
     [not found]       ` <8f2776cb0511182044r7a653ae5w46f3f2a1ddcaeec7@mail.gmail.com>
2005-11-19 12:43         ` Fwd: " Jim Blandy
2005-11-19 12:56           ` Eli Zaretskii
2005-11-20  5:44             ` Jim Blandy [this message]
2005-11-20  5:47               ` Eli Zaretskii
2005-11-21  5:10                 ` Jim Blandy

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=8f2776cb0511191115l7e52d993rb82efb944d27d3d1@mail.gmail.com \
    --to=jimb@red-bean.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=msnyder@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