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

gdb-pretty-print broken since m_data added #4309

Closed
2 tasks
blackworm27 opened this issue Mar 13, 2024 · 0 comments · Fixed by #4343
Closed
2 tasks

gdb-pretty-print broken since m_data added #4309

blackworm27 opened this issue Mar 13, 2024 · 0 comments · Fixed by #4343
Labels
kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@blackworm27
Copy link

blackworm27 commented Mar 13, 2024

Description

The pretty printer Python script for gdb, located at tools/gdb_pretty_printer/nlohmann-json.py, is broken since the addition of the m_data member in the json object.
SOLUTION: The solution is to first dereference 'm_data' before dereferencing 'm_type' or 'm_value' in the three places they occur in the nlohmann-json.py script. A corrected script (renamed to .txt)
nlohmann-json.py.txt
is attached to this bug.

Reproduction steps

Following the README.md in tools/gdb_pretty_printer/README.md does not work as described. gdb reports 'Cannot instantiate printer for default visualiser' and the console says Python Exception <class 'gdb.error'>: There is no member or method named m_type. This is a regression from 3.11.2, where it does work.

Expected vs. actual results

Expected printing of json objects in gdb to work. Instead, an error message is given.

Minimal code example

nlohmann::json a;
// Attempting to pretty-print this object in gdb fails in nlohmann-json 3.11.3

Error messages

Python Exception <class 'gdb.error'>: There is no member or method named m_type.
Python Exception <class 'gdb.error'>: There is no member or method named m_type.
$1 = {
  <nlohmann::json_abi_v3_11_3::detail::json_default_base> = {<No data fields>}, 
  members of nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> >, void>:
  m_data = {
    m_type = nlohmann::json_abi_v3_11_3::detail::value_t::object,
    m_value = {
      object = 0x555555a543e0,
      array = 0x555555a543e0,
      string = 0x555555a543e0,
      binary = 0x555555a543e0,
      boolean = 224,
      number_integer = 93824997475296,
      number_unsigned = 93824997475296,
      number_float = 4.6355707973685445e-310
    }
  }
}

Compiler and operating system

Linux Ubuntu 20.04, gdb 12.1

Library version

3.11.3

Validation

@MrJia1997 MrJia1997 mentioned this issue Apr 12, 2024
4 tasks
@nlohmann nlohmann linked a pull request Apr 13, 2024 that will close this issue
4 tasks
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Apr 13, 2024
@nlohmann nlohmann added this to the Release 3.11.4 milestone Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants