简体   繁体   English

如何有效使用dartium和其他工具来读取/调试客户端dart库?

[英]How to use dartium and other tools effectively to read / debug client side dart library?

Motivation 动机

Reading / understanding dart library to override / extend classes in dart-sdk. 阅读/理解dart库以覆盖/扩展dart-sdk中的类。

barriers I see 我看到的障碍

  • Dynamic method calls 动态方法调用
    Eg 例如

    appendChild_Callback_1_(mthis, __arg_0) => Blink_JsNative_DomException.callMethod(mthis, "appendChild",[__arg_0]); appendChild_Callback_1_(mthis,__arg_0)=> Blink_JsNative_DomException.callMethod(mthis,“ appendChild”,[__ arg_0]);

    Debugger is useful. 调试器很有用。 With async code, however, I imagine it could be hundreds of micro tasks loop later. 但是,使用异步代码,我想以后可能会有数百个微任务循环。 Watch point or breakpoint based on a scope or function name possible? 基于作用域或函数名称的观察点或断点可能吗?
    Or someone working on it? 还是有人在工作? Or searching files with regex the only way? 还是用正则表达式搜索文件的唯一方法?

  • Javascript or native code Javascript或本机代码
    Some part of dart depends on javascript or what looks like compile C and there I see an impenetorable wall: dart的某些部分取决于javascript或看起来像编译C的东西,在那儿我看到了一块坚不可摧的墙:
    Eg 例如

    _callMethod(String name, List args) native "JsObject_callMethod"; _callMethod(字符串名称,列表参数)原生“ JsObject_callMethod”;

    Dartium's debugger won't go deeper. Dartium的调试器不会更深入。

What was I doing 我在做什么

I wanted to see how an HtmlElement's parent value is set when the element gets appended to another element. 我想看看当元素附加到另一个元素时如何设置HtmlElement的父值。 For optimization purpose, I guess it's handled by the browser side compiled C. 出于优化目的,我认为它是由浏览器端编译的C处理的。

The questions 问题

  • Techniques 技术
    Is there a better way than adding if("appendChild") == mthis) debugger(); 有没有比添加if("appendChild") == mthis) debugger();更好的方法了if("appendChild") == mthis) debugger(); to the library? 去图书馆?
  • what tools are available other than what's in dartium? 除了dartium中可用的工具以外,还有哪些可用的工具?
    Where can I find resources and tips if I wanted to dig deeper? 如果我想更深入地学习,可以在哪里找到资源和提示?
  • When to give up? 什么时候放弃?
    How can I get a general idea about what sort of things require diving into chromium source code? 我如何大致了解需要深入研究铬源代码的东西? Or just have to try and see? 还是只需要尝试看看?

Breakpoints are somewhat limited, but when you see that callMethod(mthis, "appendChild", ...) in the _blink library that is precisely calling the JavaScript method appendChild with receiver mthis . 断点有所限制,但是当您看到_blink库中的callMethod(mthis, "appendChild", ...)恰好以接收者mthis调用JavaScript方法appendChild时。 And you'll see wrap_jso and unwrap_jso calls around it, which are removing or adding Dart wrappers to the underlying JavaScript objects. 并且您将看到关于它的wrap_jso和unwrap_jso调用,这些调用正在将Dart包装器添加或添加到基础JavaScript对象。 Since 1.14, (almost?) all the HTML calls in Dartium are done via JS Interop. 从1.14开始,(几乎?)Dartium中的所有HTML调用都是通过JS Interop完成的。

If you really want to know what the C code is doing in between, look for js_dartium.dart in the SDK checkout. 如果您真的想知道C代码在这之间的作用,请在SDK签出中查找js_dartium.dart。 But for most purposes it's enough to know that it's doing what it says and calling the JS. 但是对于大多数目的来说,足以知道它正在执行所声明的操作并调用JS。 You can also set a breakpoint on the JS side in devtools and get through that way. 您还可以在devtools的JS端设置一个断点,并通过这种方式来解决。

For techniques - you can set a breakpoint in the blink library or in html, but there aren't any meta-breakpoint facilities. 对于技术-您可以在眨眼库或html中设置断点,但是没有任何元断点功能。 You can also look at the non-minified dart2js output to see what's really going on, as it should be pretty similar. 您还可以查看未缩小的dart2js输出,以了解实际情况,因为它应该非常相似。 There aren't a lot of tools or resources available other than running Dartium or looking at the sources. 除了运行Dartium或查看源代码外,没有太多可用的工具或资源。 sdk/tools/dom . sdk/tools/dom Most of html_dartium and all of _blink is generated using Python Scripts from the Chrome IDL files. 大部分html_dartium和所有_blink都是使用Chrome IDL文件中的Python脚本生成的。

To answer your original question - I'm pretty sure it's getting set in browser C code, called from JavaScript. 要回答您的原始问题-我很确定它已经在从JavaScript调用的浏览器C代码中设置了。 Dart has nothing to do with it. Dart与它无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM