| 1097 | #endif |
| 1098 | |
| 1099 | static void debug_start_child( int argc, const char * * argv ) |
| 1100 | { |
| 1101 | #if NT |
| 1102 | char buf[ 80 ]; |
| 1103 | HANDLE pipe1[ 2 ]; |
| 1104 | HANDLE pipe2[ 2 ]; |
| 1105 | string self[ 1 ]; |
| 1106 | string command_line[ 1 ]; |
| 1107 | SECURITY_ATTRIBUTES sa = { sizeof( SECURITY_ATTRIBUTES ), NULL, TRUE }; |
| 1108 | PROCESS_INFORMATION pi = { NULL, NULL, 0, 0 }; |
| 1109 | STARTUPINFOA si = { sizeof( STARTUPINFOA ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1110 | 0, 0, 0, 0, 0, 0 }; |
| 1111 | assert( debug_state == DEBUG_NO_CHILD ); |
| 1112 | if ( ! CreatePipe( &pipe1[ 0 ], &pipe1[ 1 ], &sa, 0 ) ) |
| 1113 | { |
| 1114 | printf("internal error: CreatePipe:1: 0x%08lx\n", GetLastError()); |
| 1115 | return; |
| 1116 | } |
| 1117 | if ( ! CreatePipe( &pipe2[ 0 ], &pipe2[ 1 ], &sa, 0 ) ) |
| 1118 | { |
| 1119 | printf("internal error: CreatePipe:2: 0x%08lx\n", GetLastError()); |
| 1120 | CloseHandle( pipe1[ 0 ] ); |
| 1121 | CloseHandle( pipe1[ 1 ] ); |
| 1122 | return; |
| 1123 | } |
| 1124 | string_new( self ); |
| 1125 | if ( ! get_module_filename( self ) ) |
| 1126 | { |
| 1127 | printf("internal error\n"); |
| 1128 | CloseHandle( pipe1[ 0 ] ); |
| 1129 | CloseHandle( pipe1[ 1 ] ); |
| 1130 | CloseHandle( pipe2[ 0 ] ); |
| 1131 | CloseHandle( pipe2[ 1 ] ); |
| 1132 | return; |
| 1133 | } |
| 1134 | string_copy( command_line, "b2 " ); |
| 1135 | /* Pass the handles as the first and second arguments. */ |
| 1136 | string_append( command_line, debugger_opt ); |
| 1137 | sprintf( buf, "%p", pipe1[ 0 ] ); |
| 1138 | string_append( command_line, buf ); |
| 1139 | string_push_back( command_line, ' ' ); |
| 1140 | string_append( command_line, debugger_opt ); |
| 1141 | sprintf( buf, "%p", pipe2[ 1 ] ); |
| 1142 | string_append( command_line, buf ); |
| 1143 | /* Pass the rest of the command line. */ |
| 1144 | { |
| 1145 | int i; |
| 1146 | for ( i = 1; i < argc; ++i ) |
| 1147 | { |
| 1148 | string_push_back( command_line, ' ' ); |
| 1149 | string_append( command_line, argv[ i ] ); |
| 1150 | } |
| 1151 | } |
| 1152 | SetHandleInformation( pipe1[ 1 ], HANDLE_FLAG_INHERIT, 0 ); |
| 1153 | SetHandleInformation( pipe2[ 0 ], HANDLE_FLAG_INHERIT, 0 ); |
| 1154 | if ( ! CreateProcessA( |
| 1155 | self->value, |
| 1156 | command_line->value, |
no test coverage detected