Commit Graph

50 Commits

Author SHA1 Message Date
Alejandro Alonso
b2f21bbfb3 Update DebuggerSupport.swift 2024-05-15 10:02:35 -07:00
Alejandro Alonso
180a11fdc2 Print strings using their description in the debugger 2024-05-09 14:36:57 -07:00
Dave Lee
e57f70bd4d [Debugging] Add DebugDescriptionMacro experimental feature (#73107)
This removes the leading underscore from the macro.
2024-04-18 17:25:44 -07:00
Karoy Lorentey
16240a1342 [stdlib] Do not introduce any new ABI symbols for _get*RetainCount 2024-02-27 13:18:28 -08:00
Mishal Shah
b8cd763b21 Merge branch 'main' into bump-swift-version-to-6 2024-02-21 12:40:54 -08:00
Dave Lee
5b35938e5b [Debug] Introduce use of DebugDescription macro in stdlib (#71425)
Introduces the first use of `@_DebugDescription` in the standard library, applying it 
to `ObjectIdentifier`. In order to use the DebugDescription macro in the stdlib, the 
following changes are required:

1. Compilation must reference the just built macros (ie `libSwiftMacros.dylib`), not 
those from the SDK. This is addressed by adding an explicit `-external-plugin-path` 
flag that overrides the defaults generated by the compiler (which uses SDK paths, where 
the macro may or may not exist, and may not be the current version).
2. As DebugDescription uses `@_section`, compilation enables the `SymbolLinkageMarkers` 
feature.

Note that the use of DebugDescription is conditionally enabled for the following 
reasons:

1. Use is disabled in freestanding builds, where the stdlib macros are not built.
2. Use is temporarily disabled in Linux builds due to a dynamic loader issue that needs 
further investigation

The dynamic loader error causing issues with Linux CI is:
> swift-plugin-server: error while loading shared libraries: libswiftGlibc.so: cannot 
open shared object file: No such file or directory

This PR depended on #71639, #71588, and #71685.
2024-02-21 09:17:10 -08:00
Mishal Shah
b488702cc9 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-20 21:04:47 -08:00
Dave Lee
b79c4ded76 [Debugging] Expand DebugDescriptionMacro docstring (#71700)
Describe more details of `DebugDescriptionMacro`.
2024-02-20 10:28:31 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Dave Lee
a56c89f97e [Debug] Conditional _DebugDescription macro declaration (#70351)
Make `_DebugDescription` macro conditional upon macro availability in the build.

The `Macros` feature is based on the value of `SWIFT_BUILD_SWIFT_SYNTAX`.

See https://github.com/apple/swift/pull/69626#issuecomment-1848221971
2023-12-12 15:19:49 -08:00
Dave Lee
ad585b3195 [Debug] Add _DebugDescription macro (#69626)
Implementation of the DebugDescription macro pitched on the forums: 
https://forums.swift.org/t/pitch-debug-description-macro/67711. In this initial commit, 
the macro is named `_DebugDescription` to indicate it's internal use at this time, 
pending Swift Evolution.

rdar://115180949
2023-12-08 15:19:16 -08:00
Yuta Saito
7df19b86ea [stdlib] Fix calling convention mismatch for debugger utility functions (#69352)
This is the 3rd attempt to fix the mismatch, where the actual definition
(e.g. `swift_retainCount`) are defined with C calling-convention and the
callers wrongly expect Swift calling-convention.

The 1st fix broke ABI compatibility by introducing new symbol references
from app-side without any availability checks.
The 2nd fix broke lldb's retain counting feature due to new x-ref to
Clang module in serialized function body by `@_alwaysEmitIntoClient`.

This attemps to avoid introducing serialized x-ref to Clang module by
using new `@_extern(c)` attribute.

Resolves rdar://113910821

Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2023-11-08 10:45:28 -08:00
Stephen Canon
20a11db290 Revert "[stdlib] Fix calling convention mismatch for debugger utility functions" 2023-08-09 07:31:58 -04:00
Max Desiatov
819d9847a5 stdlib/public/core: use UInt(bitPattern:) to make sure casts work 2023-07-31 16:50:52 +01:00
Yuta Saito
8124738fc2 [stdlib] Fix calling convention mismatch for debugger utility functions
The functions `swift_retainCount`, `swift_unownedRetainCount`, and
`swift_weakRetainCount` are declared in `HeapObject.h` as using
the C calling convention, but the Swift declarations referenced them
by `@_silgen_name`, which uses the Swift calling convention. This
patch fixes the mismatch without any ABI/API breakage by calling the
utility functions through C interop.
2023-06-10 07:40:50 +00:00
Kuba (Brecka) Mracek
404badb49a Introduce SWIFT_ENABLE_REFLECTION to turn on/off the support for Mirrors and reflection (#33617) 2021-09-08 13:08:13 -07:00
Ben Cohen
125902923c Revert lazy mirror children (#36722) 2021-04-08 16:34:50 -10:00
tbkka
524cfae1b2 [Dynamic Casting] Overhauled Runtime (#33561)
* Dynamic Cast Rework: Runtime

This is a completely refactored version of the core swift_dynamicCast
runtime method.

This fixes a number of bugs, especially in the handling of multiply-wrapped
types such as Optional within Any.  The result should be much closer to the
behavior specified by `docs/DynamicCasting.md`.

Most of the type-specific logic is simply copied over from the
earlier implementation, but the overall structure has been changed
to be uniformly recursive.  In particular, this provides uniform
handling of Optional, existentials, Any and other common "box"
types along all paths.  The consistent structure should also be
easier to update in the future with new general types.

Benchmarking does not show any noticable performance implications.

**Temporarily**, the old implementation is still available.  Setting the
environment variable `SWIFT_OLD_DYNAMIC_CAST_RUNTIME` before launching a program
will use the old runtime implementation.  This is only to facilitate testing;
once the new implementation is stable, I expect to completely remove the old
implementation.
2020-08-27 11:06:40 -07:00
Ben Cohen
5ec1e3ed7b Refactor Mirror to reduce metadata allocation (#32041)
- Refactor Mirror.descendents

- Add _Either sequence

- Create custom reflected children type

- Switch Mirror to use _Either
2020-05-28 10:51:57 -07:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Sho Ikeda
a35c9f0c60 [gardening] Use Collection.isEmpty over Collection.count 2019-05-26 09:35:20 +09:00
Ben Cohen
f4eae3fff0 Clean up debug printing code (#18126) 2018-07-23 10:11:37 -07:00
swift-ci
65b22697ae Merge pull request #15770 from dcci/refcount-obj 2018-04-09 12:12:32 -07:00
Davide Italiano
6535d8cec8 [DebuggerSupport] Expose a way to query the reference counts.
lldb will use it to reimplement `language swift refcount <obj>`
which is currently not working. Asking the compiler allows us
to avoid maintinaing a bunch of information in the debugger which
are likely to change and break.

<rdar://problem/30538363>
2018-04-06 13:12:53 -07:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Vedant Kumar
ca27e829ba Add a transform to help test lldb expression evaluation
The initial version of the debugger testing transform instruments
assignments in a way that allows the debugger to sanity-check its
expression evaluator.

Given an assignment expression of the form:

```
  a = b
```

The transform rewrites the relevant bits of the AST to look like this:

```
  { () -> () in
    a = b
    checkExpect("a", stringForPrintObject(a))
  }()
```

The purpose of the rewrite is to make it easier to exercise the
debugger's expression evaluator in new contexts. This can be automated
by having the debugger set a breakpoint on checkExpect, running `expr
$Varname`, and comparing the result to the expected value generated by
the runtime.

While the initial version of this testing transform only supports
instrumenting assignments, it should be simple to teach it to do more
interesting rewrites.

There's a driver script available in SWIFT_BIN_DIR/lldb-check-expect to
simplfiy the process of launching and testing instrumented programs.

rdar://36032055
2018-03-30 16:50:31 -07:00
Jordan Rose
9034ba617b Ban @_fixed_layout on enums in favor of @_frozen
In theory there could be a "fixed-layout" enum that's not exhaustive
but promises not to add any more cases with payloads, but we don't
need that distinction today.

(Note that @objc enums are still "fixed-layout" in the actual sense of
"having a compile-time known layout". There's just no special way to
spell that.)
2018-03-20 14:49:10 -07:00
Vedant Kumar
5049db0dd9 [DebuggerSupport] Attempt expanding objects with .class display style
When pretty-printing objects, attempt to expand & print objects which
have the `.class` display style even if they do not have any instance
variables. The pretty-printer will still bail out if the object does not
conform to CustomReflectable.

This is enough to teach the pretty-printer to format bridged NSStrings.

rdar://36843869
2018-01-29 15:31:53 -08:00
Max Moiseev
5650f80937 [stdlib] Annotate types with @_fixed_layout
This will allows us to build the standard library in resilient mode by
default, hopefully, without performance regression.

<rdar://problem/36362648>
2018-01-09 14:46:30 -08:00
Slava Pestov
c272d41e2f Re-apply "SIL: Remove special meaning for @_semantics("stdlib_binary_only")"
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-04 14:07:52 -07:00
Jordan Rose
aab5f7aa4f Revert "SIL: Remove special meaning for @_semantics("stdlib_binary_only")" (#12270)
It still affects StdlibUnittest, which is still using -sil-serialize-all.
2017-10-04 12:49:21 -07:00
Slava Pestov
0fad13eeba SIL: Remove special meaning for @_semantics("stdlib_binary_only")
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-03 13:48:22 -07:00
Max Moiseev
b30b937ed3 Revert making some enums public
The compiler problem was fixed: rdar://problem/34342955
2017-09-29 11:26:56 -07:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift
3a4ee89034 [gardening] Use consistent formatting. 2016-09-17 12:12:49 +02:00
Sean Callanan
694ef45a09 Added an explicatory comment, thanks to Dmitri Gribenko for the suggestion. 2016-08-10 15:57:25 -07:00
Sean Callanan
8ab85d7a3e Put @_sematics on its own line, thanks to Erik Eckstein for the comment. 2016-08-10 15:35:32 -07:00
Sean Callanan
b57926895f [stdlib] Make the stringForPrintObject function not inlined by default.
Inlining it causes the lldb "po" command to generate a 50KB binary blob that
needs to be injected into the target process.  It is much faster to just call
into the standard-library binary.

<rdar://problem/27710066>
2016-08-10 15:11:34 -07:00
Robert Widmann
14dc86cf15 Polish off uses of dynamicType in codebase 2016-07-29 16:58:40 -07:00
Joe Groff
9effc047e6 Update standard library for id-as-Any. 2016-07-25 06:01:21 -07:00
Tony Parker
2a4e916296 Rename OutputStream to TextOutputStream [SE-0086] 2016-07-18 16:47:23 -07:00
practicalswift
68af19b6b8 [gardening] Fix incorrect header filenames 2016-07-15 10:23:42 +02:00
practicalswift
a8c18a5242 [gardening] Don't compare to false. 2016-07-15 10:20:15 +02:00
Enrico Granata
4990fbd074 In order to avoid reference cycles and repeat printing of data, stringForPrintObject maintains a list of references it has encountered and skips printing them
Bridging was causing an issue where some value types were being bridged into references and ending up randomly causing collisions which would make certain data not be printed when it should have

Make it so that we only tuck away references we know are natively references for uniqueness purposes

Fixes rdar://problem/27319054
2016-07-13 16:36:56 -07:00
Enrico Granata
061b681d9f Minor tweak to stringForPrintObject to not say "1 elements" 2016-07-13 14:47:56 -07:00
Enrico Granata
dccff399e3 Adjust for latest round of code review; change PrintForDebugger to _DebuggerSupport and stringForPrintObject; minor indentation and label fixups 2016-07-11 18:32:18 -07:00