Date: Sat, 15 Mar 2025 15:44:20 +0100
Do you plan to support an interface for advanced data structures like trees or graphs?
Or even interactive code?
You are focusing on ELFs and DWARFs (dwarves?) for now? Or would the implementation be Unix and the attributes system independent?
-----Ursprüngliche Nachricht-----
Von:Henning Meyer via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Sa 15.03.2025 15:11
Betreff:Re: [std-proposals] Providing information about data structures to the compiler
An:Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]>;
CC:Henning Meyer <hmeyer.eu_at_[hidden]>;
Functions and methods just for use by the debugger would be eliminated
completely by the optimizer in production builds. You would need an
attribute to tell the compiler to keep it around even if it is not used.
For example, in the case of ELF binaries with DWARF debug information,
you would want the compiler to emit unoptimized, non-inlined functions
for begin(), end(), size(), probably to_string() as well. These could go
into a new, separate .debug_text section that can be stripped from
binaries. This requires cooperation from libraries ([[debug]]
annotations), compiler, linker and debugger. I am working on a prototype
implementation.
If the only purpose is for code to be run in the debugger, they could
even be emitted in DWARF opcodes instead of machine code, but for now I
am lifting the generated machine code back to DWARF opcodes (for pure
functions like std::vector begin() and end()) or run them in a VM
(to_string() methods and functions that might allocate and free).
Containers aren't so bad, std::variant and std::any require more effort
(if you want to support them generically, i.e. boost and everyone else's
re-implementation as well).
On 15.03.25 14:45, Sebastian Wittmeier via Std-Proposals wrote:
> AW: [std-proposals] Providing information about data structures to the
> compiler
>
> What one could do besides attributes is to have functions just for use
> by the debugger.
>
> Like an integrated debug interface.
>
> Anything similar already out there for C++?
>
> Other languages:
>
> Elixir
>
> Inspect protocol
>
> https://hexdocs.pm/elixir/Inspect.html
>
> Rust:
>
> #[derive(Debug)] attribute
>
> https://doc.rust-lang.org/rust-by-example/hello/print/print_debug.html
>
> Julia:
>
> overloading Base.show member function
>
> https://docs.julialang.org/en/v1/manual/types/#man-custom-pretty-printing
>
> C#
>
> DebuggerDisplay attribute
>
> https://learn.microsoft.com/en-us/visualstudio/debugger/using-the-debuggerdisplay-attribute?view=vs-2022
>
> Python:
>
> __repr__ member function
>
> https://docs.python.org/3/library/functions.html#repr
>
> -----Ursprüngliche Nachricht-----
> *Von:* Henning Meyer via Std-Proposals
> <std-proposals_at_[hidden]>
> - For ranges, the language has a way of marking them, that is via
> begin()/end() methods or free functions.
>
>
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-03-15 14:49:31