dbxelf.h revision 52284
133965Sjdp/* Definitions needed when using stabs embedded in ELF sections.
233965Sjdp   Copyright (C) 1999 Free Software Foundation, Inc.
333965Sjdp
433965SjdpThis file is part of GNU CC.
533965Sjdp
633965SjdpGNU CC is free software; you can redistribute it and/or modify
733965Sjdpit under the terms of the GNU General Public License as published by
889857Sobrienthe Free Software Foundation; either version 2, or (at your option)
989857Sobrienany later version.
1089857Sobrien
1189857SobrienGNU CC is distributed in the hope that it will be useful,
1289857Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1389857SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1489857SobrienGNU General Public License for more details.
1589857Sobrien
1689857SobrienYou should have received a copy of the GNU General Public License
1789857Sobrienalong with GNU CC; see the file COPYING.  If not, write to
1889857Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
1989857SobrienBoston, MA 02111-1307, USA.  */
2089857Sobrien
2189857Sobrien/* This file may be included by any ELF target which wishes to
2233965Sjdp   support -gstabs generating stabs in sections, as produced by gas
2333965Sjdp   and understood by gdb.  */
2433965Sjdp
25218822Sdim#ifndef __DBX_ELF_H
26218822Sdim#define __DBX_ELF_H
27218822Sdim
2833965Sjdp/* Output DBX (stabs) debugging information if doing -gstabs.  */
2933965Sjdp
3033965Sjdp#undef  DBX_DEBUGGING_INFO
3133965Sjdp#define DBX_DEBUGGING_INFO
3233965Sjdp
3333965Sjdp/* Make LBRAC and RBRAC addresses relative to the start of the
3433965Sjdp   function.  The native Solaris stabs debugging format works this
35104834Sobrien   way, gdb expects it, and it reduces the number of relocation
36104834Sobrien   entries...  */
37104834Sobrien
38104834Sobrien#undef  DBX_BLOCKS_FUNCTION_RELATIVE
3933965Sjdp#define DBX_BLOCKS_FUNCTION_RELATIVE 1
40218822Sdim
41104834Sobrien/* ... but, to make this work, functions must appear prior to line info.  */
4233965Sjdp
43218822Sdim#undef  DBX_FUNCTION_FIRST
4433965Sjdp#define DBX_FUNCTION_FIRST
4533965Sjdp
46218822Sdim/* When generating stabs debugging, use N_BINCL entries.  */
4733965Sjdp
4833965Sjdp#undef  DBX_USE_BINCL
4933965Sjdp#define DBX_USE_BINCL
5033965Sjdp
5133965Sjdp/* There is no limit to the length of stabs strings.  */
5233965Sjdp
53218822Sdim#ifndef DBX_CONTIN_LENGTH
5433965Sjdp#define DBX_CONTIN_LENGTH 0
5533965Sjdp#endif
5633965Sjdp
5733965Sjdp/* When using stabs, gcc2_compiled must be a stabs entry, not an
5833965Sjdp   ordinary symbol, or gdb won't see it.  Furthermore, since gdb reads
5933965Sjdp   the input piecemeal, starting with each N_SO, it's a lot easier if
6033965Sjdp   the gcc2 flag symbol is *after* the N_SO rather than before it.  So
6133965Sjdp   we emit an N_OPT stab there.  */
6233965Sjdp
6333965Sjdp#define ASM_IDENTIFY_GCC(FILE)						\
6433965Sjdpdo									\
6533965Sjdp  {									\
6633965Sjdp    if (write_symbols != DBX_DEBUG)					\
67218822Sdim      fputs ("gcc2_compiled.:\n", FILE);				\
6833965Sjdp  }									\
6933965Sjdpwhile (0)
7033965Sjdp
7133965Sjdp#define ASM_IDENTIFY_GCC_AFTER_SOURCE(FILE)				\
7233965Sjdpdo									\
7333965Sjdp  {									\
7433965Sjdp    if (write_symbols == DBX_DEBUG)					\
7533965Sjdp      fputs ("\t.stabs\t\"gcc2_compiled.\", 0x3c, 0, 0, 0\n", FILE);	\
7633965Sjdp  }									\
7733965Sjdpwhile (0)
7833965Sjdp
7933965Sjdp/* Like block addresses, stabs line numbers are relative to the
8033965Sjdp   current function.  */
8133965Sjdp
8233965Sjdp#undef  ASM_OUTPUT_SOURCE_LINE
8333965Sjdp#define ASM_OUTPUT_SOURCE_LINE(FILE, LINE)				\
8433965Sjdpdo									\
8533965Sjdp  {									\
8633965Sjdp    static int sym_lineno = 1;						\
8733965Sjdp    char temp[256];							\
8833965Sjdp    ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno);		\
8933965Sjdp    fprintf (FILE, ".stabn 68,0,%d,", LINE);				\
9033965Sjdp    assemble_name (FILE, temp);						\
91218822Sdim    putc ('-', FILE);							\
9233965Sjdp    assemble_name (FILE,						\
9333965Sjdp		   XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
9433965Sjdp    putc ('\n', FILE);							\
9533965Sjdp    ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno);			\
9633965Sjdp    sym_lineno += 1;							\
9733965Sjdp  }									\
9833965Sjdpwhile (0)
9933965Sjdp
100/* Generate a blank trailing N_SO to mark the end of the .o file, since
101   we can't depend upon the linker to mark .o file boundaries with
102   embedded stabs.  */
103
104#undef  DBX_OUTPUT_MAIN_SOURCE_FILE_END
105#define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME)			\
106  asm_fprintf (FILE,							\
107	       "\t.text\n\t.stabs \"\",%d,0,0,%LLetext\n%LLetext:\n", N_SO)
108
109#endif /* __DBX_ELF_H */
110