- Source Server
- Source Indexing
- Retrieving the Source File
- Using Source Server with a Debugger
- Source Server Data Blocks
- How Source Server Works
- Creating a Source Control Provider Module
- Подключение к источнику данных SQL Server (мастер импорта и экспорта SQL Server) Connect to a SQL Server Data Source (SQL Server Import and Export Wizard)
- Подключение к SQL Server через поставщик Microsoft OLE DB для SQL Server Connect to SQL Server with the .NET Framework Data Provider for SQL Server
- Указываемые параметры (поставщик данных .NET Framework для SQL Server) Options to specify (.NET Framework Data Provider for SQL Server)
- Подключение к SQL Server с помощью драйвера ODBC для SQL Server Connect to SQL Server with the ODBC driver for SQL Server
- Указываемые параметры (драйвер ODBC для SQL Server) Options to specify (ODBC driver for SQL Server)
- Формат строки подключения Connection string format
- Ввод строки подключения Enter the connection string
- Подключение к SQL Server с помощью поставщика OLE DB для SQL Server (Майкрософт) или SQL Server Native Client Connect to SQL Server with the Microsoft OLE DB Provider for SQL Server or SQL Server Native Client
- Другие поставщики данных и дополнительные сведения Other data providers and more info
Source Server
Source server enables a client to retrieve the exact version of the source files that were used to build an application. Because the source code for a module can change between versions and over a course of years, it is important to look at the source code as it existed when the version of the module in question was built.
Source server retrieves the appropriate files from source control. To use source server, the application must have been source indexed.
Source Indexing
The source indexing system is a collection of executable files and Perl scripts. The Perl scripts require Perl 5.6 or greater.
Generally, binaries are source indexed during the build process after the application has been built. The information needed by source server is stored in the PDB files.
Source server currently ships with scripts that should work with the following source-control systems.
- Team Foundation Server
- Perforce
- Visual SourceSafe
- CVS
- Subversion
You can also create a custom script to index your code for a different source-control system.
The following table lists the source server tools.
Tool | Description |
---|---|
Srcsrv.ini | This file is the master list of all source control servers. Each entry has the following format:MYSERVER=serverinfo When using Perforce, the server info consists of the full network path to the server, followed by a colon, followed by the port number it uses. For example: MYSERVER=machine.corp.company.com:1666 This file can be installed on the computer running the debugger. When source server starts, it looks at Srcsrv.ini for values; these values will override the information contained in the PDB file. This enables users to configure a debugger to use an alternate source control server at debug time. For more information, see the example Srcsrv.ini installed with the source server tools. |
Ssindex.cmd | This script builds the list of files checked into source control along with the version information of each file. It stores a subset of this information in the .pdb files generated when you built the application. The script uses one of the following Perl modules to interface with source control: P4.pm (Perforce) or Vss.pm (Visual Source Safe).For more information, run the script with the -? or -?? (verbose help) option or examine the script. |
Srctool.exe | This utility lists all files indexed within a .pdb file. For each file, it lists the full path, source control server, and version number of the file. You can use this information to retrieve files without using the source server.For more information, run the utility with the /? option. |
Pdbstr.exe | This utility is used by the indexing scripts to insert the version control information into the «srcsrv» alternate stream of the target .pdb file. It can also read any stream from a .pdb file. You can use this information to verify that the indexing scripts are working properly.For more information, run the utility with the /? option. |
Retrieving the Source File
The DbgHelp API provides access to source server functionality through the SymGetSourceFile function. To retrieve the name of the source file to be retrieved, call the SymEnumSourceFiles or SymGetLineFromAddr64 function.
Using Source Server with a Debugger
To use the source server with WinDbg, KD, NTSD, or CDB, ensure that you have installed a recent version of the Debugging Tools for Windows package (version 6.3 or later). Then, include srv* in the .srcpath command as follows:
.srcpath srv*;c:\mysource
Note that this example also includes a traditional source path. If the debugger cannot retrieve the file from the source server, it will search the specified path.
If a source file is retrieved by the source server, it will remain on your hard drive after the debugging session is over. Source files are stored locally in the src subdirectory of the Debugging Tools for Windows installation directory.
Source Server Data Blocks
Source server relies on two blocks of data within the PDB file.
- Source file list. Building a module automatically creates a list of fully qualified paths to the source files used to build the module.
- Data block. Indexing the source as described previously adds an alternate stream to the PDB file named «srcsrv». The script that inserts this data is dependent on the specific build process and source control system in use.
In the language specification version 1, the data block is divided into three sections: ini, variables, and source files. It has the following syntax.
All text is interpreted literally, except for text enclosed in percent signs (%). Text enclosed in percent signs is treated as a variable name to be resolved recursively, unless it is one of the following functions:
The parameter text should be enclosed in percent signs and treated as a variable to be expanded.
All forward slashes (/) in the parameter text should be replaced with backward slashes (\).
All path information in the parameter text should be stripped out, leaving only the file name.
The ini section contains variables that describe the requirements. The indexing script can add any number of variables to this section. The following are examples:
The language specification version. This variable is required.
A string that describes the source control product. This variable is optional.
A string that indicates the date and time the PDB file was processed. This variable is optional.
The variables section contains variables that describe how to extract a file from source control. It can also be used to define commonly used text as variables to reduce the size of the data block.
Describes how to build the target path for the extracted file. This is a required variable.
Describes how to build the command to extract the file from source control. This includes the name of the executable file and its command-line parameters. This is a required variable.
A string that lists environment variables to be created during the file extraction. Separate multiple entries with a backspace character (\b). This is an optional variable.
The source files section contains an entry for each source file that has been indexed. The contents of each line are interpreted as variables with the names VAR1, VAR2, VAR3, and so on until VAR10. The variables are separated by asterisks. VAR1 must specify the fully qualified path to the source file as listed elsewhere in the PDB file. For example, the following line:
is interpreted as follows:
In this example, VAR4 is a version number. However, most source control systems support labeling files in such a way that the source state for a given build can be restored. Therefore, you could alternately use the label for the build. The sample data block could be modified to contain a variable such as the following:
Then, presuming the source control system uses the at sign (@) to indicate a label, you could modify the SRCSRVCMD variable as follows:
sd.exe -p %fnvar%(%var2%) print -o %srcsrvtrg% -q %depot%/%var3%@%label%
How Source Server Works
The source server client is implemented in Symsrv.dll. The client does not extract information directly from the PDB file; it uses a symbol handler such as the one implemented in Dbghelp.dll. It is essentially a recursive variable substitution engine that creates a command line that can be used to extract the proper source file from the source control system. Your code should not call Symsrv.dll directly. To integrate its functionality into your application, use the SymGetSourceFile function.
The first version of source server works as follows. This behavior may change in future versions.
- The client calls the SrcSrvInit function with the target path to be used as a base for all source file extractions. It stores this path in the TARG variable.
- The client extracts the Srcsrv stream from the PDB when the module PDB is loaded and calls the SrcSrvLoadModule function to pass the data block to source server.
- When Dbghelp retrieves a source file, the client calls the SrcSrvGetFile function to retrieve the source files from source control.
- Source server searches the source file entries in the data block for an entry that matches the requested file. It fills VAR1 to VARn with the contents of the source file entry. Next, it expands the SRCSRVTRG variable using VAR1 to VARn. If the file is already in this location, it returns the location to the caller. Otherwise, it expands the SRCSRVCMD variable to build the command needed to retrieve the file from source control and copy it to the target location. Finally, it executes this command.
Creating a Source Control Provider Module
The source server includes provider modules for Perforce (p4.pm) and Visual Source Safe (vss.pm). To create your own provider module, you must implement the following set of interfaces.
$module::SimpleUsage()
Purpose: Displays simple module usage information to STDOUT.
Return value: None
$module::VerboseUsage()
Purpose: Displays in-depth module usage information to STDOUT.
Return value: None
$objref = $module::new(@CommandArguments)
Purpose: Initializes an instance of the provider module.
Parameters: All @ARGV arguments that were not recognized by SSIndex.cmd as being general arguments.
Return value: A reference that can be used in later operations.
$objref->GatherFileInformation($SourcePath, $ServerHashReference)
Purpose: Enables the module to gather the required source indexing information for the directory specified by the $SourcePath parameter. The module should not assume that this entry will be called only once for each object instance, as SSIndex.cmd may call it multiple times for different paths.
Parameters: (1) The local directory containing the source to be indexed. (2) A reference to a hash containing all of the entries from the specified Srcsrv.ini file.
Return value: None
($VariableHashReference, $FileEntry) = $objref->GetFileInfo($LocalFile)
Purpose: Provides the necessary information to extract a single, specific file from the source control system.
Parameters: A fully qualified file name
Return value: (1) A hash reference of the variables necessary to interpret the returned $FileEntry. SSIndex.cmd caches these variables for every source file used by a single debug file to reduce the amount of information written to the source index stream. (2) The file entry to be written to the source index stream to allow SrcSrv.dll to extract this file from source control. The exact format of this line is specific to the source control system.
$TextString = $objref->LongName()
Purpose: Provides a descriptive string to identify the source control provider to the end user.
Return value: The descriptive name of the source control system.
@StreamVariableLines = $objref->SourceStreamVariables()
Purpose: Enables the source control provider to add source control specific variables to the source stream for each debug file. The sample modules use this method for writing the required EXTRACT_CMD and EXTRACT_TARGET variables.
Return value: The list of entries for the source stream variables.
Подключение к источнику данных SQL Server (мастер импорта и экспорта SQL Server) Connect to a SQL Server Data Source (SQL Server Import and Export Wizard)
Применимо к: Applies to: SQL Server SQL Server (все поддерживаемые версии) SQL Server SQL Server (all supported versions) Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory Применимо к: Applies to: SQL Server SQL Server (все поддерживаемые версии) SQL Server SQL Server (all supported versions) Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory Azure-SSIS Integration Runtime в Фабрике данных Azure SSIS Integration Runtime in Azure Data Factory
В этом разделе показано, как подключаться к источникам данных Microsoft SQL Server со страницы Выбор источника данных или Выбор назначения в мастере импорта и экспорта SQL Server. This topic shows you how to connect to a Microsoft SQL Server data source from the Choose a Data Source or Choose a Destination page of the SQL Server Import and Export Wizard. Для подключения к SQL Server можно использовать ряд поставщиков данных. There are several data providers that you can use to connect to SQL Server.
В сети с несколькими серверами может быть проще ввести имя сервера, а не разворачивать раскрывающийся список серверов. If you’re on a network with multiple servers, it may be easier to enter the server name rather than expand the drop-down list of servers. Если вы щелкнете раскрывающийся список, запрос всех доступных серверов может потребовать много времени, причем нужного сервера может не оказаться в списке. If you click the drop-down list, it may take a lot of time to query the network for all available servers, and the results may not even include the server you want.
Подключение к SQL Server через поставщик Microsoft OLE DB для SQL Server Connect to SQL Server with the .NET Framework Data Provider for SQL Server
После выбора элемента Поставщик данных .NET Framework для SQL Server на странице Выбор источника данных или Выбор назначения мастера появится сгруппированный список параметров для поставщика. After you select .NET Framework Data Provider for SQL Server on the Choose a Data Source or Choose a Destination page of the wizard, the page displays a grouped list of options for the provider. Многие из них могут быть вам незнакомы или иметь непонятные имена. Many of these are unfriendly names and unfamiliar settings. К счастью, для подключения к любой корпоративной базе данных, как правило, необходимо указать лишь некоторые данные. Fortunately, to connect to any enterprise database, you typically have to provide only a few pieces of information. Остальные параметры можно пропустить. You can ignore the default values for the other settings.
Параметры подключения для этого поставщика данных одинаковы независимо от того, является ли сервер SQL Server источником или назначением. The connection options for this data provider are the same whether SQL Server is your source or your destination. Таким образом, на страницах Выбор источника данных и Выбор назначения мастера отображаются одинаковые параметры. That is, the options you see are the same on both the Choose a Data Source and the Choose a Destination pages of the wizard.
Необходимые сведения Required info | Свойство «Поставщик данных .NET Framework для SQL Server» .Net Framework Data Provider for SQL Server property |
---|---|
Аутентификация Authentication | По умолчанию выберите для NotSpecified «Встроенная система безопасности» или выберите другой режим проверки подлинности. Default NotSpecified as “Integrated Security”, or choose other authentication mode. «Интерактивная проверка подлинности Active Directory» не поддерживается. “Interactive Active Directory Authentication” is not supported. |
Имя сервера Server name | Источник данных Data Source |
Сведения для проверки подлинности (имя входа) Authentication (login) info | Встроенная система безопасности или Идентификатор пользователя и Пароль Integrated Security; or, User ID and Password Чтобы открыть раскрывающийся список баз данных на сервере, сначала нужно указать действительные данные для входа. If you want to see a drop-down list of databases on the server, you first have to provide valid login info. |
Имя базы данных Database name | Исходный каталог Initial Catalog |
Указываемые параметры (поставщик данных .NET Framework для SQL Server) Options to specify (.NET Framework Data Provider for SQL Server)
Параметры подключения для этого поставщика данных одинаковы независимо от того, является ли сервер SQL Server источником или назначением. The connection options for this data provider are the same whether SQL Server is your source or your destination. Таким образом, на страницах Выбор источника данных и Выбор назначения мастера отображаются одинаковые параметры. That is, the options you see are the same on both the Choose a Data Source and the Choose a Destination pages of the wizard.
Источник данных Data Source
Введите имя или IP-адрес исходного или конечного сервера либо выберите сервер в раскрывающемся списке. Enter the name or IP address of the source or destination server, or select a server from the drop-down list.
Чтобы указать нестандартный TCP-порт, введите запятую после имени или IP-адреса сервера, а затем введите номер порта. To specify a non-standard TCP port, enter a comma after the server name or IP address, then enter the port number.
Исходный каталог Initial Catalog
Введите имя исходной или конечной базы данных либо выберите базу данных в раскрывающемся списке. Enter the name of the source or destination database, or select a database from the drop-down list.
Встроенные функции безопасности Integrated Security
Выберите значение True, чтобы использовать встроенную проверку подлинности Windows (рекомендуется), или False для подключения с использованием проверки подлинности SQL Server SQL Server . Specify True to connect with Windows integrated authentication (recommended), or False to connect with SQL Server SQL Server authentication. При выборе Falseнеобходимо ввести идентификатор пользователя и пароль. If you specify False, you must enter a user ID and password. Значение по умолчанию равно False. The default value is False.
Идентификатор пользователя User ID
При использовании проверки подлинности SQL Server SQL Server введите имя пользователя. Enter a user name if you’re using SQL Server SQL Server authentication.
Пароль Password
При использовании проверки подлинности SQL Server SQL Server введите пароль. Enter the password if you’re using SQL Server SQL Server authentication.
Подключение к SQL Server с помощью драйвера ODBC для SQL Server Connect to SQL Server with the ODBC driver for SQL Server
Драйверы ODBC не приводятся в раскрывающемся списке источников данных. ODBC drivers aren’t listed in the drop-down list of data sources. Чтобы подключиться с помощью драйвера ODBC, сначала выберите поставщик данных .NET Framework для ODBC в качестве источника данных. To connect with an ODBC driver, start by selecting the .NET Framework Data Provider for ODBC as the data source. Этот поставщик служит оболочкой для драйвера ODBC. This provider acts as a wrapper around the ODBC driver.
Получите последнюю версию драйвера. Get the latest driver. Скачайте Microsoft ODBC Driver for SQL Server. Download the Microsoft ODBC Driver for SQL Server.
Ниже показан экран, который появляется сразу после выбора поставщика данных .NET Framework для ODBC. Here’s the generic screen that you see immediately after selecting the .NET Framework Data Provider for ODBC.
Указываемые параметры (драйвер ODBC для SQL Server) Options to specify (ODBC driver for SQL Server)
Параметры подключения для этого драйвера ODBC одинаковы независимо от того, является ли сервер SQL Server источником или назначением. The connection options for the ODBC driver are the same whether SQL Server is your source or your destination. Таким образом, на страницах Выбор источника данных и Выбор назначения мастера отображаются одинаковые параметры. That is, the options you see are the same on both the Choose a Data Source and the Choose a Destination pages of the wizard.
Чтобы подключиться к SQL Server с помощью последней версии драйвера ODBC, постройте строку подключения, используя указанные ниже параметры и их значения. To connect to SQL Server with the latest ODBC driver, assemble a connection string that includes the following settings and their values. Полный формат строки подключения приведен после списка параметров. The format of a complete connection string immediately follows the list of settings.
Вы можете получить помощь в построении строки подключения. Get help assembling a connection string that’s just right. Кроме того, вместо указания строки подключения вы можете предоставить существующее имя DSN (имя источника данных) или создать новое. Or, instead of providing a connection string, provide an existing DSN (data source name) or create a new one. Дополнительные сведения об этих возможностях см. в разделе Подключение к источнику данных ODBC. For more info about these options, see Connect to an ODBC Data Source.
Драйвер Driver
Имя драйвера ODBC. The name of the ODBC driver. Для разных версий драйвера имена различаются. The name is different for different versions of the driver.
Server Server
Имя сервера SQL Server. The name of the SQL Server.
База данных Database
Имя базы данных. The name of the database.
Trusted_Connection либо Uid и Pwd Trusted_Connection; or, Uid and Pwd
Укажите параметр Trusted_Connection=Yes для подключения с использованием встроенной проверки подлинности Windows либо укажите Uid (идентификатор пользователя) и Pwd (пароль) для подключения с использованием проверки подлинности SQL Server. Specify Trusted_Connection=Yes to connect with Windows integrated authentication; or, specify Uid (user id) and Pwd (password) to connect with SQL Server authentication.
Формат строки подключения Connection string format
Ниже приведен формат строки подключения с использованием встроенной проверки подлинности Windows. Here’s the format of a connection string that uses Windows integrated authentication.
Driver=
Ниже приведен формат строки подключения с использованием проверки подлинности SQL Server вместо встроенной проверки подлинности Windows. Here’s the format of a connection string that uses SQL Server authentication instead of Windows integrated authentication.
Ввод строки подключения Enter the connection string
Введите строку подключения в поле ConnectionString либо введите имя DSN в поле Dsn на странице Выбор источника данных или Выбор назначения. Enter the connection string in the ConnectionString field, or enter the DSN name in the Dsn field, on the Choose a Data Source or Choose a Destination page. После того как вы введете строку подключения, мастер проанализирует ее и отобразит отдельные свойства и их значения в списке. After you enter the connection string, the wizard parses the string and displays the individual properties and their values in the list.
В приведенном ниже примере используется следующая строка подключения: The following example uses this connection string.
Ниже показан экран, который появляется после ввода строки подключения. Here’s the screen that you see after entering the connection string.
Подключение к SQL Server с помощью поставщика OLE DB для SQL Server (Майкрософт) или SQL Server Native Client Connect to SQL Server with the Microsoft OLE DB Provider for SQL Server or SQL Server Native Client
Поставщик OLE DB для SQL Server (Майкрософт) и клиент SQL Server Native Client не поддерживаются в версиях SQL Server после SQL Server 2012. The Microsoft OLE DB Provider for SQL Server and SQL Server Native Client are not supported in versions of SQL Server after SQL Server 2012. Используйте вместо этого драйвер ODBC. Use the ODBC driver instead. Дополнительные сведения о переходе на драйвер ODBC см. в следующих записях блога: To learn more about the transition to the ODBC driver, see the following blog posts.
Другие поставщики данных и дополнительные сведения Other data providers and more info
Сведения о подключении к SQL Server с помощью поставщика данных, который не указан в этой статье, см. на странице Строки подключения к SQL Server. For info about how to connect to SQL Server with a data provider that’s not listed here, see SQL Server connection strings. Этот сторонний сайт также содержит дополнительные сведения о поставщиках данных и параметрах подключения, описанных на этой странице. This third-party site also contains more info about the data providers and the connection parameters described on this page.