* [PATCH] Add -gcodeview option
@ 2022-10-24 0:28 Mark Harmstone
2022-10-24 11:08 ` Martin Storsjö
0 siblings, 1 reply; 5+ messages in thread
From: Mark Harmstone @ 2022-10-24 0:28 UTC (permalink / raw)
To: gcc-patches, martin; +Cc: 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 this useful - I submitted patches for this a
while back, but they need to be rewritten to parse the DWARF DIEs rather
than using debug_hooks.
Clang also has -gcodeview, but AFAICS only uses it for .debug$S and
.debug$T, and doesn't use it for linker options (though IMO it probably
should).
---
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/common.opt
index 8a0dafc522d..77103f961d8 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3253,6 +3253,10 @@ gas-locview-support
Common Driver Var(dwarf2out_as_locview_support)
Assume assembler support for view in (DWARF2+) .loc directives.
+gcodeview
+Common Driver JoinedOrMissing
+Generate debug information in CodeView format.
+
gcoff
Common Driver WarnRemoved
Does nothing. Preserved for backward compatibility.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index ff6c338bedb..2d29fd2611d 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -483,6 +483,7 @@ Objective-C and Objective-C++ Dialects}.
-gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol
-gas-loc-support -gno-as-loc-support @gol
-gas-locview-support -gno-as-locview-support @gol
+-gcodeview @gol
-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
-gstatement-frontiers -gno-statement-frontiers @gol
-gvariable-location-views -gno-variable-location-views @gol
@@ -10358,6 +10359,12 @@ assembler (GAS) to fail with an error.
Produce debugging information in Alpha/VMS debug format (if that is
supported). This is the format used by DEBUG on Alpha/VMS systems.
+@item -gcodeview
+@opindex gcodeview
+Produce debugging information in CodeView debug format (if that is
+supported). This is the format used by Microsoft Visual C++ on
+Windows.
+
@item -g@var{level}
@itemx -ggdb@var{level}
@itemx -gstabs@var{level}
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index bb07cc244e3..2820f325282 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -4608,6 +4608,10 @@ driver_handle_option (struct gcc_options *opts,
do_save = false;
break;
+ case OPT_gcodeview:
+ add_infile ("-pdb=", "*");
+ break;
+
default:
/* Various driver options need no special processing at this
point, having been handled in a prescan above or being
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3a89da2dd03..e2633ee5439 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3089,6 +3089,9 @@ common_handle_option (struct gcc_options *opts,
set_debug_level (NO_DEBUG, 2, arg, opts, opts_set, loc);
break;
+ case OPT_gcodeview:
+ break;
+
case OPT_gstabs:
case OPT_gstabs_:
set_debug_level (DBX_DEBUG, code == OPT_gstabs_, arg, opts, opts_set,
--
2.37.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add -gcodeview option
2022-10-24 0:28 [PATCH] Add -gcodeview option Mark Harmstone
@ 2022-10-24 11:08 ` Martin Storsjö
2022-10-24 23:20 ` Mark Harmstone
0 siblings, 1 reply; 5+ messages in thread
From: Martin Storsjö @ 2022-10-24 11:08 UTC (permalink / raw)
To: Mark Harmstone; +Cc: gcc-patches
On Mon, 24 Oct 2022, Mark Harmstone wrote:
> 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 this useful - I submitted patches for this a
> while back, but they need to be rewritten to parse the DWARF DIEs rather
> than using debug_hooks.
>
> Clang also has -gcodeview, but AFAICS only uses it for .debug$S and
> .debug$T, and doesn't use it for linker options (though IMO it probably
> should).
That's true - in Clang, this option doesn't affect linking, it only
affects code generation.
(FWIW, if I understand it correctly, Clang also does support generating
both DWARF and CodeView at the same time - I think that would require
passing something like "-g -gdwarf-4 -gcodeview" at the same time - but I
don't have experience with playing with such setups.)
Another vague oddity in how this option is handled in Clang, is that if I
only pass "-gcodeview" to the compiler, it doesn't actually generate any
debug info (it just changes preference, in case I would request debug info
separately), while one has to pass e.g. "-g -gcodeview" for it to do
what's expected. I'm not sure if this is the same with dwarf, or if
passing "-gdwarf-4" is enough for actually enabling generating dwarf debug
info too. In any case, I don't think this aspect needs to be matched
closely (unless dwarf does the same), as any existing users of PDB
generation do use "-g -gcodeview", so as long as that case works, there
shouldn't be any interop issues.
> ---
> gcc/common.opt | 4 ++++
> gcc/doc/invoke.texi | 7 +++++++
> gcc/gcc.cc | 4 ++++
> gcc/opts.cc | 3 +++
> 4 files changed, 18 insertions(+)
>
> @@ -4608,6 +4608,10 @@ driver_handle_option (struct gcc_options *opts,
> do_save = false;
> break;
>
> + case OPT_gcodeview:
> + add_infile ("-pdb=", "*");
> + break;
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 take precedence (i.e. be passed
after the compiler's default one).
// Martin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add -gcodeview option
2022-10-24 11:08 ` Martin Storsjö
@ 2022-10-24 23:20 ` Mark Harmstone
2022-10-25 8:21 ` Martin Storsjö
0 siblings, 1 reply; 5+ messages in thread
From: Mark Harmstone @ 2022-10-24 23:20 UTC (permalink / raw)
To: Martin Storsjö; +Cc: gcc-patches
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 take precedence (i.e. be passed after the compiler's default one).
That's right. The "*" means "all languages".
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add -gcodeview option
2022-10-24 23:20 ` Mark Harmstone
@ 2022-10-25 8:21 ` Martin Storsjö
2022-10-27 3:36 ` Mark Harmstone
0 siblings, 1 reply; 5+ messages in thread
From: Martin Storsjö @ 2022-10-25 8:21 UTC (permalink / raw)
To: Mark Harmstone; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 876 bytes --]
On Tue, 25 Oct 2022, Mark Harmstone wrote:
> 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 take precedence (i.e. be passed
>> after the compiler's default one).
>
> That's right. The "*" means "all languages".
Ok, great.
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 prefer that form (together with
preferring -Wl,--pdb=<name> over -Wl,--pdb,<name>) and probably will send
a few more.
// Martin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Add -gcodeview option
2022-10-25 8:21 ` Martin Storsjö
@ 2022-10-27 3:36 ` Mark Harmstone
0 siblings, 0 replies; 5+ messages in thread
From: Mark Harmstone @ 2022-10-27 3:36 UTC (permalink / raw)
To: Martin Storsjö; +Cc: gcc-patches
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 prefer that form (together with preferring -Wl,--pdb=<name> over -Wl,--pdb,<name>) and probably will send a few more.
Thanks Martin. Yes, I agree.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-27 3:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 0:28 [PATCH] Add -gcodeview option Mark Harmstone
2022-10-24 11:08 ` Martin Storsjö
2022-10-24 23:20 ` Mark Harmstone
2022-10-25 8:21 ` Martin Storsjö
2022-10-27 3:36 ` Mark Harmstone
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).