Skip to content

json pretty printer causes python exceptions on non-json types #3919

Closed
@Finkman

Description

@Finkman

Description

I am using version 3.11.2 and added the pretty printer to my gdb with

source ${workspaceFolder}/libs/json/tools/gdb_pretty_printer/nlohmann-json.py

When debugging, inspecting json values is working fine.
Inspecting the value of a pointer or anything that is not json pops an error on the gdb console

Reproduction steps

  • Use python 3.6.10
  • Use gdb 12.1 with python support
  • add source your/path/to/json/tools/gdb_pretty_printer/nlohmann-json.py to ~/.gdbinit
  • Stop at a break point while debugging
  • Inspect a value like: -exec p -pretty on -- this
    • In that case, I let it stop within an instance of a class and would like to know the address of it.

Expected vs. actual results

Gdb pops an error on the screen. While I am using VSCode, this stops the pretty-printed values of the variable of being visible.

grafik

Minimal code example

No response

Error messages

Output of -exec p -pretty on -- this

Python Exception <class 'TypeError'>: expected string or bytes-like object
Python Exception <class 'TypeError'>: expected string or bytes-like object
$2 = (DemoPlugin * const) 0x5555555da2f0


### Compiler and operating system

Ubuntu 22.04, gdb 12.1, python 3.6.10, gnu gcc 11

### Library version

3.11.2

### Validation

- [X] The bug also occurs if the latest version from the [`develop`](https://github.com/nlohmann/json/tree/develop) branch is used.
- [X] I can successfully [compile and run the unit tests](https://github.com/nlohmann/json#execute-unit-tests).

Metadata

Metadata

Assignees

Labels

kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmation

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions