Setting up Debugging USD code in CLion on macOS

I’m trying to set up local debugging of USD and I’m able to get the project and many targets to build however at runtime my plugInfo.json’s are not in the right place.

When building with the build_usd.py script locally I get the ‘normal’ output directory structure with a lib folder containing all the libraries and within that all the USD project folders with a resources folder and a plugInfo.json inside. However when loading the CMake project from within CLion, the lib folder is never created, and the resources folders are not either. The plugInfo files exist within the cmake-build-debug folder however their relative paths are wrong.

My current setup is described here .

It’s not necessary for me to use CLion to do this, so if there are easier setup steps someone has to step through USD code, I would appreciate hearing how you’re set up.

Andy

To help debug this issue, be sure to set this envvar:

TFDEBUG=PLUG_INFO_SEARCH

This will output helpful diagnostics that will probably highlight the problem immediately. (You’ll be able to see if the path you need is there or not.)

PXR_PLUGINPATH_NAME=whatever

will be the next envvar for you to set, because that’s how you can tell OpenUSD, from within your IDE, where to load the plugins from.

Getting specifically a debug build to work might be tricky with custom (or target-named) build folders. So maybe start with a RelWithDebInfo target (hopefully it doesn’t append a suffix? I’m not seeing a suffix in my build folders, but I’m not using CLion). I think it’s helpful to avoid having to solve all of the problems at once :slight_smile:

1 Like

I’m using CLion too. What I usually do is that I run the build_usd.py with the verbose option -v to get the cmake options and use them in my IDE.

One other thing that you might be missing is the install step. I think that is the one that correctly puts the plugin resources corresponding with the library structure

1 Like

Thanks @kohakukun & @nporcino , this helped me get closer i think. It seems now my libs are building in two locations. this causes issues here since i end up registering Tf_Debug symbols multiple times. I can hack around this a little by commenting out some areas of code but it eventually will die because having two different versions of the libraries in the path eventually just doesn’t work.

In my case the paths that libraries get built to are:

  • <build_dir>/pxr/**/xx.dylib
  • <build_dir>/lib/xx.dylib

so initially I get logs of something like:

TfRegistryManager: Library <build_dir>/pxr/usd/usd/libusd_usd.dylib
TfRegistryManager: running 1 functions for TfDebug
pxrInternal_v0_24__pxrReserved__::Tf_DebugSymbolRegistry::_Register: USD_AUTO_APPLY_API_SCHEMAS

then later after i’m already inside of usdcat something similar, this time from the different location

Loading plugin 'usd'.
TfDlopen: [opening] '<build_dir>/lib/libusd_usd.dylib' (flag=2)...
TfRegistryManager: Library <build_dir>/lib/libusd_usd.dylib
TfRegistryManager: running 1 functions for TfDebug
pxrInternal_v0_24__pxrReserved__::Tf_DebugSymbolRegistry::_Register: USD_AUTO_APPLY_API_SCHEMAS

This gets me closer to doing what I really want to do, which is to step through usdcat but it seems with these duplicated libraries, when i try to step into where the usdc file format code actually does it’s work, it breaks and doesn’t know where to go.

here are my current settings for my debug build in CLion, maybe something here is obviously wrong.

It seems I’m set up completely wrong, or that I’m fighting mac based things that make it harder than it needs to be? Maybe rather than digging into my current problems, would anyone be willing to post some ‘hello world’ example of how they are stepping through code? Would the generic advice here be more of :

  1. Getting off of macOS
  2. Learning more about CMake
  3. Learning more about CLion
  4. Getting off of CLion and learning gdb / lldb
  5. Something else?

Apologies as I know these types of issues are pretty individual, but I’ve been stuck on this for far too long and if there is some ‘standard’ way to do this, that would be very helpful. (totally happy to switch OS / tools / anything)

This is the build location, you shouldn’t be referencing it at all. Think of it as a staging area.

<build_dir>/pxr/usd/usd/libusd_usd.dylib

This is the install location: <build_dir>/lib/libusd_usd.dylib

That’s the one that should be in your paths. When you build in your IDE (it doesn’t matter if it is CLion or Xcode or whatever), you need to build the install target to actually get everything staged to the right place.

Then, when you run, you have to coerce the IDE to run usdcat from the install location, not from the build location. You may have to do more work to tell clion/lldb where the symbol database is, but I’m not sure, as i don’t use CLion (I use the command line or xcode depending on the type of debugging I am doing.)

2 Likes

you have to coerce the IDE to run usdcat from the install location, not from the build location.

Thanks @nporcino, this was a huge part of this. and now it’s working! Appreciate the help so much :slight_smile:

Updated / Documented my steps for getting this to work here. If anyone finds this in the future and it doesn’t work for them or if anyone cares to try my steps, I’d like to keep them up to date.

1 Like