Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV matrix inside std::vector is not displayed in LLDB #216

Open
wl2776 opened this issue Feb 11, 2024 · 3 comments
Open

OpenCV matrix inside std::vector is not displayed in LLDB #216

wl2776 opened this issue Feb 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@wl2776
Copy link
Contributor

wl2776 commented Feb 11, 2024

Environment

  • OID version (commit or tag): head of main branch (b151cd9)
  • OS and Version: MacOS Sonoma 14.2.1, Ubuntu 22.04
  • Debugger and versions:
    lldb: 17.0.6 on MacOS, 14.0.0 on Ubuntu.
  • Python version: 3.11.7 on MacOS, 3.10.12 on Ubuntu

Describe the bug

OpenCV matrices, stored in STL containers like std::vector or std::map, are not displayed.

To Reproduce

Same setup as in #215. Compile sample project, run it in LLDB and try to inspect variables, storing OpenCV matrices.

  1. Clone and build sample project
    git clone https://github.com/wl2776/oid_debug_sample
    cd oid_debug_sample
    conan install . -b missing -s \&:build_type=Debug -s build_type=Release -of build
    cd build
    cmake .. --preset conan-debug
    make -j
    
  2. lldb sample
  3. breakpoint set -l 18 -s sample.cpp
  4. run
  5. When debugger stops on the breakpoint, switch to OID window and try to display mh.v[0]

Expected behavior

Matrix is shown

Actual behavior

Matrix is not displayed

Error messages/stack traces

None.

Additional context

I've added call to print inside the method Mat.is_symbol_observable (file resources/oidscripts/oidtypes/opencv.py)

It shows that type of variable mh.v[0] is std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >::value_type.

Currently this method tries to match this type with regex, requiring that type name ends with cv::Mat.

@wl2776 wl2776 added the bug Something isn't working label Feb 11, 2024
@wl2776
Copy link
Contributor Author

wl2776 commented Feb 11, 2024

I've tried to fix this issue by playing with GetType, GetCanonicalType, etc, but currently no luck.
Although I've managed to get it working with std::vector, my solution doesn't work with other STL containers (maps, lists).

I think, it is better to check if a symbol includes required data members (flags, data, datastart, dataend, ... ) and by checking value of flags (I remember that it should contain a kind of magic signatures that we can use to make sure that we have OpenCV matrix).

@brunoalr
Copy link
Member

Thanks once more! :D I will also try to take a look at it when I have time. Or maybe ping @csantosbh...

@wl2776
Copy link
Contributor Author

wl2776 commented Feb 13, 2024

value of flags (I remember that it should contain a kind of magic signatures that we can use to make sure that we have OpenCV matrix).

Indeed. https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#af9333f06c84f115fda4cdf3af18c2ad0

enum  	{
  MAGIC_VAL = 0x42FF0000,
  AUTO_STEP  = 0,
  CONTINUOUS_FLAG  = CV_MAT_CONT_FLAG,
  SUBMATRIX_FLAG = CV_SUBMAT_FLAG
}
 
enum  	{
  MAGIC_MASK = 0xFFFF0000,
  TYPE_MASK = 0x00000FFF,
  DEPTH_MASK = 7
}

wl2776 added a commit to wl2776/OpenImageDebugger that referenced this issue Feb 14, 2024
wl2776 added a commit to wl2776/OpenImageDebugger that referenced this issue Mar 3, 2024
wl2776 added a commit to wl2776/OpenImageDebugger that referenced this issue Mar 3, 2024
add `has_symbol` method to SymbolWrapper
check cv::Mat fields
wl2776 added a commit to wl2776/OpenImageDebugger that referenced this issue Mar 20, 2024
add `has_symbol` method to SymbolWrapper
check cv::Mat fields
wl2776 added a commit to wl2776/OpenImageDebugger that referenced this issue Apr 4, 2024
add `has_symbol` method to SymbolWrapper
check cv::Mat fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants