Skip to content
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

Setting cwd explicitly to ensure lldb remote debugging works on relative paths in debug info etc. #127

Merged
merged 1 commit into from
Oct 1, 2020

Conversation

gyfelton
Copy link
Contributor

@gyfelton gyfelton commented Oct 1, 2020

This is important for lldb debugger to work correctly according to https://lldb.llvm.org/use/remote.html#id6
In future we can ask developers to run platform status inside lldb to ensure some metadata is correct.

Without this change, do platform shell pwd in lldb says / and after this it becomes whatever workspace you are actually in.

This might be a solution to some past/existing issues related to lldb debugger.
Testing against downstream project to make sure this works.

# NOTE: In order to use this, add this line to `~/.lldbinit`:
#
# command source ~/.lldbinit-source-map
cat <<-END > ~/.lldbinit-source-map
settings set target.source-map ./ "$BAZEL_WORKSPACE_ROOT/"
settings set target.sdk-path $SDKROOT
settings set target.swift-framework-search-paths $FRAMEWORK_SEARCH_PATHS

platform settings -w "$BAZEL_WORKSPACE_ROOT/"
Copy link

Choose a reason for hiding this comment

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

Interesting, I've only tested this by doing script import os; os.chdir("$BAZEL_WORKSPACE_ROOT") but this seems nicer if it works 🤔

Do you have to reset this setting in other LLDB sessions? you do for my option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@keith do you do script import os; os.chdir("$BAZEL_WORKSPACE_ROOT") in ~/.lldbinit-source-map as well like here? It fails for me for some reason

Copy link
Contributor Author

@gyfelton gyfelton Oct 1, 2020

Choose a reason for hiding this comment

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

and this setting works btw, tested in downstream project that uses this

Copy link

Choose a reason for hiding this comment

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

IIRC with the script option lldb-rpc-server kept around some state about that change, where it looks like it doesn't with your change, which is awesome

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@keith so this is going to be a problem for bazel projects not built using this rules_ios because this script is embedded inside every xcodeproj generated here so running one will overwrite the content from the previous one.
As we are switching to use per scheme .lldbinit file in future, we will eventually pointing this script to a per-project file not user directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC with the script option lldb-rpc-server kept around some state about that change, where it looks like it doesn't with your change, which is awesome

Wanted to learn how u know about the state in this lldb-rpc-server, also i wonder what does platform status output looks like for you when use the script os.chdir("$BAZEL_WORKSPACE_ROOT"). This can be invoked in the debugging window with lldb

@gyfelton gyfelton force-pushed the set_current_working_directory branch from 8e0da5f to 8cdc04c Compare October 1, 2020 19:22
settings set target.source-map ./ "$BAZEL_WORKSPACE_ROOT/"
settings set target.sdk-path $SDKROOT
settings set target.swift-framework-search-paths $FRAMEWORK_SEARCH_PATHS

Copy link
Member

Choose a reason for hiding this comment

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

are these trailing newlines intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, let me fix this and merge

@gyfelton gyfelton marked this pull request as draft October 1, 2020 19:33
@gyfelton gyfelton marked this pull request as ready for review October 1, 2020 19:41
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