Skip to content

[stdlib] Clean up debug printing code #18126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2018

Conversation

airspeedswift
Copy link
Member

This code has been largely untouched since the early days and has missed out on a few possible improvements since, especially with optionals. Hopefully a NFC, though it doesn't look like it's got full test coverage.

Also removed all inlineable annotations – it oughtn't be necessary to inline any code if it's for debugging, and there's no public generic code to specialize.

@airspeedswift
Copy link
Member Author

@swift-ci please test

printedElements += 1
}
}

// LLDB uses this function in expressions, and if it is inlined the resulting
// LLVM IR is enormous. As a result, to improve LLDB performance we are not
// making it @inlinable.
public static func stringForPrintObject(_ value: Any) -> String {
var maxItemCounter = Int.max
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is... quite a big maximum.

public
func _debuggerTestingCheckExpect(_ checked_value: String,
_ expected_value: String) {}
public func _debuggerTestingCheckExpect(_: String, _: String) { }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this global symbol could be eliminated and users could call into the _DebuggerSupport version directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the retain count getters below could be moved into _DebuggerSupport, too, so that stringForPrintObject isn't the only definition there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think there's no reason to keep this global.

@airspeedswift
Copy link
Member Author

@swift-ci please test

@airspeedswift
Copy link
Member Author

@swift-ci please clean test macOS platform

@swiftlang swiftlang deleted a comment from swift-ci Jul 22, 2018
@swiftlang swiftlang deleted a comment from swift-ci Jul 22, 2018
Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

public
func _debuggerTestingCheckExpect(_ checked_value: String,
_ expected_value: String) {}
public func _debuggerTestingCheckExpect(_: String, _: String) { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the retain count getters below could be moved into _DebuggerSupport, too, so that stringForPrintObject isn't the only definition there.

public
func _debuggerTestingCheckExpect(_ checked_value: String,
_ expected_value: String) {}
public func _debuggerTestingCheckExpect(_: String, _: String) { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think there's no reason to keep this global.

printedElements += 1
}
}

// LLDB uses this function in expressions, and if it is inlined the resulting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment stale?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I'm going to land this, and then will take care of that in a follow-up PR, at the same time as moving those global symbols.

@airspeedswift airspeedswift merged commit f4eae3f into swiftlang:master Jul 23, 2018
@dcci
Copy link
Member

dcci commented Jul 23, 2018

Cool. Thanks for the spring cleaning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants