OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "windows.h" | 8 #include "windows.h" |
9 #include "win_dbghelp.h" | 9 #include "win_dbghelp.h" |
10 #include <process.h> | 10 #include <process.h> |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 * This function expects the .pdb file to be in the same directory. | 202 * This function expects the .pdb file to be in the same directory. |
203 */ | 203 */ |
204 void setUpDebuggingFromArgs(const char* vargs0) { | 204 void setUpDebuggingFromArgs(const char* vargs0) { |
205 size_t i = strlen(vargs0); | 205 size_t i = strlen(vargs0); |
206 | 206 |
207 if (i >= 4 && _stricmp(vargs0 - 4, ".exe") == 0) { | 207 if (i >= 4 && _stricmp(vargs0 - 4, ".exe") == 0) { |
208 // Ignore .exe | 208 // Ignore .exe |
209 i -= 4; | 209 i -= 4; |
210 } | 210 } |
211 | 211 |
212 int pos_period = i; | 212 size_t pos_period = i; |
213 | 213 |
214 // Find last \ in path - this is Windows! | 214 // Find last \ in path - this is Windows! |
215 while (i >= 0 && vargs0[i] != '\\') { | 215 while (i >= 0 && vargs0[i] != '\\') { |
216 i--; | 216 i--; |
217 } | 217 } |
218 | 218 |
219 int pos_last_slash = i; | 219 size_t pos_last_slash = i; |
220 | 220 |
221 char app_name[MAX_PATH]; | 221 char app_name[MAX_PATH]; |
222 strncpy(app_name, vargs0 + pos_last_slash + 1, pos_period - pos_last_slash -
1); | 222 strncpy(app_name, vargs0 + pos_last_slash + 1, pos_period - pos_last_slash -
1); |
223 app_name[pos_period - pos_last_slash] = '\0'; | 223 app_name[pos_period - pos_last_slash] = '\0'; |
224 setAppName(app_name); | 224 setAppName(app_name); |
225 | 225 |
226 char binaries_path[MAX_PATH]; | 226 char binaries_path[MAX_PATH]; |
227 strncpy(binaries_path, vargs0, pos_last_slash); | 227 strncpy(binaries_path, vargs0, pos_last_slash); |
228 binaries_path[pos_last_slash] = '\0'; | 228 binaries_path[pos_last_slash] = '\0'; |
229 setBinariesPath(binaries_path); | 229 setBinariesPath(binaries_path); |
230 | 230 |
231 setAppVersion("1.0"); // Dummy for now, but use revision instead if we use | 231 setAppVersion("1.0"); // Dummy for now, but use revision instead if we use |
232 // the minidump for anything else other than | 232 // the minidump for anything else other than |
233 // collecting the callstack. | 233 // collecting the callstack. |
234 | 234 |
235 // cdb.exe is the app used to load the minidump which prints the callstack. | 235 // cdb.exe is the app used to load the minidump which prints the callstack. |
236 char cdbExePath[MAX_PATH]; | 236 char cdbExePath[MAX_PATH]; |
237 #ifdef _WIN64 | 237 #ifdef _WIN64 |
238 sprintf(cdbExePath, "%s\\x64\\cdb.exe", SK_CDB_PATH); | 238 sprintf(cdbExePath, "%s\\x64\\cdb.exe", SK_CDB_PATH); |
239 #else | 239 #else |
240 sprintf(cdbExePath, "%s\\cdb.exe", SK_CDB_PATH); | 240 sprintf(cdbExePath, "%s\\cdb.exe", SK_CDB_PATH); |
241 #endif | 241 #endif |
242 setCdbPath(cdbExePath); | 242 setCdbPath(cdbExePath); |
243 } | 243 } |
OLD | NEW |