This is the mail archive of the binutils@sourceware.cygnus.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]

PATCH objdump source interlist


This patch fixes a bug preventing objdump from printing the very first
line of a file when interlisting source and assembly code.  It also adds
an option to include the entire beginning of the source file up to the
current source line when the source file is first encountered.

* binutils/objdump.c (show_line): Allow line zero to be printed when
interlisting source.  If 'file_start_context' is set, include all source
file lines previous to the current one if this is the first line from
that source file.
* binutils/binutils.texi: Add documentation for --file-start-context.




Index: binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/binutils.texi,v
retrieving revision 1.18
diff -d -c -p -r1.18 binutils.texi
*** binutils.texi	2000/01/28 01:06:37	1.18
--- binutils.texi	2000/02/08 14:46:37
*************** objdump [ -a | --archive-headers ] 
*** 1171,1176 ****
--- 1171,1177 ----
          [ -z | --disassemble-zeroes ]
          [ -EB | -EL | --endian=@{big | little @} ]
          [ -f | --file-headers ]
+         [ --file-start-context ]
          [ -g | --debugging ]
          [ -h | --section-headers | --headers ]
          [ -i | --info ]
*************** does not describe endianness information
*** 1298,1303 ****
--- 1299,1310 ----
  @cindex object file header
  Display summary information from the overall header of
  each of the @var{objfile} files.
+ 
+ @item --file-start-context
+ @cindex source code context
+ Specify that when displaying interlisted source code/disassembly
+ (assumes '-S') from a file that has not yet been displayed, extend the
+ context to the start of the file.
  
  @item -h
  @itemx --section-header
Index: objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.16
diff -d -c -p -r1.16 objdump.c
*** objdump.c	2000/02/03 18:12:55	1.16
--- objdump.c	2000/02/08 14:46:38
*************** static bfd_vma start_address = (bfd_vma)
*** 75,80 ****
--- 75,81 ----
  static bfd_vma stop_address = (bfd_vma) -1;  /* --stop-address */
  static int dump_debugging;		/* --debugging */
  static bfd_vma adjust_section_vma = 0;	/* --adjust-vma */
+ static int file_start_context = 0;      /* --file-start-context */
  
  /* Extra info to pass to the disassembler address printing function.  */
  struct objdump_disasm_info {
*************** usage (stream, status)
*** 257,262 ****
--- 258,264 ----
    -M  --disassembler-options <o> Pass text <o> on to the disassembler\n\
    -EB --endian=big               Assume big endian format when disassembling\n\
    -EL --endian=little            Assume little endian format when disassembling\n\
+       --file-start-context       Include context from start of file (with -S)\n\
    -l  --line-numbers             Include line numbers and filenames in output\n\
    -C  --demangle                 Decode mangled/processed symbol names\n\
    -w  --wide                     Format output for more than 80 columns\n\
*************** static struct option long_options[]=
*** 300,305 ****
--- 302,308 ----
    {"dynamic-syms", no_argument, NULL, 'T'},
    {"endian", required_argument, NULL, OPTION_ENDIAN},
    {"file-headers", no_argument, NULL, 'f'},
+   {"file-start-context", no_argument, &file_start_context, 1},
    {"full-contents", no_argument, NULL, 's'},
    {"headers", no_argument, NULL, 'h'},
    {"help", no_argument, NULL, 'H'},
*************** show_line (abfd, section, addr_offset)
*** 1076,1083 ****
  	      else
  		{
  		  l = line - SHOW_PRECEDING_CONTEXT_LINES;
! 		  if (l <= 0)
! 		    l = 1;
  		}
  
  	      if (p->f == NULL)
--- 1079,1086 ----
  	      else
  		{
  		  l = line - SHOW_PRECEDING_CONTEXT_LINES;
! 		  if (l < 0)
! 		    l = 0;
  		}
  
  	      if (p->f == NULL)
*************** show_line (abfd, section, addr_offset)
*** 1127,1135 ****
  	      p->next = print_files;
  	      print_files = p;
  
! 	      l = line - SHOW_PRECEDING_CONTEXT_LINES;
! 	      if (l <= 0)
! 		l = 1;
  	      skip_to_line (p, l, false);
  	      if (p->f != NULL)
  		skip_to_line (p, line, true);
--- 1130,1141 ----
  	      p->next = print_files;
  	      print_files = p;
  
!               if (file_start_context)
!                 l = 0;
!               else
!                 l = line - SHOW_PRECEDING_CONTEXT_LINES;
! 	      if (l < 0)
! 		l = 0;
  	      skip_to_line (p, l, false);
  	      if (p->f != NULL)
  		skip_to_line (p, line, true);

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