Skip to content

Commit b5d0ec4

Browse files
Vincent Couverttkrasnukha
authored andcommitted
Fix issue #53: wrong file path returned under Windows when reaching a breakpoint.
1 parent 7ba4d48 commit b5d0ec4

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/MICmnLLDBDebugSessionInfo.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
#include "MICmnResources.h"
2929
#include "Platform.h"
3030

31+
// Paths separators
32+
#ifdef _WIN32
33+
#define PATH_SEPARATOR "\\"
34+
#else
35+
#define PATH_SEPARATOR "/"
36+
#endif // _WIN32
37+
#define RETURNED_PATH_SEPARATOR "/"
38+
3139
//++
3240
// Details: CMICmnLLDBDebugSessionInfo constructor.
3341
// Type: Method.
@@ -283,21 +291,31 @@ bool CMICmnLLDBDebugSessionInfo::ResolvePath(const CMIUtilString &vstrUnknown,
283291
bool bOk = MIstatus::success;
284292

285293
CMIUtilString::VecString_t vecPathFolders;
286-
const MIuint nSplits = vwrResolvedPath.Split("/", vecPathFolders);
294+
const MIuint nSplits = vwrResolvedPath.Split(PATH_SEPARATOR, vecPathFolders);
287295
MIunused(nSplits);
288296
MIuint nFoldersBack = 1; // 1 is just the file (last element of vector)
297+
CMIUtilString strTestPath;
289298
while (bOk && (vecPathFolders.size() >= nFoldersBack)) {
290-
CMIUtilString strTestPath;
291299
MIuint nFoldersToAdd = nFoldersBack;
300+
strTestPath = "";
292301
while (nFoldersToAdd > 0) {
293-
strTestPath += "/";
302+
strTestPath += RETURNED_PATH_SEPARATOR;
294303
strTestPath += vecPathFolders[vecPathFolders.size() - nFoldersToAdd];
295304
nFoldersToAdd--;
296305
}
297306
bool bYesAccessible = false;
298307
bOk = AccessPath(strTestPath, bYesAccessible);
299308
if (bYesAccessible) {
300-
vwrResolvedPath = strTestPath;
309+
#ifdef _WIN32
310+
if (nFoldersBack == (vecPathFolders.size() - 1)) {
311+
// First folder is probably a Windows drive letter ==> must be returned
312+
vwrResolvedPath = vecPathFolders[0] + strTestPath;
313+
} else {
314+
#endif
315+
vwrResolvedPath = strTestPath;
316+
#ifdef _WIN32
317+
}
318+
#endif
301319
return MIstatus::success;
302320
} else
303321
nFoldersBack++;
@@ -306,6 +324,11 @@ bool CMICmnLLDBDebugSessionInfo::ResolvePath(const CMIUtilString &vstrUnknown,
306324
// No files exist in the union of working directory and debuginfo path
307325
// Simply use the debuginfo path and let the IDE handle it.
308326

327+
#ifdef _WIN32 // Under Windows we must returned vwrResolvedPath to replace "\\"
328+
// by "/"
329+
vwrResolvedPath = strTestPath;
330+
#endif
331+
309332
return bOk;
310333
}
311334

0 commit comments

Comments
 (0)