[PATCH 1/5] Remove obsolete debugging formats from names list

2023-10-22 Thread Mark Harmstone
STABS and xcoff have been removed, but are still in debug_type_names, which ought to match debug_type_masks. This results in the following minor bug with GCC 13: $ x86_64-pc-linux-gnu-gcc -gvms -c tmp.c cc1: error: target system does not support the ‘dwarf-2’ debug format --- gcc/opts.cc | 4 ++--

[PATCH 5/5] Output S_COMPILE3 symbol in CodeView debug section

2023-10-22 Thread Mark Harmstone
Outputs the S_COMPILE3 symbol in the CodeView .debug$S debug section. The DEBUG_S_SYMBOLS block added here makes up pretty much everything that isn't data structures or line numbers; we add the S_COMPILE3 symbol here to start it off. This is a descriptive bit, the most interesting part of which is

[PATCH 3/5] Output file checksums in CodeView section

2023-10-22 Thread Mark Harmstone
Outputs the file name and MD5 hash of the main source file into the CodeView .debug$S section, along with that of any #include'd files. --- gcc/dwarf2codeview.cc | 254 ++ gcc/dwarf2codeview.h | 1 + gcc/dwarf2out.cc | 3 + 3 files changed, 258 ins

[PATCH 2/5] Support for CodeView debugging format

2023-10-22 Thread Mark Harmstone
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

[PATCH 4/5] Output line numbers in CodeView section

2023-10-22 Thread Mark Harmstone
Outputs the DEBUG_S_LINES block in the CodeView .debug$S section, which maps between line numbers and addresses. You'll need a fairly recent version of GAS for the .secidx directive to be recognized. --- gcc/dwarf2codeview.cc | 303 ++ gcc/dwarf2codeview.h

Re: [PATCH 2/5] Support for CodeView debugging format

2023-10-26 Thread Mark Harmstone
On 26/10/23 10:35, Richard Biener wrote: On Mon, Oct 23, 2023 at 2:57 AM Mark Harmstone wrote: This patch and the following add initial support for Microsoft's CodeView debugging format, as used by MSVC, to mingw targets. A high-level question - it seems there's almost no informat

[PATCH v2 0/4] CodeView patches

2023-10-30 Thread Mark Harmstone
Changes from initial version: * First patch now accepted * Added #ifdefs to avoid compilation failures on other targets

[PATCH v2 3/4] Output line numbers in CodeView section

2023-10-30 Thread Mark Harmstone
Outputs the DEBUG_S_LINES block in the CodeView .debug$S section, which maps between line numbers and addresses. You'll need a fairly recent version of GAS for the .secidx directive to be recognized. --- gcc/dwarf2codeview.cc | 303 ++ gcc/dwarf2codeview.h

[PATCH v4 4/4] Output S_COMPILE3 symbol in CodeView debug section

2023-10-30 Thread Mark Harmstone
Outputs the S_COMPILE3 symbol in the CodeView .debug$S debug section. The DEBUG_S_SYMBOLS block added here makes up pretty much everything that isn't data structures or line numbers; we add the S_COMPILE3 symbol here to start it off. This is a descriptive bit, the most interesting part of which is

[PATCH v2 1/4] Support for CodeView debugging format

2023-10-30 Thread Mark Harmstone
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

[PATCH v2 2/4] Output file checksums in CodeView section

2023-10-30 Thread Mark Harmstone
Outputs the file name and MD5 hash of the main source file into the CodeView .debug$S section, along with that of any #include'd files. --- gcc/dwarf2codeview.cc | 254 ++ gcc/dwarf2codeview.h | 1 + gcc/dwarf2out.cc | 5 + 3 files changed, 260 ins

[PATCH] Add -gcodeview option

2022-10-23 Thread Mark Harmstone
Both current lld and the next version of ld have an option -pdb, which creates a PDB file which Microsoft's debuggers can use. This patch adds a -gcodeview option, which passes this to the linker. I do intend to expand this so it also creates the .debug$S and .debug$T sections which would make thi

Re: [PATCH] Add -gcodeview option

2022-10-24 Thread Mark Harmstone
On 24/10/22 12:08, Martin Storsjö wrote: Hmm, what does this end up passing to the linker in the end - does it just pass "-pdb="? (What does the "*" parameter do here?) If that's the case - that sounds reasonable - assuming that if a user passes an extra -Wl,--pdb,myspecificname.pdb, that would ta

Re: [PATCH] Add -gcodeview option

2022-10-26 Thread Mark Harmstone
On 25/10/22 09:21, Martin Storsjö wrote: Btw, stylistically, should we strive towards using double dashes for the pdb option? I think that's the most canonical way for such getopt options (even though it doesn't make any practical difference). I've started trying to update various users to pref

[PATCH v2] Add -gcodeview option

2022-10-26 Thread Mark Harmstone
Changed to double dashes as per https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604287.html. --- gcc/common.opt | 4 gcc/doc/invoke.texi | 7 +++ gcc/gcc.cc | 4 gcc/opts.cc | 3 +++ 4 files changed, 18 insertions(+) diff --git a/gcc/common.opt b/gcc/co

Re: [PATCH v1 00/13] Add aarch64-w64-mingw32 target

2024-02-22 Thread Mark Harmstone
nsuring support for the AArch64 architecture within these libraries. These changes collectively enhance the capabilities of GCC for the specified target. Coauthors: Zac Walker , Mark Harmstone and Ron Riddle Refactored, prepared, and validated by Radek Barton and Evgeny Karpov Special thanks t

Re: [PATCH v1 05/13] Reuse MinGW from i386 for AArch64

2024-02-25 Thread Mark Harmstone
On 22/2/24 11:11, Richard Earnshaw (lists) wrote: Most of the free world has left COFF behind since several decades, so I won't comment on that. YMMV. This isn't helpful. Windows platforms use (a derivative of) COFF, so that's what the tools need to use when targetting that platform. Also,

Re: [PATCH v1 02/13] aarch64: The aarch64-w64-mingw32 target implements

2024-02-25 Thread Mark Harmstone
On 23/2/24 17:54, Andrew Pinski wrote: There is arm64ec ABI defined for aarch64 windows which is a different ABI from the standard windows aarch64 ABI, though I am not sure if it supported with the patches here. It is documented at https://learn.microsoft.com/en-us/cpp/build/arm64ec-windows-abi-c

[PATCH 1/5] Add CodeView enum cv_leaf_type

2024-06-29 Thread Mark Harmstone
Make everything more gdb-friendly by using an enum for type constants rather than #defines. gcc/ * dwarf2codeview.cc (enum cv_leaf_type): Define. (struct codeview_subtype): Use enum cv_leaf_type. (struct codeview_custom_type): Use enum cv_leaf_type.

[PATCH 2/5] Add CodeView enum cv_sym_type

2024-06-29 Thread Mark Harmstone
Make everything more gdb-friendly by using an enum for symbol constants rather than #defines. gcc/ * dwarf2codeview.cc (S_LDATA32, S_GDATA32, S_COMPILE3): Undefine. (enum cv_sym_type): Define. (struct codeview_symbol): Use enum cv_sym_type. (writ

[PATCH 3/5] Avoid magic numbers when writing CodeView padding

2024-06-29 Thread Mark Harmstone
Adds names for the padding magic numbers to enum cv_leaf_type. gcc/ * dwarf2codeview.cc (enum cv_leaf_type): Add padding constants. (write_cv_padding): Use names for padding constants. --- gcc/dwarf2codeview.cc | 11 +++ 1 file changed, 7 insertions(+), 4 delet

[PATCH 4/5] Make sure CodeView symbols are aligned

2024-06-29 Thread Mark Harmstone
CodeView symbols have to be multiples of four bytes; add an alignment directive to write_data_symbol to ensure this. Note that these can be zeroes, so we can rely on GAS to do this for us; it's only types that need f3, f2, f1 values. gcc/ * dwarf2codeview.cc (write_data_symbol): A

[PATCH 5/5] Document return value in write_cv_integer

2024-06-29 Thread Mark Harmstone
gcc/ * dwarf2codeview.cc (write_lf_modifier): Expand upon comment. --- gcc/dwarf2codeview.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc index 5a33b439b14..df53d8bab9d 100644 --- a/gcc/dwarf2codeview.cc +++ b/gcc

[PATCH] Output CodeView function information

2024-07-13 Thread Mark Harmstone
Translate DW_TAG_subprogram DIEs into CodeView LF_FUNC_ID types and S_GPROC32_ID / S_LPROC32_ID symbols. ld will then transform these into S_GPROC32 / S_LPROC32 symbols, which map addresses to unmangled function names. gcc/ * dwarf2codeview.cc (enum cv_sym_type): Add new values. (

[PATCH 2/2] Output CodeView type information for rvalue references

2024-07-20 Thread Mark Harmstone
Translates DW_TAG_rvalue_reference_type DIEs into LF_POINTER types. gcc/ * dwarf2codeview.cc (get_type_num_reference_type): Handle rvalue refs. (get_type_num_array_type): Add DW_TAG_rvalue_reference_type to switch. (get_type_num): Handle DW_TAG_rvalue_reference_type DIEs.

[PATCH 1/2] Output CodeView type information for references

2024-07-20 Thread Mark Harmstone
Translates DW_TAG_reference_type DIEs into LF_POINTER types. gcc/ * dwarf2codeview.cc (get_type_num_reference_type): New function. (get_type_num_array_type): Add DW_TAG_reference_type to switch. (get_type_num): Handle DW_TAG_reference_type DIEs. * dwarf2codeview.h (

[PATCH] Fix maybe-uninitialized CodeView LF_INDEX warning

2024-08-12 Thread Mark Harmstone
Initialize last_type to 0 to silence two spurious maybe-uninitialized warnings. We issue an LF_INDEX continuation subtype for any LF_FIELDLISTs that overflow, so LF_INDEXes will always have a subtype preceding them (and thus last_type will always be set). gcc/ * dwarf2codeview.cc (get_type

Re: [PATCH 00/11] CodeView variables and type system

2024-08-12 Thread Mark Harmstone
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

[PATCH 3/3] Write CodeView information about stack variables

2024-08-12 Thread Mark Harmstone
Outputs CodeView S_REGREL32 symbols for unoptimized local variables that are stored on the stack. This includes a change to dwarf2out.cc to make it easier to extract the function frame base without having to worry about the function prologue or epilogue. gcc/ * dwarf2codeview.cc (enum cv_s

[PATCH 1/3] Write CodeView information about local static variables

2024-08-12 Thread Mark Harmstone
Outputs CodeView S_LDATA32 symbols, for static variables within functions, along with S_BLOCK32 and S_END for the beginning and end of lexical blocks. gcc/ * dwarf2codeview.cc (enum cv_sym_type): Add S_END and S_BLOCK32. (write_local_s_ldata32): New function. (write_unoptim

[PATCH 2/3] Write CodeView information about enregistered variables

2024-08-12 Thread Mark Harmstone
Outputs CodeView S_REGISTER symbols, representing local variables or parameters that are held in a register. gcc/ * dwarf2codeview.cc (enum cv_sym_type): Add S_REGISTER. (enum cv_x86_register): New type. (enum cv_amd64_register): New type. (dwarf_reg_to_cv): New fun

Re: [PATCH 1/3] Write CodeView information about local static variables

2024-08-16 Thread Mark Harmstone
wrote: On 8/12/24 6:24 PM, Mark Harmstone wrote: Outputs CodeView S_LDATA32 symbols, for static variables within functions, along with S_BLOCK32 and S_END for the beginning and end of lexical blocks. gcc/ * dwarf2codeview.cc (enum cv_sym_type): Add S_END and S_BLOCK32

[PATCH 2/4] Write CodeView information about optimized stack variables

2024-08-18 Thread Mark Harmstone
Outputs S_DEFRANGE_REGISTER_REL symbols for optimized local variables that are on the stack, consisting of the stack register, the offset, and the code range for which this applies. gcc/ * dwarf2codeview.cc (enum cv_sym_type): Add S_DEFRANGE_REGISTER_REL. (write_defrange_register_r

[PATCH 3/4] Write CodeView S_FRAMEPROC symbols

2024-08-18 Thread Mark Harmstone
Write S_FRAMEPROC symbols, which aren't very useful but seem to be necessary for Microsoft debuggers to function properly. These symbols come after S_LOCAL symbols for optimized variables, but before S_REGISTER and S_REGREL32 for unoptimized variables. gcc/ * dwarf2codeview.cc (enum cv_sym

[PATCH 4/4] Write CodeView information about static locals in optimized code

2024-08-18 Thread Mark Harmstone
Write CodeView S_LDATA32 symbols for static locals in optimized code. We have to handle these separately, as they come after the S_FRAMEPROC, plus you can't have S_BLOCK32 symbols like you can in unoptimized code. gcc/ * dwarf2codeview.cc (write_optimized_static_local_vars): New function.

[PATCH 1/4] Write CodeView information about enregistered optimized variables

2024-08-18 Thread Mark Harmstone
Enable variable tracking when outputting CodeView debug information, and make it so that we issue debug symbols for optimized variables in registers. This consists of S_LOCAL symbols, which give the name and the type of local variables, followed by S_DEFRANGE_REGISTER symbols for the register and t

[PATCH 1/5] Handle namespaced names for CodeView

2024-08-26 Thread Mark Harmstone
Run all CodeView names through a new function get_name, which chains together a DIE's DW_AT_name with that of its parent to create a C++-style name. gcc/ * dwarf2codeview.cc (get_name): New function. (add_enum_forward_def): Call get_name. (get_type_num_enumeration_type): Ca

[PATCH 5/5] Write LF_MFUNC_ID types for CodeView struct member functions

2024-08-26 Thread Mark Harmstone
If recording the definition of a struct member function, write an LF_MFUNC_ID type rather than an LF_FUNC_ID. This links directly to the struct type, rather than to an LF_STRING_ID with its name. gcc/ * dwarf2codeview.cc (enum cv_leaf_type): Add LF_MFUNC_ID. (write_lf_mfunc_id): Ne

[PATCH 2/5] Handle scoping in CodeView LF_FUNC_ID types

2024-08-26 Thread Mark Harmstone
If a function is in a namespace, create an LF_STRING_ID type for the name of its parent, and record this in the LF_FUNC_ID type we create for the function. gcc/ * dwarf2codeview.cc (enum cf_leaf_type): Add LF_STRING_ID. (struct codeview_custom_type): Add lf_string_id to union.

[PATCH 3/5] Record static data members in CodeView structs

2024-08-26 Thread Mark Harmstone
Record LF_STMEMBER field list subtypes to represent static data members in structs. gcc/ * dwarf2codeview.cc (enum cv_leaf_type): Add LF_STMEMBER. (struct codeview_subtype): Add lf_static_member to union. (write_lf_fieldlist): Handle LF_STMEMBER. (add_struct_member)

[PATCH 4/5] Record member functions in CodeView struct definitions

2024-08-26 Thread Mark Harmstone
CodeView has two ways of recording struct member functions. Non-overloaded functions have an LF_ONEMETHOD sub-type in the field list, which records the name and the function type (LF_MFUNCTION). Overloaded functions have an LF_METHOD instead, which points to an LF_METHODLIST, which is an array of l

Re: [PATCH 1/5] Handle namespaced names for CodeView

2024-08-28 Thread Mark Harmstone
Thanks Jeff. Yes, sounds good to me. Mark On 27/08/2024 16:23, Jeff Law wrote: On 8/26/24 4:48 PM, Mark Harmstone wrote: Run all CodeView names through a new function get_name, which chains together a DIE's DW_AT_name with that of its parent to create a C++-style name.

[PATCH 00/11] CodeView variables and type system

2024-06-17 Thread Mark Harmstone
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

[PATCH 04/11] Handle pointers for CodeView

2024-06-17 Thread Mark Harmstone
Translates DW_TAG_pointer_type DIEs into LF_POINTER symbols, which get output into the .debug$T section. gcc/ * dwarf2codeview.cc (FIRST_TYPE): Define. (struct codeview_custom_type): New structure. (custom_types, last_custom_type): New variables.

[PATCH 01/11] Output CodeView data about variables

2024-06-17 Thread Mark Harmstone
Parse the DW_TAG_variable DIEs, and outputs S_GDATA32 (for global variables) and S_LDATA32 (static global variables) symbols into the .debug$S section. gcc/ * dwarf2codeview.cc (S_LDATA32, S_GDATA32): Define. (struct codeview_symbol): New structure. (sym, la

[PATCH 07/11] Handle structs and classes for CodeView

2024-06-17 Thread Mark Harmstone
Translates DW_TAG_structure_type DIEs into LF_STRUCTURE symbols, and DW_TAG_class_type DIEs into LF_CLASS symbols. gcc/ * dwarf2codeview.cc (struct codeview_type): Add is_fwd_ref member. (struct codeview_subtype): Add lf_member to union. (struct

[PATCH 05/11] Handle const and varible modifiers for CodeView

2024-06-17 Thread Mark Harmstone
Translate DW_TAG_const_type and DW_TAG_volatile_type DIEs into LF_MODIFIER symbols. gcc/ * dwarf2codeview.cc (struct codeview_custom_type): Add lf_modifier to union. (write_cv_padding, write_lf_modifier): New functions. (write_custom_types): Call

[PATCH 10/11] Handle bitfields for CodeView

2024-06-17 Thread Mark Harmstone
Translates structure members with DW_AT_data_bit_offset set in DWARF into LF_BITFIELD symbols. gcc/ * dwarf2codeview.cc (struct codeview_custom_type): Add lf_bitfield to union. (write_lf_bitfield): New function. (write_custom_types): Call write_l

[PATCH 03/11] Handle typedefs for CodeView

2024-06-17 Thread Mark Harmstone
gcc/ * dwarf2codeview.cc (get_type_num): Handle typedefs. --- gcc/dwarf2codeview.cc | 6 ++ 1 file changed, 6 insertions(+) diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc index eb7c1270e31..5006a176260 100644 --- a/gcc/dwarf2codeview.cc +++ b/gcc/dwarf2codeview.cc

[PATCH 02/11] Handle CodeView base types

2024-06-17 Thread Mark Harmstone
Adds a get_type_num function to translate type DIEs into CodeView numbers, along with a hash table for this. For now we just deal with the base types (integers, Unicode chars, floats, and bools). gcc/ * dwarf2codeview.cc (struct codeview_type): New structure. (struct d

[PATCH 06/11] Handle enums for CodeView

2024-06-17 Thread Mark Harmstone
Translates DW_TAG_enumeration_type DIEs into LF_ENUM symbols. gcc/ * dwarf2codeview.cc (MAX_FIELDLIST_SIZE): Define. (struct codeview_integer): New structure. (struct codeview_subtype): Likewise (struct codeview_custom_type): Add lf_fieldlist and

[PATCH 08/11] Handle unions for CodeView.

2024-06-17 Thread Mark Harmstone
Translates DW_TAG_union_type DIEs into LF_UNION symbols. gcc/ * dwarf2codeview.cc (write_lf_union): New function. (write_custom_types): Call write_lf_union. (add_struct_forward_def): Handle DW_TAG_union_type DIEs. (get_type_num_struct): Handle un

[PATCH 09/11] Handle arrays for CodeView

2024-06-17 Thread Mark Harmstone
Translates DW_TAG_array_type DIEs into LF_ARRAY symbols. gcc/ * dwarf2codeview.cc (struct codeview_custom_type): Add lf_array to union. (write_lf_array): New function. (write_custom_types): Call write_lf_array. (get_type_num_array_typ

[PATCH 11/11] Handle subroutine types in CodeView

2024-06-17 Thread Mark Harmstone
Translates DW_TAG_subroutine_type DIEs into LF_PROCEDURE symbols. gcc/ * dwarf2codeview.cc (struct codeview_custom_type): Add lf_procedure and lf_arglist to union. (write_lf_procedure, write_lf_arglist): New functions. (write_cust

Re: [PATCH 05/11] Handle const and varible modifiers for CodeView

2024-06-24 Thread Mark Harmstone
On 24/6/24 04:39, Jeff Law wrote: So presumably you're freeing these objects elsewhere?  I see the free (custom_types), but I don' see where you free an subobjects.  Did I miss something? I'll go ahead and commit, but please double check for memory leaks. Thanks Jeff. I just realized I wro

[PATCH] Fix ICE when using -gcodeview with empty struct

2024-07-28 Thread Mark Harmstone
Empty structs result in empty LF_FIELDLIST types, which are valid, but we weren't accounting for this and assuming they had to contain subtypes. gcc/ * dwarf2codeview.cc (get_type_num_struct): Fix NULL pointer dereference. --- gcc/dwarf2codeview.cc | 7 +-- 1 file changed, 5 insertion

[PATCH] Fix handling of const or volatile void pointers in CodeView

2024-08-04 Thread Mark Harmstone
DWARF represents voids in DW_TAG_const_type and DW_TAG_volatile_type DIEs by the absence of a DW_AT_type attribute, which we weren't handling correctly. gcc/ * dwarf2codeview.cc (get_type_num_const_type): Handle missing DW_AT_type attribute. (get_type_num_volatile_type): Li

[PATCH 01/24] Add -gcodeview debugging option

2021-03-20 Thread Mark Harmstone
e OPT_gstabs: case OPT_gstabs_: set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg, opts, opts_set, diff --git a/gcc/pdbout.c b/gcc/pdbout.c new file mode 100644 index 000..e8f39bb64ea --- /dev/null +++ b/gcc/pdbout.c @@ -0,0 +1,70 @@ +/* Output CodeView debugging information from G

[PATCH 03/24] pdbout: Output function details.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 149 +-- gcc/pdbout.h | 12 + 2 files changed, 158 insertions(+), 3 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index feaab37cc37..17011134d7a 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -29,14 +29,25 @@ #inclu

[PATCH 02/24] pdbout: Output details of local variables.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 417 ++- gcc/pdbout.h | 89 +++ 2 files changed, 504 insertions(+), 2 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index e8f39bb64ea..feaab37cc37 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -25,13 +25,37 @@

[PATCH 05/24] pdbout: Handle optimized variables.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 242 ++- gcc/pdbout.h | 21 + 2 files changed, 260 insertions(+), 3 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 2f5b52b6fc3..29b0d1c131f 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -51,6 +51,7 @@ static vo

[PATCH 07/24] pdbout: Output line numbers.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 150 ++- gcc/pdbout.h | 10 2 files changed, 159 insertions(+), 1 deletion(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index a4424fa470d..040ac6fe8e4 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -54,6 +54,11 @@ static voi

[PATCH 06/24] pdbout: Output checksums and names of source files.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 195 ++- gcc/pdbout.h | 16 + 2 files changed, 209 insertions(+), 2 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 29b0d1c131f..a4424fa470d 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -32,6 +32,7 @@ #include

[PATCH 04/24] pdbout: Output details of variables within functions.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 1272 +- gcc/pdbout.h | 969 ++ 2 files changed, 2238 insertions(+), 3 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 17011134d7a..2f5b52b6fc3 100644 --- a/gcc/pdbout.c +++ b/gcc/p

[PATCH 08/24] pdbout: Output function prototypes.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 338 ++- gcc/pdbout.h | 23 2 files changed, 359 insertions(+), 2 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 040ac6fe8e4..64f7c1d71bc 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -32,6 +32,7 @@ #include

[PATCH 09/24] pdbout: Output information about pointers.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 131 --- gcc/pdbout.h | 36 ++ 2 files changed, 161 insertions(+), 6 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 64f7c1d71bc..08bb14364e5 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -76,6 +76,7 @@

[PATCH 10/24] pdbout: Output information about CV type modifiers.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 85 gcc/pdbout.h | 11 +++ 2 files changed, 96 insertions(+) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 08bb14364e5..fa3b1fb0312 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -78,6 +78,7 @@ static struct pdb_type *t

[PATCH 12/24] pdbout: Handle type declarations and typedefs.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 76 +++- gcc/pdbout.h | 22 +++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 8376b0e762c..5089203e339 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -55,6 +55,7 @@ st

[PATCH 11/24] pdbout: Output array types.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 133 +++ gcc/pdbout.h | 15 ++ 2 files changed, 148 insertions(+) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index fa3b1fb0312..8376b0e762c 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -79,6 +79,7 @@ static struct pdb_type *

[PATCH 13/24] pdbout: Output information about enums.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 449 +++ gcc/pdbout.h | 43 + 2 files changed, 492 insertions(+) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 5089203e339..9701aaf8902 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -46,6 +46,8 @@ #define FIRST_TYPE_NUM

[PATCH 15/24] pdbout: Output definitions of unions.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 62 +++- gcc/pdbout.h | 1 + 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 3bfec519877..7d493513e06 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -829,6 +829,7 @@ free_type (st

[PATCH 14/24] pdbout: Output definitions of structs and classes.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 469 ++- gcc/pdbout.h | 51 ++ 2 files changed, 517 insertions(+), 3 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 9701aaf8902..3bfec519877 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -83,6 +83,7 @@ static s

[PATCH 16/24] pdbout: Output definitions of bitfields within structs.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 93 ++-- gcc/pdbout.h | 8 + 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 7d493513e06..d3f251f22d2 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -85,6 +85,7 @@ static stru

[PATCH 17/24] pdbout: Prepend namespaces to struct and function names.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 93 ++-- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index d3f251f22d2..fb40f066bd9 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -1484,24 +1484,113 @@ pdbout_finish (const char *fil

[PATCH 18/24] pdbout: Append template information to struct or function name.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 346 ++- 1 file changed, 344 insertions(+), 2 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index fb40f066bd9..0cae4d33469 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -73,6 +73,7 @@ static void pdbout_end_block (unsign

[PATCH 19/24] pdbout: Handle typedefs to anonymous types.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 79 +++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 0cae4d33469..dae5c1ef679 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -3344,6 +3344,8 @@ alias_hasher::equal (const value_t

[PATCH 20/24] pdbout: Output file and line number of type definitions.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 208 ++- gcc/pdbout.h | 10 +++ 2 files changed, 217 insertions(+), 1 deletion(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index dae5c1ef679..8dbd8f58a87 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -79,6 +79,7 @@ static struc

[PATCH 21/24] pdbout: Don't output unused types.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 256 ++- gcc/pdbout.h | 1 + 2 files changed, 254 insertions(+), 3 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 8dbd8f58a87..3d15c620db5 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -1438,7 +1438,8 @@ write_typ

[PATCH 22/24] pdbout: Split large fieldlists when necessary.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 151 ++- gcc/pdbout.h | 1 + 2 files changed, 151 insertions(+), 1 deletion(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 3d15c620db5..d9ad659cd9a 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -84,7 +84,7 @@ static struct

[PATCH 24/24] pdbout: Handle functions with parts in cold section.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 226 ++- gcc/pdbout.h | 2 + 2 files changed, 170 insertions(+), 58 deletions(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index 0f5315f7f07..b4528fb79e8 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -71,6 +71,7 @@ static void

[PATCH 23/24] pdbout: Handle names of ctor and dtor functions.

2021-03-20 Thread Mark Harmstone
--- gcc/pdbout.c | 28 +++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/gcc/pdbout.c b/gcc/pdbout.c index d9ad659cd9a..0f5315f7f07 100644 --- a/gcc/pdbout.c +++ b/gcc/pdbout.c @@ -2175,7 +2175,33 @@ get_tree_name (tree t) static const char anon_ns[] = "

Re: [PATCH 01/24] Add -gcodeview debugging option

2021-03-22 Thread Mark Harmstone
Thanks Richard. > How do CV and DWARF debug differ and is emitting CV debug from a DWARF > representation possible (I suppose there might even exist offline > conversion tools?) I don't know enough about DWARF internals to answer that, but I'd be surprised if the answer is "no". Do you mean that

Re: [PATCH v2] Add -gcodeview option

2022-11-20 Thread Mark Harmstone
On 20/11/22 16:43, Jeff Law wrote: On 10/26/22 21:38, Mark Harmstone wrote: Changed to double dashes as per https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604287.html. What value is there in providing this option now?  IIUC we don't have any of the bits yet to actually produc

[PATCH 2/3] Write LF_POINTER CodeView types for pointers to member functions or data

2024-11-02 Thread Mark Harmstone
Translate DW_TAG_ptr_to_member_type DIEs into special extended LF_POINTER CodeView types. gcc/ * dwarf2codeview.cc (struct codeview_custom_type): Add new fields to lf_pointer struct in union. (write_lf_pointer): Write containing_class and ptr_to_mem_type if applicab

[PATCH 3/3] Handle T_HRESULT types in CodeView records

2024-11-02 Thread Mark Harmstone
Follow MSVC in having a special type value, T_HRESULT, for (signed) longs that have been typedef'd with the name "HRESULT". This is so that the debugger can display user-friendly constant names when debugging COM code. gcc/ * dwarf2codeview.cc (get_type_num_typedef): New function.

[PATCH 1/3] Write LF_BCLASS records in CodeView struct definitions

2024-11-02 Thread Mark Harmstone
When writing the CodeView type definition for a struct, translate DW_TAG_inheritance DIEs into LF_BCLASS records, to record which other structs this one inherits from. gcc/ * dwarf2codeview.cc (enum cv_leaf_type): Add LF_BCLASS. (struct codeview_subtype): Add lf_bclass to union.

[PATCH] Don't skip CodeView data for partially cold functions

2024-11-12 Thread Mark Harmstone
If a function is contained in two sections, for instance if it is partially cold, it gets a DW_AT_ranges attribute in its DIE rather than the normal DW_AT_low_pc and DW_AT_high_pc. There's no way to express this in CodeView, so rather than skipping the function entirely, use the labels in the firs

[PATCH 3/4] Write S_INLINEELINES CodeView subsection

2024-11-06 Thread Mark Harmstone
When outputting the .debug$S CodeView section, also write an S_INLINEELINES subsection, which records the filename and line number of the start of each inlined function. gcc/ * dwarf2codeview.cc (DEBUG_S_INLINEELINES): Define. (CV_INLINEE_SOURCE_LINE_SIGNATURE): Define. (st

[PATCH 1/4] Add block parameter to begin_block debug hook

2024-11-06 Thread Mark Harmstone
Add a parameter to the begin_block debug hook that is a pointer to the tree_node of the block in question. CodeView needs this as it records line numbers of inlined functions in a different manner, so we need to be able to tell if the block is actually the start of an inlined function. gcc/

[PATCH 2/4] Don't output CodeView line numbers for inlined functions

2024-11-06 Thread Mark Harmstone
If we encounter an inlined function, treat it as another codeview_function, and skip over these when outputting line numbers. This information will instead be output as part of the S_INLINESITE symbols. gcc/ * dwarf2codeview.cc (struct codeview_function): Add parent and inline_bloc

[PATCH 4/4] Write S_INLINESITE CodeView symbols

2024-11-06 Thread Mark Harmstone
Translate DW_TAG_inlined_subroutine DIEs into S_INLINESITE CodeView symbols, marking inlined functions. gcc/ * dwarf2codeview.cc (enum cv_sym_type): Add S_INLINESITE and S_INLINESITE_END. (get_func_id): Add declaration. (write_s_inlinesite): New function. (w

[PATCH] Write binary annotations for CodeView S_INLINESITE symbols

2024-11-17 Thread Mark Harmstone
Add "binary annotations" at the end of CodeView S_INLINESITE symbols, which are a series of compressed integers that represent how line numbers map to addresses. This requires assembler support; you will need commit b3aa594d ("gas: add .cv_ucomp and .cv_scomp pseudo-directives") in binutils. gcc/

Re: [PATCH 2/2] Flatten anonymous structs in CodeView types

2024-11-18 Thread Mark Harmstone
On 18/11/2024 05:05, Jeff Law wrote: On 11/17/24 9:01 AM, Mark Harmstone wrote: If a CodeView struct, class, or union has as a member an anonymous struct, class, or union, this gets flattened. The sub-struct's members will appear as if they were part of their parent. For this, we move

Re: [PATCH] Write binary annotations for CodeView S_INLINESITE symbols

2024-11-18 Thread Mark Harmstone
On 18/11/2024 04:57, Jeff Law wrote: On 11/17/24 8:40 AM, Mark Harmstone wrote: Add "binary annotations" at the end of CodeView S_INLINESITE symbols, which are a series of compressed integers that represent how line numbers map to addresses. This requires assembler support; you

[PATCH 2/2] Flatten anonymous structs in CodeView types

2024-11-17 Thread Mark Harmstone
If a CodeView struct, class, or union has as a member an anonymous struct, class, or union, this gets flattened. The sub-struct's members will appear as if they were part of their parent. For this, we move part of get_type_num_struct into a new function add_to_fieldlist, which also handles creatin

[PATCH 1/2] Produce CodeView info about nested types

2024-11-17 Thread Mark Harmstone
If the DIE for a struct, class, or union contains a nested type, add a LF_NESTTYPE entry to its field list recording this. Plus if we use a nested type, make sure that its parent also gets defined. This may entail adding a forward definition and creating a deferred type, so we need to call flush_d

[PATCH v2] Write binary annotations for CodeView S_INLINESITE symbols

2024-11-30 Thread Mark Harmstone
Add "binary annotations" at the end of CodeView S_INLINESITE symbols, which are a series of compressed integers that represent how line numbers map to addresses. This requires assembler support; you will need commit b3aa594d ("gas: add .cv_ucomp and .cv_scomp pseudo-directives") in binutils. gcc/

[PATCH] Fix non-aligned CodeView symbols

2024-12-01 Thread Mark Harmstone
CodeView symbols in PDB files are aligned to four-byte boundaries. It's not really clear what logic MSVC uses to enforce this; sometimes the symbols are padded in the object file, sometimes the linker seems to do the work. It makes more sense to do this in the compiler, so fix the two instances wh

[PATCH] Fix compilation error in vmsdbgout_begin_block on VMS targets

2024-12-19 Thread Mark Harmstone
Commit 4ed189854eae ("Add block parameter to begin_block debug hook") changed the definition of the begin_block function pointer to add another parameter, but I missed a call in vmsdbgout_begin_block. Fixes bug #118123. gcc/ * vmsdbgout.cc (vmsdbgout_begin_block): Fix compilation error. -