debugger usage on macOS

36 views
Skip to first unread message

John Davis

unread,
Jul 9, 2024, 12:02:42 PMJul 9
to v8-users
Hello

I'm building v8 on macOS with debugging symbols.  (`gn gen ... is_debug=true`)  I see the compile command line to include -g2 -dwarf-aranges, -D_DEBUG, -DDEBUG.  I've compared the `nm` and `nm -a` output with and without debug switch.  

```
$ ls -lh out/arm64.release/d8
 543K Jul  2 15:37 out/arm64.release/d8*
$ ls -lh out/arm64.debug/d8
 679K Jul  3 12:32 out/arm64.debug/d8*
$ nm -a out/arm64.release/libv8_libplatform.dylib | wc -l
     938
$ nm  out/arm64.release/libv8_libplatform.dylib | wc -l
     404
$ nm -a out/arm64.debug/libv8_libplatform.dylib | wc -l
    1130
$ nm  out/arm64.debug/libv8_libplatform.dylib | wc -l
```

It appears debug symbols are present.  However, when I try to run the debugger with the CodeLLDB extension for vscode, I can not hit any breakpoints.  If I build simple C++ apps with a combined compile/link I can hit breakpoints using this method.

launch.json:
```
{
"version": "0.2.0",
"configurations": [
  {
"name": "clang++ - Debug exe",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/v8/out/arm64.debug/d8",
"args": [
"${workspaceFolder}/data/foo.js"
],
"cwd": "${workspaceFolder}/v8/out/arm64.debug",
"stopOnEntry": false,
  }
]
  }
```

Any pointers on how to debug v8 code on macOS? 

Jakob Kummerow

unread,
Jul 10, 2024, 5:22:53 AMJul 10
to v8-u...@googlegroups.com
You may be missing the v8_optimized_debug = false build flag.
Debug symbols are controlled by the symbol_level flag, which should default to 2 in debug builds, but it might help to manually set that. FWIW, on Linux I get 2640 for nm -a out/x64.debug/libv8_libplatform.so | wc -l.

I recommend using the recommended building workflow. In short, tools/dev/gm.py arm64.debug should give you reasonable default settings for debugging (if args.gn doesn't exist yet; if it does exist, it intentionally leaves it alone).


This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.

--

John Davis

unread,
Jul 10, 2024, 2:30:16 PMJul 10
to v8-users
Hello Jakob,

Many thanks.  I haven't yet read the workflow you referenced.  I will though.

Regarding the quick try of adding `v8_optimized_debug = false` to my gn gen line - that did not help.  ie.:

`gn -v gen out/arm64.debug --args='is_debug=true target_cpu="arm64" v8_target_cpu="arm64" is_component_build=true v8_optimized_debug=false'`

John Davis

unread,
Jul 11, 2024, 11:51:49 AM (13 days ago) Jul 11
to v8-users
Hello Jakob,

Here is a workflow that enables debugging in vscode on macOS/Arm using the CodeLLDB debugger:




The gn clean command removes all files and directories  except for build.ninja, build.ninja.d and args.gn

```
$ cd v8
$ gn clean out/arm64.debug
```

To ensure the `args.gn` file is present, write it like so to ensure debugging is enabled.

```
$ cat << EOF > out/arm64.debug/args.gn
is_debug=true
enable_dsyms=true
v8_optimized_debug=false

target_cpu="arm64"
v8_target_cpu="arm64"
is_component_build=true
EOF
```

Generate ninja build files.

```
$ gn -v gen out/arm64.debug
```


Spot check that it has one of our settings.  Note, this is an override from default setting of false. (I don't know how but I would like to be able to verify all settings with one command.)

```
$ gn args out/arm64.debug --list=enable_dsyms
```

Proceed with build.

```
$ ninja -v -C out/arm64.debug
```

Thanks again Jakob for pointing out the v8_optimized_debug setting.  That disabled optimization (-O0) and prompted me to find the enable_dsyms setting.
Reply all
Reply to author
Forward
0 new messages