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

Handle clrdbg to vsdbg rename #501

Merged
merged 2 commits into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
REM
REM This is an example script for starting a project on Windows and attaching to it with clrdbg.
REM This is an example script for starting a project on Windows and attaching to it with vsdbg.
REM Various paths at the top of the script may need to be changed.
REM
REM See ExampleClrdbgLaunchOptions.Windows.xml for more information.
REM See ExampleVsDbgLaunchOptions.Windows.xml for more information.
REM

setlocal
set clrdbg=C:\dd\VSPro_VBCS\binaries\amd64chk\Debugger\x-plat\Windows\clrdbg.exe
set vsdbg=C:\dd\VSPro_VBCS\binaries\amd64chk\Debugger\x-plat\Windows\vsdbg.exe
set ProjectName=AspNet5Con
set ProjectDir=C:\proj\AspNet5Con\src\AspNet5Con
set dnx=%USERPROFILE%\.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-beta4-11296\bin\dnx.exe

if not exist "%clrdbg%" echo ERROR: %clrdbg% does not exist.>&2 & exit /b -1
if not exist "%vsdbg%" echo ERROR: %vsdbg% does not exist.>&2 & exit /b -1
if not exist "%dnx%" echo ERROR: %dnx% does not exist.>&2 & exit /b -1

start %dnx% --appbase %ProjectDir% "Microsoft.Framework.ApplicationHost" --configuration Debug "%ProjectName%"
Expand All @@ -23,4 +23,4 @@ for /f "skip=3 tokens=2" %%p in ('tasklist /FI "IMAGENAME eq dnx.exe"') do set t

if "%target_pid%"=="" echo ERROR: Failed to find dnx.exe process.>&2 & exit /b -1

%clrdbg% --interpreter=mi --attach %target_pid%
%vsdbg% --interpreter=mi --attach %target_pid%
34 changes: 20 additions & 14 deletions tools/InstallToVSCode/InstallToVSCode.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ if not exist "%OpenDebugAD7BinDir%\OpenDebugAD7.dll" echo ERROR: %OpenDebugAD7Bi
set MIEngineBinDir=%~dp0..\..\bin\%Configuration%\
if not exist "%MIEngineBinDir%Microsoft.MIDebugEngine.dll" echo ERROR: Microsoft.MIDebugEngine.dll has not been built & exit /b -1

if NOT "%~5"=="-d" echo ERROR: Bad command line argument. Expected '-d ^<clrdbg-dir^>'. & exit /b -1
if "%~6" == "" echo ERROR: Clrdbg binaries directory not set &exit /b -1
set CLRDBGBITSDIR=%~6
if not exist "%CLRDBGBITSDIR%\libclrdbg.dll" echo ERROR: %CLRDBGBITSDIR%\libclrdbg.dll does not exist. & exit /b -1
if NOT "%~5"=="-d" echo ERROR: Bad command line argument. Expected '-d ^<vsdbg-dir^>'. & exit /b -1
if "%~6" == "" echo ERROR: VsDbg binaries directory not set &exit /b -1
set VSDBGBITSDIR=%~6
if not exist "%VSDBGBITSDIR%\libvsdbg.dll" echo ERROR: %VSDBGBITSDIR%\libvsdbg.dll does not exist. & exit /b -1

set DESTDIR=%USERPROFILE%\.MIEngine-VSCode-Debug
if exist "%DESTDIR%" rmdir /s /q "%DESTDIR%"
Expand Down Expand Up @@ -92,22 +92,28 @@ for %%f in (xunit.console.netcore.exe) do call :InstallFile "%OpenDebugAD7BinDir
for %%f in (%OpenDebugAD7BinDir%\*.dll) do call :InstallFile "%%f"

echo.
echo Installing clrdbg bits from %CLRDBGBITSDIR%...
echo Installing vsdbg bits from %VSDBGBITSDIR%...

REM NOTE: We ignore files that already exist. This is because we have already
REM cleaned the directory originally, and published CoreCLR files. Replacing existing
REM files will replace some of those CoreCLR files with new copies that will not work.
for %%f in (%CLRDBGBITSDIR%\*.dll) do call :InstallNewFile "%%f"
for %%f in (%CLRDBGBITSDIR%\*.exe) do call :InstallFile "%%f"
for %%f in (%CLRDBGBITSDIR%\*.vsdconfig) do call :InstallFile "%%f"
for %%f in (%CLRDBGBITSDIR%\version.txt) do call :InstallFile "%%f"
for /D %%d in (%CLRDBGBITSDIR%\*) do (
for %%f in (%VSDBGBITSDIR%\*.dll) do call :InstallNewFile "%%f"
for %%f in (%VSDBGBITSDIR%\*.exe) do call :InstallFile "%%f"
for %%f in (%VSDBGBITSDIR%\*.vsdconfig) do call :InstallFile "%%f"
for %%f in (%VSDBGBITSDIR%\version.txt) do call :InstallFile "%%f"
for /D %%d in (%VSDBGBITSDIR%\*) do (
echo.
echo Installing clrdbg bits from %%d... to %%~nd
echo Installing vsdbg bits from %%d... to %%~nd
if NOT exist "%DESTDIR%\%%~nd" mkdir "%DESTDIR%\%%~nd
for %%f in (%%d\*.dll) do call :InstallFile "%%f" %%~nd\
)

REM Rename vsdbg back to clrdbg
Copy link
Member

Choose a reason for hiding this comment

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

is it worth having this part behind an option so we can toggle whether to rename it or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, these scripts are already forked, so I don't expect there to be much more long-term use for them.

pushd %destdir%
ren vsdbg.exe clrdbg.exe
if not "%errorlevel%"=="0" echo error: unable to rename vsdbg.exe???& exit /b -1
popd

for %%f in (coreclr\coreclr.ad7Engine.json) do call :InstallFile "%~dp0%%f"
for %%f in (Microsoft.MICore.dll Microsoft.MIDebugEngine.dll) do call :InstallFile "%MIEngineBinDir%%%f"

Expand Down Expand Up @@ -161,7 +167,7 @@ if NOT "%ERRORLEVEL%"=="0" echo ERROR: mklink failed. Ensure this script is runn
goto eof

:Help
echo InstallToVSCode ^<link^|copy^> ^<portable^|debug^> ^<oss-dev^|alpha^|insiders^|stable^> ^<open-debug-ad7-dir^> -d ^<clrdbg-binaries^>
echo InstallToVSCode ^<link^|copy^> ^<portable^|debug^> ^<oss-dev^|alpha^|insiders^|stable^> ^<open-debug-ad7-dir^> -d ^<vsdbg-binaries^>
echo.
echo This script is used to copy files needed to enable MIEngine based debugging
echo into VS Code.
Expand All @@ -179,10 +185,10 @@ echo insiders: Install to VSCode insiders
echo stable: Install to VSCode stable
echo.
echo open-debug-ad7-dir : Root of the OpenDebugAD7 repo
echo clrdbg-binaries: Directory which contains clrdbg binaries
echo vsdbg-binaries: Directory which contains vsdbg binaries
echo.
echo Example:
echo .\InstallToVSCode.cmd link portable alpha c:\dd\OpenDebugAD7 -d c:\dd\vs1\out\binaries\amd64chk\Debugger\x-plat\clrdbg
echo .\InstallToVSCode.cmd link portable alpha c:\dd\OpenDebugAD7 -d c:\dd\vs1\out\binaries\amd64chk\Debugger\x-plat\vsdbg
echo.

:eof
44 changes: 24 additions & 20 deletions tools/InstallToVSCode/InstallToVSCode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ script_dir=`dirname $0`

print_help()
{
echo 'InstallToVSCode.sh <link|copy> <oss-dev|alpha|insiders|stable> <open-debug-ad7-dir> -d <clrdbg-binaries>'
echo 'InstallToVSCode.sh <link|copy> <oss-dev|alpha|insiders|stable> <open-debug-ad7-dir> -d <vsdbg-binaries>'
echo ''
echo 'This script is used to copy files needed to enable MIEngine based debugging'
echo 'into VS Code.'
Expand All @@ -19,10 +19,10 @@ print_help()
echo ' stable: Install to VSCode stable'
echo ''
echo ' open-debug-ad7-dir : Root of the OpenDebugAD7 repo'
echo ' clrdbg-binaries-dir : Directory containing clrdbg binaries'
echo ' vsdbg-binaries-dir : Directory containing vsdbg binaries'
echo ''
echo 'Example:'
echo "$script_dir/InstallToVSCode.sh link alpha /Volumes/dd/OpenDebugAD7 -d ~/clrdbg/out/Linux/bin/x64.Debug/clrdbg"
echo "$script_dir/InstallToVSCode.sh link alpha /Volumes/dd/OpenDebugAD7 -d ~/vsdbg/out/Linux/bin/x64.Debug/vsdbg"
}

# Copies a file to another file or directory
Expand Down Expand Up @@ -119,7 +119,7 @@ SetupSymLink()
rm -r $1
fi
fi

ln -s $2 $1
return $?
}
Expand Down Expand Up @@ -171,15 +171,15 @@ pushd $DropDir >/dev/null
DropDir=$(pwd)
popd >/dev/null

[ ! "$4" == "-d" ] && echo "ERROR: Bad command line argument. Expected '-d <clrdbg-dir>'." && exit 1
CLRDBGBITSDIR=${5:?"ERROR: Clrdbg binaries directory must be specified with -d option. See -h for usage."}
[ ! -f "$CLRDBGBITSDIR/clrdbg" ] && echo "ERROR: $CLRDBGBITSDIR/clrdbg does not exist." && exit 1
[ ! "$4" == "-d" ] && echo "ERROR: Bad command line argument. Expected '-d <vsdbg-dir>'." && exit 1
VSDBGBITSDIR=${5:?"ERROR: VsDbg binaries directory must be specified with -d option. See -h for usage."}
[ ! -f "$VSDBGBITSDIR/vsdbg" ] && echo "ERROR: $VSDBGBITSDIR/vsdbg does not exist." && exit 1
DESTDIR=$HOME/.MIEngine-VSCode-Debug

VSCodeExtensionsRoot=$HOME/$VSCodeDirName/extensions
[ ! -d "$VSCodeExtensionsRoot" ] && echo "ERROR: $VSCodeExtensionsRoot does not exist." && exit 1

CSharpExtensionRoot="$(ls -d $VSCodeExtensionsRoot/ms-vscode.csharp-* 2>/dev/null)"
CSharpExtensionRoot="$(ls -d $VSCodeExtensionsRoot/ms-vscode.csharp-* 2>/dev/null)"
[ "$CSharpExtensionRoot" == "" ] && echo "ERROR: C# extension is not installed in VS Code. No directory matching '$VSCodeExtensionsRoot/ms-vscode.csharp-*' found." && exit 1

num_results=$(echo "$CSharpExtensionRoot" | wc -l)
Expand All @@ -194,7 +194,7 @@ fi
mkdir -p "$DESTDIR"
[ $? -ne 0 ] && echo "ERROR: unable to create destination directory '$DESTDIR'." && exit 1

hash dotnet 2>/dev/null
hash dotnet 2>/dev/null
[ $? -ne 0 ] && echo "ERROR: The .NET CLI is not installed. see: http://dotnet.github.io/getting-started/" && exit 1

SetupSymLink "$CSharpExtensionRoot/coreclr-debug/debugAdapters" "$DESTDIR"
Expand Down Expand Up @@ -237,40 +237,44 @@ mv "$DESTDIR/dummy" "$DESTDIR/OpenDebugAD7"

InstallError=
install_module "$OpenDebugAD7BinDir/dar.exe"
install_module "$OpenDebugAD7BinDir/xunit.console.netcore.exe" "" ignoreMissingPdbs
install_module "$OpenDebugAD7BinDir/xunit.console.netcore.exe" "" ignoreMissingPdbs
for dll in $(ls $OpenDebugAD7BinDir/*.dll); do
install_module "$dll" "" ignoreMissingPdbs
done

echo ''
echo "Installing clrdbg bits from $CLRDBGBITSDIR"
echo "Installing vsdbg bits from $VSDBGBITSDIR"

for clrdbgFile in $(ls $CLRDBGBITSDIR/*); do
if [ -f "$clrdbgFile" ]; then
for vsdbgFile in $(ls $VSDBGBITSDIR/*); do
if [ -f "$vsdbgFile" ]; then
# NOTE: We ignore files that already exist. This is because we have already
# cleaned the directory originally, and published CoreCLR files. Replacing existing
# files will replace some of those CoreCLR files with new copies that will not work.
install_new_file "$clrdbgFile"
install_new_file "$vsdbgFile"
fi
done
for directory in $(ls -d $CLRDBGBITSDIR/*/); do

for directory in $(ls -d $VSDBGBITSDIR/*/); do
directory_name=$(basename $directory)

if [ ! -d "$DESTDIR/$directory_name" ]; then
mkdir "$DESTDIR/$directory_name"
fi

for dll in $(ls $directory/*.dll); do
install_file "$dll" "$directory_name/"
done
done

# Rename vsdbg back to clrdbg
mv "$DESTDIR/vsdbg" "$DESTDIR/clrdbg"
Copy link
Member

Choose a reason for hiding this comment

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

same here.

[ $? -ne 0 ] && echo "ERROR: Unable to move vsdbg executable." && exit 1

install_file "$script_dir/coreclr/coreclr.ad7Engine.json"
install_file "$DropDir/osxlaunchhelper.scpt"

for dll in Microsoft.MICore.dll Microsoft.MIDebugEngine.dll
do
do
install_module "$DropDir/$dll"
done

Expand All @@ -290,7 +294,7 @@ fi
# Write out an install.complete file so that the C# extension doesn't try to restore.
echo "InstallToVSCode.sh done">$DESTDIR/install.complete

echo "InstallToVSCode.sh succeeded. Open directory '$OpenDebugAD7Dir' in VS Code"
echo "InstallToVSCode.sh succeeded. Open directory '$OpenDebugAD7Dir' in VS Code"
echo "to debug. Edit .vscode/launch.json before launching."
echo ""
exit 0