diff options
author | Mark Harmstone <mark@harmstone.com> | 2024-05-11 08:08:50 -0600 |
---|---|---|
committer | Jeff Law <jlaw@ventanamicro.com> | 2024-05-11 08:15:01 -0600 |
commit | 36781ef8fd26eb9a0686957e7bac8f5ccc5ecc3f (patch) | |
tree | 5162e8e8fec0b8e35d5b37bf4ac2d72cd416bb48 /gcc/dwarf2codeview.cc | |
parent | 1b0919cd147a2b6ccdee2b1217bf0200bdcc87aa (diff) | |
download | gcc-36781ef8fd26eb9a0686957e7bac8f5ccc5ecc3f.zip gcc-36781ef8fd26eb9a0686957e7bac8f5ccc5ecc3f.tar.gz gcc-36781ef8fd26eb9a0686957e7bac8f5ccc5ecc3f.tar.bz2 |
[PATCH v2 1/4] Support for CodeView debugging format
This patch and the following add initial support for Microsoft's
CodeView debugging format, as used by MSVC, to mingw targets.
Note that you will need a recent version of binutils for this to be
useful. The best way to view the output is to run Microsoft's
cvdump.exe, found in their microsoft-pdb repo on GitHub, against the
object files.
gcc/
* Makefile.in (OBJS): Add dwarf2codeview.o.
(GTFILES): Add dwarf2codeview.cc
* config/i386/cygming.h (CODEVIEW_DEBUGGING_INFO): Define.
* dwarf2codeview.cc: New file.
* dwarf2codeview.h: New file.
* dwarf2out.cc: Include dwarf2codeview.h.
(dwarf2out_finish): Call codeview_debug_finish as needed.
* flag-types.h (DINFO_TYPE_CODEVIEW): Add enum member.
(CODEVIEW_DEBUG): Define.
* flags.h (codeview_debuginfo_p): Proottype.
* opts.cc (debug_type_names): Add codeview.
(debug_type_masks): Add CODEVIEW_DEBUG.
(df_set_names): Add codeview.
(codeview_debuginfo_p): New function.
(dwarf_based_debuginfo_p): Add CODEVIEW clause.
(set_debug_level): Handle CODEVIEW_DEBUG.
* toplev.cc (process_options): Handle codeview.
gcc/testsuite
* gcc.dg/debug/codeview/codeview-1.c: New test.
* gcc.dg/debug/codeview/codeview.exp: New testsuite driver.
Diffstat (limited to 'gcc/dwarf2codeview.cc')
-rw-r--r-- | gcc/dwarf2codeview.cc | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc new file mode 100644 index 0000000..f08f5d5 --- /dev/null +++ b/gcc/dwarf2codeview.cc @@ -0,0 +1,54 @@ +/* Generate CodeView debugging info from the GCC DWARF. + Copyright (C) 2023 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +/* See gas/codeview.h in binutils for more about the constants and structs + listed below. References to Microsoft files refer to Microsoft's PDB + repository: https://github.com/microsoft/microsoft-pdb. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "target.h" +#include "output.h" +#include "errors.h" +#include "md5.h" +#include "function.h" +#include "version.h" +#include "tree.h" +#include "langhooks.h" +#include "dwarf2out.h" +#include "dwarf2codeview.h" + +#ifdef CODEVIEW_DEBUGGING_INFO + +#define CV_SIGNATURE_C13 4 + +/* Finish CodeView debug info emission. */ + +void +codeview_debug_finish (void) +{ + targetm.asm_out.named_section (".debug$S", SECTION_DEBUG, NULL); + + fputs (integer_asm_op (4, false), asm_out_file); + fprint_whex (asm_out_file, CV_SIGNATURE_C13); + putc ('\n', asm_out_file); +} + +#endif |