]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/third_party/gdb_pretty_printer/README.md
f5f61927b0e81600da737d974ed029b4eaf96115
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / third_party / gdb_pretty_printer / README.md
1 # GDB Pretty Printer
2
3 File [nlohmann-json.py](nlohmann-json.py) contains a pretty printer for GDB for JSON values of this library. It was originally published as [Gist](https://gist.github.com/ssbssa/60da5339c6e6036b2afce17de06050ea#file-nlohmann-json-py) by [Hannes Domani](https://github.com/ssbssa).
4
5 ## How to use
6
7 - Add line
8
9 ```
10 source /path/to/nlohmann-json.py
11 ```
12
13 to `~/.gdbinit`. Note you must replace `/path/to` with whatever path you stored file `nlohmann-json.py`.
14 - In GDB, debug as usual. When you want to pretty-print a JSON value `var`, type
15
16 ```
17 p -pretty on -array on -- var
18 ```
19
20 The result should look like
21
22 ```
23 $1 = std::map with 5 elements = {
24 ["Baptiste"] = std::map with 1 element = {
25 ["first"] = "second"
26 },
27 ["Emmanuel"] = std::vector of length 3, capacity 3 = {
28 3,
29 "25",
30 0.5
31 },
32 ["Jean"] = 0.7,
33 ["Zorg"] = std::map with 8 elements = {
34 ["array"] = std::vector of length 3, capacity 3 = {
35 1,
36 0,
37 2
38 },
39 ["awesome_str"] = "bleh",
40 ["bool"] = true,
41 ["flex"] = 0.2,
42 ["float"] = 5.22,
43 ["int"] = 5,
44 ["nested"] = std::map with 1 element = {
45 ["bar"] = "barz"
46 },
47 ["trap "] = "you fell"
48 },
49 ["empty"] = nlohmann::detail::value_t::null
50 }
51 ```
52
53 Tested with GDB 9.2. See [#1952](https://github.com/nlohmann/json/issues/1952) for more information. Please post questions there.
54
55 ## Copyright
56
57 MIT License
58
59 Copyright (C) 2020 [Hannes Domani](https://github.com/ssbssa)
60
61 Permission is hereby granted, free of charge, to any person obtaining a copy
62 of this software and associated documentation files (the "Software"), to deal
63 in the Software without restriction, including without limitation the rights
64 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
65 copies of the Software, and to permit persons to whom the Software is
66 furnished to do so, subject to the following conditions:
67
68 The above copyright notice and this permission notice shall be included in all
69 copies or substantial portions of the Software.
70
71 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
73 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
74 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
75 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
76 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
77 SOFTWARE.