Selecting Source Code Manually

If Debugger wasn't able to select your correct source code automatically, you can manually specify the location and version of your code.

Expand the Alternative source code panel on the Debug page to display your options:

Alternative source code pane

  • Local files: The local files option allows you to select a directory on your local machine containing your project's source files. Stackdriver Debugger displays the source code in the web UI using standard HTML5 APIs. The source code is only used locally for the current debugging session. No source code is uploaded to Google servers when debugging with local files. However, you will need to provide access to local source in each session and make sure that the local source code matches the deployed revision of the source. Use local files.

  • Google Cloud Source Repository: Cloud Source Repositories are fully-featured private Git repositories hosted on Google Cloud Platform. If you have not set up a repo for your source code yet, Google Cloud Repository is a great place to start. You can select a Cloud Source Repository from any project to which you have access - it does not have to belong to the same project as the app that you're debugging. Use Google Cloud Repository.

  • GitHub repository: Stackdriver Debugger integrates directly with GitHub repositories. Connecting to your GitHub repo allows you to view your source code on the Debug page without storing it on Google servers. Use a GitHub repo.

  • Bitbucket repository: Stackdriver Debugger integrates directly with Bitbucket repositories. Connecting to your Bitbucket repo allows you to view your source code on the Debug page without storing it on Google servers. Use a Bitbucket repo.

  • App Engine: For applications running on App Engine standard environment, in Python or PHP, view the application source code as it was deployed to App Engine, without having to connect to your repo or upload any code. Use App Engine source.

  • Upload a source code capture: Using source capture makes it easy to use the source code for debugging, over multiple sessions, even when a source change is not submitted to the source control repo. The source is captured and uploaded to Google for a specific deployment of the application. Once the application is redeployed, a new source capture is required. Use source code capture.

Local files

Regardless of where your source code is stored, you can view local source code on the Debug page. Your files are not uploaded to Google's servers; instead, they're loaded and displayed in the browser using HTML5 APIs. This option is only supported in Google Chrome.

  1. From the source location drop-down menu, click Add source code...
  2. In the Alternative source code pane, find the Local files section and click Select source.
  3. Browse to the directory containing your source files and click Upload or OK, depending on your platform. Your files are displayed on the Debug page.

Google Cloud Source Repository

If your code is hosted in Google Cloud Source Repository, it's made available to Stackdriver Debugger automatically. You can also point Stackdriver Debugger at other repos in Cloud Source Repository:

  1. From the source location drop-down menu, click Add source code...
  2. In the Alternative source code pane, find the Google Cloud Source Repository section and click Select source.
  3. Select the project, repository, and the branch or tagged version.
  4. Click Select source.

The contents of the selected repository are displayed on the Debug page. Read Using Stackdriver Debugger for your next steps.

GitHub repository

To connect to your GitHub repositories, you must grant Google Stackdriver access to your repositories. The GitHub OAuth token is stored by Google, and can be revoked from GitHub's settings page at any time.

  1. In the Alternative source code pane, find the GitHub Repository section, and click Select source.
  2. An Authorization required window appears. Read the information, then select I consent... and click Authorize.

    Alternative source code pane

    You are redirected to GitHub's authentication flow.

  3. Follow GitHub's instructions to grant Google Stackdriver access to your repositories. Google Stackdriver requires read access only. Once complete, you are returned to the Debug page.

  4. Select your repository and branch or tag, and click Select source. Your source code is displayed in on the Debug page.

Note that your source code is not stored on Google servers.

Read Using Stackdriver Debugger for your next steps.

Bitbucket repository

To connect to your Bitbucket repositories, you must grant Google Stackdriver access to your repositories. The Bitbucket OAuth token is stored by Google, and can be revoked from Bitbucket's Access Management page. Visit https://bitbucket.org/account/ and select OAuth from the left menu.

  1. In the Alternative source code pane, find the Bitbucket Repository section, and click Select source.
  2. An Authorization required window appears. Read the information, then select I consent... and click Authorize. You are redirected to Bitbucket's authentication flow.
  3. Follow Bitbucket's instructions to grant Google Stackdriver access to your repositories. Google Stackdriver requires read access only. Once complete, you're returned to the Debug page.
  4. Select your repository and branch, and click Select source. Your source code is displayed in Debugger.

Note that your source code is not stored on Google servers.

Read Using Stackdriver Debugger for your next steps.

App Engine

If your app is hosted on App Engine standard environment (flexible environment is not supported) and is written in PHP or Python, this option displays the source code as it was deployed to App Engine, without the need to connect a repo or upload your source.

This option should be selected automatically for supported projects; if it was not selected:

  1. In the Alternative source code pane, find the App Engine section, and click Select source.

Your files are displayed in the Stackdriver Debugger view. Read Using Stackdriver Debugger for your next steps.

Upload a source code capture

You can upload a capture of your source code to Google for use in multiple debug sessions. You must have the gcloud command line tool installed to take a source code capture.

  1. From the source location drop-down menu, click Add source code...
  2. In the Alternative source code pane, in the section labeled Upload a source code capture to Google servers, copy the gcloud command and paste it into your terminal application.
  3. Replace LOCAL_PATH with the location of your source code directory.
  4. Execute the gcloud command.
  5. In the Alternative source code pane, click Select source in the Upload a source code capture... section.

Your files are displayed in the Stackdriver Debugger view. Read Using Stackdriver Debugger for your next steps.

Send feedback about...

Stackdriver Debugger Documentation