Name Date Size #Lines LOC

..26-Sep-2023-

chrome/H26-Sep-2023-5,7054,325

detail/H26-Sep-2023-413235

docs/H26-Sep-2023-4836

.clang-formatH A D26-Sep-20232.5 KiB8887

ABI49_0_0AsyncPauseState.hH A D26-Sep-20231,008 3512

ABI49_0_0Exceptions.hH A D26-Sep-20231.7 KiB6142

ABI49_0_0Inspector.cppH A D26-Sep-202324.3 KiB745537

ABI49_0_0Inspector.hH A D26-Sep-202313.4 KiB389181

ABI49_0_0InspectorState.cppH A D26-Sep-202316.3 KiB512335

ABI49_0_0InspectorState.hH A D26-Sep-202312.4 KiB413245

ABI49_0_0RuntimeAdapter.cppH A D26-Sep-2023741 3116

ABI49_0_0RuntimeAdapter.hH A D26-Sep-20232.3 KiB7734

BUCKH A D26-Sep-20236.3 KiB235223

CMakeLists.txtH A D26-Sep-20231,006 4134

DEFS.bzlH A D26-Sep-2023377 86

README.mdH A D26-Sep-20233.7 KiB11482

README.md

1hermes-inspector provides a bridge between the low-level debugging API exposed
2by Hermes and higher-level debugging protocols such as the Chrome DevTools
3protocol.
4
5# Targets
6
7 - chrome: classes that implement the Chrome DevTools Protocol adapter. Sits on
8   top of classes provided by the inspector target.
9 - detail: utility classes and functions
10 - inspector: protocol-independent classes that sit on top of the low-level
11   Hermes debugging API.
12
13# Testing
14
15Tests are implemented using gtest. Debug logging is enabled for tests, and you
16can get debug logs to show even when tests are passing by running the test
17executable directly:
18
19```
20$ buck build //xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector:chrome-tests
21$ buck-out/gen/xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector/chrome-tests
22[...]
23```
24
25You can use standard gtest filters to only execute a particular set of tests:
26
27```
28$ buck-out/gen/xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector/chrome-tests \
29    --gtest_filter='ConnectionTests.testSetBreakpoint'
30```
31
32You can debug the tests using lldb or gdb:
33
34```
35$ lldb buck-out/gen/xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector/chrome-tests
36$ gdb buck-out/gen/xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector/chrome-tests
37```
38
39# Formatting
40
41Make sure the code is formatted using the hermes clang-format rules before
42committing:
43
44```
45$ xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector/tools/format
46```
47
48We follow the clang format rules used by the rest of the Hermes project.
49
50# Adding Support For New Message Types
51
52To add support for a new Chrome DevTools protocol message, add the message you
53want to add to tools/message_types.txt, and re-run the message types generator:
54
55```
56$ xplat/js/react-native-github/packages/react-native/ReactCommon/hermes/inspector/tools/run_msggen
57```
58
59This will generate C++ structs for the new message type in
60`chrome/MessageTypes.{h,cpp}`.
61
62You'll then need to:
63
641. Implement a message handler for the new message type in `chrome::Connection`.
652. Implement a public API for the new message type in `Inspector`. This will
66   most likely return a `folly::Future` that the message handler in (1) can use
67   for chaining.
683. Implement a private API for the new message type in `Inspector` that performs
69   the logic in Inspector's executor. (Inspector.cpp contains a comment
70   explaining why the executor is necessary.)
714. Optionally, implement a method for the new message type in `InspectorState`.
72   In most cases this is probably not necessary--one of the existing methods in
73   `InspectorState` will work.
74
75For a diff that illustrates these steps, take a look at D6601459.
76
77# Testing Integration With Nuclide and Apps
78
79For now, the quickest way to use hermes-inspector in an app is with Eats. First,
80make sure the packager is running:
81
82```
83$ js1 run
84```
85
86Then, on Android, build the fbeats target:
87
88```
89$ buck install --run fbeats
90```
91
92On iOS, build the `//Apps/Internal/Eats:Eats` target:
93
94```
95$ buck install --run //Apps/Internal/Eats:Eats
96```
97
98You can also build `Eats` in Xcode using `arc focus` if you prefer an
99IDE:
100
101```
102$ arc focus --force-build \
103    -b //Apps/Internal/Eats:Eats \
104    cxxreact //xplat/hermes/API:HermesAPI //xplat/hermes/lib/VM:VM jsi \
105    jsinspector hermes-inspector FBReactKit FBReactModule FBCatalystWrapper \
106    //xplat/js:React //xplat/js/react-native-github:ReactInternal
107```
108
109For all the above commands, if you want to build the inspector `-O0` for better
110debug info, add the argument `--config hermes.build_mode=dbg`.
111
112You should then be able to launch the app and see it listed in the list of
113Mobile JS contexts in the Nuclide debugger.
114