Skip to content

Commit e8d5fda

Browse files
authored
Add logs of breakpoint URI setup (#8706)
This is relevant for debugging #7336. I'm trying to log some points in breakpoint handling to see how paths are working.
1 parent d2009be commit e8d5fda

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/io/flutter/run/FlutterPositionMapper.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.jetbrains.lang.dart.util.DartUrlResolver;
2323
import io.flutter.dart.DartPlugin;
2424
import io.flutter.logging.PluginLogger;
25+
import io.flutter.settings.FlutterSettings;
2526
import io.flutter.utils.OpenApiUtils;
2627
import io.flutter.vmService.DartVmServiceDebugProcess;
2728
import org.dartlang.vm.service.element.LibraryRef;
@@ -140,7 +141,15 @@ public void onLibrariesDownloaded(@NotNull final Iterable<LibraryRef> libraries)
140141
if (remoteUri.startsWith(DartUrlResolver.DART_PREFIX)) continue;
141142
if (remoteUri.startsWith(DartUrlResolver.PACKAGE_PREFIX)) continue;
142143
remoteSourceRoot = findRemoteSourceRoot(remoteUri);
143-
if (remoteSourceRoot != null) return;
144+
if (remoteSourceRoot != null) {
145+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
146+
LOG.info("Calculated remoteSourceRoot: " + remoteSourceRoot + " from " + remoteUri);
147+
}
148+
return;
149+
}
150+
}
151+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
152+
LOG.info("Could not calculate remoteSourceRoot");
144153
}
145154
}
146155

@@ -189,6 +198,9 @@ private String findRemoteSourceRoot(String remotePath) {
189198
public Collection<String> getBreakpointUris(@NotNull final VirtualFile file) {
190199
final Set<String> results = new HashSet<>();
191200
final String uriByIde = resolver.getDartUrlForFile(file);
201+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
202+
LOG.info("getBreakpointUris: uriByIde=" + uriByIde + " for file=" + file.getPath());
203+
}
192204

193205
// If dart:, short circuit the results.
194206
if (uriByIde.startsWith(DartUrlResolver.DART_PREFIX)) {
@@ -211,6 +223,9 @@ public Collection<String> getBreakpointUris(@NotNull final VirtualFile file) {
211223
if (uriByServer != null) {
212224
results.add(uriByServer);
213225
}
226+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
227+
LOG.info("getBreakpointUris: uriByServer=" + uriByServer);
228+
}
214229
}
215230

216231
final String path = file.getPath();
@@ -228,6 +243,9 @@ public Collection<String> getBreakpointUris(@NotNull final VirtualFile file) {
228243
}
229244
}
230245

246+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
247+
LOG.info("getBreakpointUris for " + file.getPath() + ": " + results);
248+
}
231249
return results;
232250
}
233251

@@ -285,7 +303,13 @@ String getRemoteSourceRoot() {
285303

286304
@Nullable
287305
protected VirtualFile findLocalFile(@NotNull String uri) {
288-
return findLocalFile(uri, null);
306+
final VirtualFile file = findLocalFile(uri, null);
307+
if (file == null) {
308+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
309+
LOG.info("findLocalFile: could not find local file for " + uri);
310+
}
311+
}
312+
return file;
289313
}
290314

291315
/**

src/io/flutter/vmService/DartVmServiceBreakpointHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
1919
import com.jetbrains.lang.dart.ide.runner.DartLineBreakpointType;
2020
import org.dartlang.vm.service.element.Breakpoint;
21+
import com.intellij.openapi.diagnostic.Logger;
22+
import io.flutter.logging.PluginLogger;
23+
import io.flutter.settings.FlutterSettings;
2124
import org.jetbrains.annotations.NotNull;
2225

2326
import java.util.*;
2427

2528
import static com.intellij.icons.AllIcons.Debugger.Db_invalid_breakpoint;
2629

2730
public class DartVmServiceBreakpointHandler extends XBreakpointHandler<XLineBreakpoint<XBreakpointProperties>> {
31+
private static final Logger LOG = PluginLogger.createLogger(DartVmServiceBreakpointHandler.class);
2832

2933
private final DartVmServiceDebugProcess myDebugProcess;
3034
private final Set<XLineBreakpoint<XBreakpointProperties>> myXBreakpoints = new HashSet<>();
@@ -102,6 +106,11 @@ public void breakpointResolved(@NotNull final Breakpoint vmBreakpoint) {
102106
// This can be null when the breakpoint has been set by another debugger client.
103107
if (xBreakpoint != null) {
104108
myDebugProcess.getSession().updateBreakpointPresentation(xBreakpoint, null, null);
109+
} else {
110+
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
111+
LOG.info("breakpointResolved: could not find XLineBreakpoint for vmBreakpointId=" + vmBreakpoint.getId() + " "
112+
+ vmBreakpoint.getLocation());
113+
}
105114
}
106115
}
107116

0 commit comments

Comments
 (0)