mbox series

[00/11] CodeView variables and type system

Message ID 20240618001713.24034-1-mark@harmstone.com
Headers show
Series CodeView variables and type system | expand

Message

Mark Harmstone June 18, 2024, 12:17 a.m. UTC
This patch series adds support for outputting global variables when the
-gcodeview option is provided, along with the type system to go along
with this.

As with previous patches, the best way to see the output is run
Microsoft's cvdump.exe against the object file:
https://github.com/microsoft/microsoft-pdb/raw/master/cvdump/cvdump.exe

You'll also need a recentish version of binutils in order to get ld to
output an actual PDB file that can be read by MSVC or windbg.

This ought to be fairly complete as far as C is concerned. Still to come
are functions, local variables, and some C++ things.

Mark Harmstone (11):
  Output CodeView data about variables
  Handle CodeView base types
  Handle typedefs for CodeView
  Handle pointers for CodeView
  Handle const and varible modifiers for CodeView
  Handle enums for CodeView
  Handle structs and classes for CodeView
  Handle unions for CodeView.
  Handle arrays for CodeView
  Handle bitfields for CodeView
  Handle subroutine types in CodeView

 gcc/dwarf2codeview.cc | 2278 ++++++++++++++++++++++++++++++++++++++++-
 gcc/dwarf2codeview.h  |   67 ++
 gcc/dwarf2out.cc      |    5 +
 3 files changed, 2341 insertions(+), 9 deletions(-)

Comments

Jan-Benedict Glaw Aug. 12, 2024, 7:09 p.m. UTC | #1
On Tue, 2024-06-18 01:17:02 +0100, Mark Harmstone <mark@harmstone.com> wrote:
> This patch series adds support for outputting global variables when the
> -gcodeview option is provided, along with the type system to go along
> with this.
[...]
> This ought to be fairly complete as far as C is concerned. Still to come
> are functions, local variables, and some C++ things.
[...]
>  gcc/dwarf2codeview.cc | 2278 ++++++++++++++++++++++++++++++++++++++++-
>  gcc/dwarf2codeview.h  |   67 ++
>  gcc/dwarf2out.cc      |    5 +
>  3 files changed, 2341 insertions(+), 9 deletions(-)

Building with a really recent GCC on the host for
--target=i686-mingw32crt or --target=i686-cygwin --enable-threads=yes,
I get these new warnings (--enable-werror-always is in place):


[all 2024-08-12 14:21:54] /var/lib/laminar/run/gcc-i686-mingw32crt/58/local-toolchain-install/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror  -DHAVE_CONFIG_H -fno-PIE -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include  -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o dwarf2codeview.o -MT dwarf2codeview.o -MMD -MP -MF ./.deps/dwarf2codeview.TPo ../../gcc/gcc/dwarf2codeview.cc
[all 2024-08-12 14:22:00] In function 'uint32_t get_type_num_enumeration_type(dw_die_ref, bool)',
[all 2024-08-12 14:22:00]     inlined from 'uint32_t get_type_num(dw_die_ref, bool, bool)' at ../../gcc/gcc/dwarf2codeview.cc:3227:43:
[all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2576:58: error: 'last_type' may be used uninitialized [-Werror=maybe-uninitialized]
[all 2024-08-12 14:22:00]  2576 |         ct->lf_fieldlist.last_subtype->lf_index.type_num = last_type;
[all 2024-08-12 14:22:00]       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
[all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc: In function 'uint32_t get_type_num(dw_die_ref, bool, bool)':
[all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2451:12: note: 'last_type' was declared here
[all 2024-08-12 14:22:00]  2451 |   uint32_t last_type;
[all 2024-08-12 14:22:00]       |            ^~~~~~~~~
[all 2024-08-12 14:22:00] In function 'uint32_t get_type_num_struct(dw_die_ref, bool, bool*)',
[all 2024-08-12 14:22:00]     inlined from 'uint32_t get_type_num(dw_die_ref, bool, bool)' at ../../gcc/gcc/dwarf2codeview.cc:3233:33:
[all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2876:60: error: 'last_type' may be used uninitialized [-Werror=maybe-uninitialized]
[all 2024-08-12 14:22:00]  2876 |           ct->lf_fieldlist.last_subtype->lf_index.type_num = last_type;
[all 2024-08-12 14:22:00]       |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
[all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc: In function 'uint32_t get_type_num(dw_die_ref, bool, bool)':
[all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2729:12: note: 'last_type' was declared here
[all 2024-08-12 14:22:00]  2729 |   uint32_t last_type;
[all 2024-08-12 14:22:00]       |            ^~~~~~~~~
[all 2024-08-12 14:22:00] cc1plus: all warnings being treated as errors
[all 2024-08-12 14:22:00] make[1]: *** [Makefile:1194: dwarf2codeview.o] Error 1
[all 2024-08-12 14:22:00] make[1]: Leaving directory '/var/lib/laminar/run/gcc-i686-mingw32crt/58/toolchain-build/gcc'
[all 2024-08-12 14:22:00] make: *** [Makefile:4698: all-gcc] Error 2

Full build logs at
http://toolchain.lug-owl.de/laminar/jobs/gcc-i686-mingw32crt/58 and
http://toolchain.lug-owl.de/laminar/jobs/gcc-i686-cygwinOPT-enable-threads=yes/53 .

MfG, JBG

--
Mark Harmstone Aug. 12, 2024, 10:46 p.m. UTC | #2
Thanks for this - I've just submitted a patch to fix these warnings.

Mark

On 12/08/2024 20:09, Jan-Benedict Glaw wrote:
> Building with a really recent GCC on the host for
> --target=i686-mingw32crt or --target=i686-cygwin --enable-threads=yes,
> I get these new warnings (--enable-werror-always is in place):
> 
> 
> [all 2024-08-12 14:21:54] /var/lib/laminar/run/gcc-i686-mingw32crt/58/local-toolchain-install/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror  -DHAVE_CONFIG_H -fno-PIE -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include  -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o dwarf2codeview.o -MT dwarf2codeview.o -MMD -MP -MF ./.deps/dwarf2codeview.TPo ../../gcc/gcc/dwarf2codeview.cc
> [all 2024-08-12 14:22:00] In function 'uint32_t get_type_num_enumeration_type(dw_die_ref, bool)',
> [all 2024-08-12 14:22:00]     inlined from 'uint32_t get_type_num(dw_die_ref, bool, bool)' at ../../gcc/gcc/dwarf2codeview.cc:3227:43:
> [all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2576:58: error: 'last_type' may be used uninitialized [-Werror=maybe-uninitialized]
> [all 2024-08-12 14:22:00]  2576 |         ct->lf_fieldlist.last_subtype->lf_index.type_num = last_type;
> [all 2024-08-12 14:22:00]       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
> [all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc: In function 'uint32_t get_type_num(dw_die_ref, bool, bool)':
> [all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2451:12: note: 'last_type' was declared here
> [all 2024-08-12 14:22:00]  2451 |   uint32_t last_type;
> [all 2024-08-12 14:22:00]       |            ^~~~~~~~~
> [all 2024-08-12 14:22:00] In function 'uint32_t get_type_num_struct(dw_die_ref, bool, bool*)',
> [all 2024-08-12 14:22:00]     inlined from 'uint32_t get_type_num(dw_die_ref, bool, bool)' at ../../gcc/gcc/dwarf2codeview.cc:3233:33:
> [all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2876:60: error: 'last_type' may be used uninitialized [-Werror=maybe-uninitialized]
> [all 2024-08-12 14:22:00]  2876 |           ct->lf_fieldlist.last_subtype->lf_index.type_num = last_type;
> [all 2024-08-12 14:22:00]       |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
> [all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc: In function 'uint32_t get_type_num(dw_die_ref, bool, bool)':
> [all 2024-08-12 14:22:00] ../../gcc/gcc/dwarf2codeview.cc:2729:12: note: 'last_type' was declared here
> [all 2024-08-12 14:22:00]  2729 |   uint32_t last_type;
> [all 2024-08-12 14:22:00]       |            ^~~~~~~~~
> [all 2024-08-12 14:22:00] cc1plus: all warnings being treated as errors
> [all 2024-08-12 14:22:00] make[1]: *** [Makefile:1194: dwarf2codeview.o] Error 1
> [all 2024-08-12 14:22:00] make[1]: Leaving directory '/var/lib/laminar/run/gcc-i686-mingw32crt/58/toolchain-build/gcc'
> [all 2024-08-12 14:22:00] make: *** [Makefile:4698: all-gcc] Error 2
>