This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[patch] Instruction packing with debugging for d10v gas
- To: binutils at sources dot redhat dot com
- Subject: [patch] Instruction packing with debugging for d10v gas
- From: Matthew Hiller <hiller at redhat dot com>
- Date: Wed, 1 Nov 2000 14:22:56 -0800 (PST)
The d10v assembler, when possible, packs adjacent short instructions
into a single packed instruction. When the assembler is invoked with
--gstabs, however, this behavior is suppressed. The following patch
enables packing even when --gstabs is specified, unless
--gstabs-no-packing is specified as well.
gdb handles this in a mostly graceful manner. The only problem is that
the patched assembler will generate pairs of stabs asm lineno directives
at a single PC. When looking up a line number based on the program's PC
(i.e., after a step or upon hitting a breakpoint), gdb will conclude that
execution has stopped at the second of the two line numbers. This is
undesirable, but it looks as though solutions to this particular problem
will be quite involved.
2000-11-01 Matthew Hiller <hiller@redhat.com>
* stabs.c (stabs_generate_asm_lineno): Sets
d10v_generating_lineno_gstab at function start, unsets it at
function end.
* config/tc-d10v.c (flag_no_gstabs_packing): New variable.
(md_longopts): New option --gstabs-no-packing.
(md_show_usage): New option --gstabs-no-packing.
(md_parse_option): New option --gstabs-no-packing.
(d10v_generating_lineno_gstab): New variable.
(d10v_cleanup): Writes pending instruction only if
!d10v_generating_lineno_gstab || flag_no_gstabs_packing.
* config/tc-d10.h (d10v_generating_lineno_gstab): New extern
declaration.
Index: stabs.c
===================================================================
RCS file: /cvs/src/src/gas/stabs.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 stabs.c
*** stabs.c 2000/09/12 03:56:22 1.6
--- stabs.c 2000/11/01 21:48:56
*************** stabs_generate_asm_lineno ()
*** 558,563 ****
--- 558,567 ----
char *buf;
char sym[30];
+ #ifdef TC_D10V
+ d10v_generating_lineno_gstab = 1;
+ #endif
+
/* Rather than try to do this in some efficient fashion, we just
generate a string and then parse it again. That lets us use the
existing stabs hook, which expect to see a string, rather than
*************** stabs_generate_asm_lineno ()
*** 588,593 ****
--- 592,600 ----
colon (sym);
input_line_pointer = hold;
+ #ifdef TC_D10V
+ d10v_generating_lineno_gstab = 0;
+ #endif
}
/* Emit a function stab.
Index: config/tc-d10v.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-d10v.c,v
retrieving revision 1.13
diff -c -3 -p -r1.13 tc-d10v.c
*** tc-d10v.c 2000/08/04 01:01:32 1.13
--- tc-d10v.c 2000/11/01 21:48:56
*************** static packing_type etype = PACK_UNSPEC;
*** 72,77 ****
--- 72,78 ----
/* True if instruction swapping warnings should be inhibited. */
static unsigned char flag_warn_suppress_instructionswap; /* --nowarnswap */
+ static unsigned char flag_no_gstabs_packing; /* --no-gstabs-packing */
/* Local functions. */
static int reg_name_search PARAMS ((char *name));
*************** struct option md_longopts[] =
*** 98,103 ****
--- 99,107 ----
{
#define OPTION_NOWARNSWAP (OPTION_MD_BASE)
{"nowarnswap", no_argument, NULL, OPTION_NOWARNSWAP},
+ #define OPTION_NOGSTABSPACKING (OPTION_MD_BASE + 1)
+ {"nogstabspacking", no_argument, NULL, OPTION_NOGSTABSPACKING},
+ {"no-gstabs-packing", no_argument, NULL, OPTION_NOGSTABSPACKING},
{NULL, no_argument, NULL, 0}
};
*************** md_show_usage (stream)
*** 232,238 ****
FILE *stream;
{
fprintf (stream, _("D10V options:\n\
! -O optimize. Will do some operations in parallel.\n"));
}
int
--- 236,244 ----
FILE *stream;
{
fprintf (stream, _("D10V options:\n\
! -O optimize. Will do some operations in parallel.\n
! --no-gstabs-packing if --gstabs is specified, do not pack adjacent\n\
! instructions together\n"));
}
int
*************** md_parse_option (c, arg)
*** 249,254 ****
--- 255,263 ----
case OPTION_NOWARNSWAP:
flag_warn_suppress_instructionswap = 1;
break;
+ case OPTION_NOGSTABSPACKING:
+ flag_no_gstabs_packing = 1;
+ break;
default:
return 0;
}
*************** md_apply_fix3 (fixp, valuep, seg)
*** 1611,1619 ****
}
return 0;
}
! /* Called after the assembler has finished parsing the input file or
! after a label is defined. Because the D10V assembler sometimes
saves short instructions to see if it can package them with the
next instruction, there may be a short instruction that still needs
to be written.
--- 1620,1631 ----
}
return 0;
}
+
+ unsigned char d10v_generating_lineno_gstab = 0;
! /* Called after the assembler has finished parsing the input file,
! after a label is defined, or an assembly line-debugging directive is
! automatcially generated. Because the D10V assembler sometimes
saves short instructions to see if it can package them with the
next instruction, there may be a short instruction that still needs
to be written.
*************** d10v_cleanup ()
*** 1631,1641 ****
{
seg = now_seg;
subseg = now_subseg;
! if (prev_seg)
! subseg_set (prev_seg, prev_subseg);
! write_1_short (prev_opcode, prev_insn, fixups->next);
subseg_set (seg, subseg);
- prev_opcode = NULL;
}
return 1;
}
--- 1643,1661 ----
{
seg = now_seg;
subseg = now_subseg;
! /* If d10v_cleanup was invoked from somewhere other than
! stabs_generate_asm_lineno we write out the pending instruction.
! If it was invoked from stabs_generate_asm_lineno, we
! write on the pending instruction only if --no-gstabs-packing
! was specified on the command line. */
! if (!d10v_generating_lineno_gstab || flag_no_gstabs_packing)
! {
! if (prev_seg)
! subseg_set (prev_seg, prev_subseg);
! write_1_short (prev_opcode, prev_insn, fixups->next);
! prev_opcode = NULL;
! }
subseg_set (seg, subseg);
}
return 1;
}
Index: config/tc-d10v.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-d10v.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 tc-d10v.h
*** tc-d10v.h 2000/09/26 07:09:18 1.4
--- tc-d10v.h 2000/11/01 21:48:56
*************** boolean d10v_fix_adjustable PARAMS ((fix
*** 65,67 ****
--- 65,69 ----
extern int d10v_force_relocation PARAMS ((fixS *));
#define md_flush_pending_output d10v_cleanup
+
+ extern unsigned char d10v_generating_lineno_gstab