This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: Decode function entry mask on VAXen


On Tue, Mar 08, 2005 at 10:44:00PM +1030, Alan Modra wrote:
> objdump already breaks up calls to disassemble_bytes into the pieces of
> a section between two defined symbols (possibly validated by a target
> symbol_is_valid function).  So if the only symbols in vax code are those
> at the beginning of a function, your idea of using last_symbol_address
> will work.  However, I think it would be better to pass
> "asymbol *last_symbol" instead, which gives your backend disassembler_fn
> a chance to deal with non-function symbols that might appear in code.

Here's a new version, which indeed works even better than the previous
version (correctly, there's no entry mask decoded for hand-crafted
assembler parts that we jump to). Could you please also comment on this?

diff -Nurp ../cvs-repos/binutils/binutils-upstream-HEAD/binutils/objdump.c src/binutils/objdump.c
--- ../cvs-repos/binutils/binutils-upstream-HEAD/binutils/objdump.c	2005-03-01 16:18:42.000000000 +0100
+++ src/binutils/objdump.c	2005-03-08 19:40:46.000000000 +0100
@@ -1379,7 +1379,12 @@ disassemble_bytes (struct disassemble_in
 	      info->stream = (FILE *) &sfile;
 	      info->bytes_per_line = 0;
 	      info->bytes_per_chunk = 0;
-	      info->flags = 0;
+	      info->last_symbol = find_symbol_for_address (section->vma +
+			      start_offset, info, NULL);
+	      if (disassemble && disassemble_all)
+		info->flags = FORCE_DISASSEMBLE;
+	      else
+		info->flags = 0;
 
 #ifdef DISASSEMBLER_NEEDS_RELOCS
 	      if (*relppp < relppend)
diff -Nurp ../cvs-repos/binutils/binutils-upstream-HEAD/include/dis-asm.h src/include/dis-asm.h
--- ../cvs-repos/binutils/binutils-upstream-HEAD/include/dis-asm.h	2005-03-03 12:58:01.000000000 +0100
+++ src/include/dis-asm.h	2005-03-08 19:39:36.000000000 +0100
@@ -98,7 +98,11 @@ typedef struct disassemble_info {
      The top 16 bits are reserved for public use (and are documented here).
      The bottom 16 bits are for the internal use of the disassembler.  */
   unsigned long flags;
-#define INSN_HAS_RELOC	0x80000000
+#define INSN_HAS_RELOC		0x80000000
+#define FORCE_DISASSEMBLE	0x40000000	/* Force disassembly of the
+						   address, even if it was
+						   probably better handled in
+						   a different way  */
   void *private_data;
 
   /* Function used to get bytes to disassemble.  MEMADDR is the
@@ -187,6 +191,7 @@ typedef struct disassemble_info {
   bfd_vma target;		/* Target address of branch or dref, if known;
 				   zero if unknown.  */
   bfd_vma target2;		/* Second target address for dref2 */
+  asymbol *last_symbol;		/* Address of last symbol or section start  */
 
   /* Command line options specific to the target disassembler.  */
   char * disassembler_options;
diff -Nurp ../cvs-repos/binutils/binutils-upstream-HEAD/opcodes/vax-dis.c src/opcodes/vax-dis.c
--- ../cvs-repos/binutils/binutils-upstream-HEAD/opcodes/vax-dis.c	2002-05-10 01:11:30.000000000 +0200
+++ src/opcodes/vax-dis.c	2005-03-08 19:51:47.000000000 +0100
@@ -1,5 +1,5 @@
 /* Print VAX instructions.
-   Copyright 1995, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright 1995, 1998, 2000-2002, 2005 Free Software Foundation, Inc.
    Contributed by Pauline Middelink <middelin@polyware.iaf.nl>
 
 This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,21 @@ static char *reg_names[] =
   "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc"
 };
 
+/* Definitions for the function entry mask bits.  */
+static char *entry_mask_bit[] =
+{
+  /* Registers 0 and 1 shall not be saved, since they're used to pass back
+     a function's result to it's caller...  */
+  "~r0~", "~r1~",
+  /* Registers 2 .. 11 are normal registers.  */
+  "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11",
+  /* Registers 12 and 13 are argument and frame pointer and must not
+     be saved by using the entry mask.  */
+  "~ap~", "~fp~",
+  /* Bits 14 and 15 control integer and decimal overflow.  */
+  "IntOvfl", "DecOvfl",
+};
+
 /* Sign-extend an (unsigned char). */
 #if __STDC__ == 1
 #define COERCE_SIGNED_CHAR(ch) ((signed char)(ch))
@@ -140,6 +155,28 @@ print_insn_vax (memaddr, info)
       buffer[1] = 0;
     }
 
+  /* Decode function entry mask.  */
+  if (info->last_symbol
+		  && (info->last_symbol->flags & BSF_FUNCTION)
+		  && !(info->flags & FORCE_DISASSEMBLE)
+		  && memaddr == bfd_asymbol_value (info->last_symbol))
+    {
+      int i = 0;
+      int register_mask = buffer[1] << 8 | buffer[0];
+
+      (*info->fprintf_func) (info->stream, "Entry mask 0x%04x = <",
+			     register_mask);
+
+      for (i = 15; i >= 0; i--)
+	if (register_mask & (1 << i))
+          (*info->fprintf_func) (info->stream, " %s",
+			entry_mask_bit[i]);
+
+      (*info->fprintf_func) (info->stream, " >");
+
+      return 2;
+    }
+
   for (votp = &votstrs[0]; votp->name[0]; votp++)
     {
       register vax_opcodeT opcode = votp->detail.code;

> Note that gdb also uses the disassembler, so it would be a good idea to
> see how your ideas fit in with gdb too.

Still don't have a NetBSD installation, but I'll post this patch to the
NetBSD-VAX in a minute, too.

Thanks, JBG

-- 
AWEK microdata GmbH -- Am Wellbach 4 -- 33609 Bielefeld


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