Commit Graph

39 Commits

Author SHA1 Message Date
Tomasz Grabiec
abf8e83c8d gdb: Cast gdb.Values to int
Fails with newer GDB with:

  TypeError: %x format: an integer is required, not gdb.Value

Message-Id: <1488981412-22279-1-git-send-email-tgrabiec@scylladb.com>
2017-03-08 19:43:48 +02:00
Tomasz Grabiec
5458a32f13 gdb: Introduce commands for inspecting pending task queue
Message-Id: <1485426236-6627-1-git-send-email-tgrabiec@scylladb.com>
2017-02-02 13:15:17 +02:00
Tomasz Grabiec
570fc0008b scylla-gdb: Fix lookup of symbols in 'scylla ptr'
Message-Id: <1480529617-26564-1-git-send-email-tgrabiec@scylladb.com>
2016-12-01 12:33:29 +02:00
Tomasz Grabiec
41e66ebce2 gdb: Introduce 'scylla heapprof'
Presents current heap profile recording.

Works in text mode or dumps to collapsed stacks format from which
flame graph can be generated.

To generate a flamegraph:

  (gdb) scylla heapprof --flame
  Wrote heapprof.stacks

  $ flamegraph.pl --colors mem < heapprof.stacks > heapprof.svg

flamegraph.pl comes from:

  https://github.com/brendangregg/FlameGraph.git

Text mode example:

(gdb) scylla heapprof --min 100000000
All (274699676, #10213)
 \-- void* memory::cpu_pages::allocate_large_and_trim<memory::cpu_pages::allocate_large_aligned(unsigned int, unsigned int)::{lambda(unsigned int, unsigned int)#1}>(unsigned int, memory::cpu_pages::allocate_large_aligned(unsigned int, unsigned int)::{lambda(unsigned int, unsigned int)#1}) + 169  (268435456, #1)
     memory::allocate_large_aligned(unsigned long, unsigned long) + 87
     memory::allocate_aligned(unsigned long, unsigned long) + 48
     aligned_alloc + 9
     logalloc::segment_zone::segment_zone() + 304
     logalloc::segment_pool::allocate_segment() + 477
     logalloc::segment_pool::segment_pool() + 304
     __tls_init.part.801 + 72
     logalloc::region_group::release_requests() + 1333
     logalloc::region_group::add(logalloc::region_group*) + 514

The branches are formatted like this:

   -- <symbol> (<size>, #<count>)

Where <size> is total size of live objects and <count> is total
number of live objects, for all objects allocated from paths going
through this node.

Nodes which share the same <size> and <count> are stacked like this:

   -- <symbol_1> (<size>, #<count>)
      <symbol_2>
      <symbol_3>

Message-Id: <1475583334-19524-1-git-send-email-tgrabiec@scylladb.com>
2016-10-09 10:54:08 +03:00
Tomasz Grabiec
69aec3835f scylla-gdb: Enhance 'scylla ptr' to show if object is managed by LSA
Example:

  (gdb) scylla ptr 0x601000480000
  thread 1, large, LSA-managed

One can then use 'scylla lsa-segment 0x601000480000' to examine LSA
segment contents.
2016-09-20 16:53:23 +02:00
Tomasz Grabiec
486a92092b scylla-gdb: Add 'scylla segment-descs' command
Displays information about shard's segment descriptors. One can see
which segments belong to LSA, what's their occupancy, etc.

(gdb) scylla segment-descs
...
0x601000940000: lsa free=26092 region=0x60100036d890 zone=0x6010000fb420
0x601000980000: lsa free=26092 region=0x60100036d890 zone=0x6010000fb420
0x6010009c0000: lsa free=261153 region=0x60100036fcf0 zone=0x6010000fb420
0x601000a00000: std
0x601000a40000: lsa free=25508 region=0x60100036d890 zone=0x6010000fb420
0x601000a80000: std
0x601000ac0000: lsa free=26092 region=0x60100036d890 zone=0x6010000fb420
0x601000b00000: lsa free=26092 region=0x60100036d890 zone=0x6010000fb420
0x601000b40000: std
...
2016-09-20 16:53:23 +02:00
Tomasz Grabiec
b0b28696b5 scylla-gdb: Add 'scylla lsa-segment' command
Allows one to examine contents of LSA segment.

Example:

  (gdb) scylla lsa-segment 0x601000480000
  0x601000480e70: live size=144 migrator=standard_migrator<cache_entry>::object
  0x601000480f10: live size=144 migrator=standard_migrator<cache_entry>::object
  0x601000480fb0: free size=192
  0x60100048107e: free size=42
  0x6010004814e0: free size=192
  0x6010004815ae: free size=40
  0x6010004815e8: free size=192
  0x6010004816b8: live size=144 migrator=standard_migrator<cache_entry>::object
  0x601000481758: free size=192
  ...
2016-09-20 16:53:21 +02:00
Tomasz Grabiec
5011b77e15 scylla-gdb: Add std::vector wrapper
Makes vector values itearable from python level.
2016-09-20 16:53:20 +02:00
Tomasz Grabiec
0c1bf6c861 scylla-gdb.py: Fix lookup of global symbols
Fixes errors like the one below:

  (gdb) scylla memory
  Python Exception <class 'gdb.error'> A syntax error in expression, near `memory::cpu_mem'.:
  Error occurred in Python command: A syntax error in expression, near `memory::cpu_mem'.

Wrapping the symbol in quotes instructs GDB to lookup in the global
context instead of the context of current frame.
Message-Id: <1470050751-3167-1-git-send-email-tgrabiec@scylladb.com>
2016-08-01 13:51:15 +01:00
Tomasz Grabiec
0b8aafd72c scylla-gdb.py: Introduce "scylla thread apply all ..."
Similar to gdb's "thread apply all". Executes given command in the
context of each seastar thread.

For example to print backtrace of all threads:

  scylla thread apply-all bt
2016-07-25 12:40:47 +02:00
Tomasz Grabiec
2d6341d4cb scylla-gdb.py: Introduce "scylla threads" command
Lists all seastar threads.

Example:

(gdb) scylla threads
[shard  1] (seastar::thread_context*) 0x602008c9aa00
[shard  1] (seastar::thread_context*) 0x602008c9ca00
[shard  1] (seastar::thread_context*) 0x602008cf5800
[shard  1] (seastar::thread_context*) 0x602008cbe000
[shard  1] (seastar::thread_context*) 0x602008c4bc00
[shard  2] (seastar::thread_context*) 0x601008d6b800
[shard  2] (seastar::thread_context*) 0x601008d89400
[shard  2] (seastar::thread_context*) 0x601008c95a00
[shard  0] (seastar::thread_context*) 0x600008d84400
[shard  0] (seastar::thread_context*) 0x6000000a1600
[shard  0] (seastar::thread_context*) 0x600008ce9a00
[shard  0] (seastar::thread_context*) 0x600008df9a00
[shard  0] (seastar::thread_context*) 0x600008dfee00
[shard  0] (seastar::thread_context*) 0x600008d85800
[shard  0] (seastar::thread_context*) 0x600008df9000
[shard  0] (seastar::thread_context*) 0x600008d82c00
[shard  0] (seastar::thread_context*) 0x600008cece00
2016-07-25 12:32:48 +02:00
Tomasz Grabiec
0e1b21eab6 scylla-gdb.py: Make intrusive_list() work with newer version of boost 2016-07-25 12:32:48 +02:00
Tomasz Grabiec
0db79c7153 scylla-gdb.py: Introduce "scylla mem-range" command
Prints memory range belonging to current shard.
2016-07-22 15:19:48 +02:00
Tomasz Grabiec
26e66bf49e scylla-gdb.py: Introduce "scylla thread" command
Switches into a seastar thread. "scylla unthread" switches back.

Example:

```
  (gdb) scylla thread 0x6000000e1800
  Switched to thread 1, (seastar::thread_context*) 0x6000000e1800

  (gdb) bt
  #0  seastar::thread_context::switch_out (this=0x6000000e1800) at core/thread.cc:104
  #1  0x00000000004cfb07 in future<>::wait() (this=0x600008ca2c70) at core/future.hh:817
  #2  0x0000000000f7752c in future<>::get() (this=0x600008ca2c70) at /home/tgrabiec/src/scylla2/seastar/core/future.hh:787
  ...
  #16 seastar::thread_context::main (this=0x6000000e1800) at core/thread.cc:166
  #17 0x000000000051a702 in seastar::thread_context::s_main (lo=<optimized out>, hi=<optimized out>) at core/thread.cc:157
  #18 0x00007f2c34861f20 in ?? () from /lib64/libc.so.6
  #19 0x0000000000000000 in ?? ()

  (gdp) scylla unthread
  Switched to thread 1
```
2016-07-22 15:19:48 +02:00
Tomasz Grabiec
d6fc9ad48e scylla-gdb.py: Break down code into finer abstractions 2016-07-22 15:19:48 +02:00
Avi Kivity
5ceb55827d Merge "Add more tools to the gdb script" from Tomasz 2016-07-20 11:21:58 +03:00
Tomasz Grabiec
d2f0711608 scylla-gdb: Fix bounds checking in scylla ptr command
Message-Id: <1468951987-10184-1-git-send-email-tgrabiec@scylladb.com>
2016-07-20 11:20:45 +03:00
Tomasz Grabiec
93a942dc53 scylla-gdb.py: Add "scylla mem-ranges" command
Prints memory ranges corresponding to seastar heap.

The ouput can be easily turned into arguemnts to "find".
2016-07-19 20:23:40 +02:00
Tomasz Grabiec
724f99641f scylla-gdb.py: Add "scylla shard" command
Beams you up to the thread corresponding to given seastar shard.

Example:

 (gdb) scylla shard 0
 Switched to thread 49
2016-07-19 20:23:40 +02:00
Tomasz Grabiec
d5fb452e94 scylla-gdb.py: Add "scylla apply" command
Executes given command on all shards.
2016-07-19 20:23:40 +02:00
Tomasz Grabiec
720d8149ba scylla-gdb.py: Add "scylla timers" command
Lists all active timers on current shard.
2016-07-19 20:23:40 +02:00
Tomasz Grabiec
6e4506a1f2 scylla-gdb.py: Add std::array wrapper which allows iteration 2016-07-19 20:23:40 +02:00
Tomasz Grabiec
29af5b22da scylla-gdb.py: Import intrusive_list() function
Imported from:

  https://github.com/cloudius-systems/osv/blob/master/scripts/loader.py
2016-07-19 20:23:40 +02:00
Tomasz Grabiec
6108d91362 scylla-gdb: Introduce scylla ptr
Helps in identifying pointers allocated through seastar
allocator. Shows to which thread the pointer belongs, to which size
class, whether it's live or free, what's the offset realtive to the
live object.

Example:

  (gdb) scylla ptr 0x6040abe88170
  thread 1, small (size <= 320), live (0x6040abe88140 +48)

Message-Id: <1467047215-1763-1-git-send-email-tgrabiec@scylladb.com>
2016-06-27 20:11:56 +03:00
Avi Kivity
a192c80377 gdb: fully-qualify type names
gdb gets confused if a non-fully-qualified class name is used when
we are in some namespace context.  Help it out by adding a :: prefix.
Message-Id: <1466587895-8690-1-git-send-email-avi@scylladb.com>
2016-06-22 12:04:17 +02:00
Tomasz Grabiec
533aec84b3 schema: Enable shared_from_this() 2016-01-11 10:34:51 +01:00
Tomasz Grabiec
f58c2dec1e schema: Make schema objects versioned
The version needs to change value not only on structural changes but
also temporal. This is needed for nodes to detect if the version they
see was already synchronized with or not even if it has the same
structure as the past versions. We also need to end up with the same
version on all nodes when schema changes are commuted.

For regular mutable schemas version will be calculated from underlying
mutations when schema is announced. For static schemas of system
keyspace it is calculated by hashing scylla version and column id,
because we don't have mutations at the time of building the schema.
2016-01-08 21:10:26 +01:00
Tomasz Grabiec
50984ad8d4 scylla-gdb.py: Allow the script to be sourced multiple times
Currently sourcing for the second time causes an exception from
pretty printer registration:

Traceback (most recent call last):
  File "./scylla-gdb.py", line 41, in <module>
    gdb.printing.register_pretty_printer(gdb.current_objfile(), build_pretty_printer())
  File "/usr/share/gdb/python/gdb/printing.py", line 152, in register_pretty_printer
    printer.name)
RuntimeError: pretty-printer already registered: scylla
2015-12-16 18:06:51 +01:00
Paweł Dziepak
73a1213160 scylla-gdb.py: print lsa zones
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-08 19:31:40 +01:00
Paweł Dziepak
2e94086a2c lsa: use bi::list to implement segment_stack
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-12-08 19:31:40 +01:00
Paweł Dziepak
9396956955 scylla-gdb.py: show lsa statistics and regions
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-11-24 16:36:20 +01:00
Paweł Dziepak
aaecf5424c scylla-gdb.py: show free, used and total memory
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2015-11-24 16:36:16 +01:00
Tomasz Grabiec
53e842aaf7 scylla-gdb.py: Fix scylla column_families command 2015-11-19 10:44:00 +02:00
Tomasz Grabiec
a540a4352b scylla-gdb.py: Make 'scylla memory' also print page span info
Example output:

Page spans:
index      size [B] free [B]
    0          4096 0
    1          8192 0
    2         16384 0
    3         32768 0
    4         65536 0
    5        131072 40239104
    6        262144 32505856
    7        524288 1835008
    8       1048576 0
    9       2097152 0
   10       4194304 0
   11       8388608 0
   12      16777216 0
   13      33554432 0
   14      67108864 0
   15     134217728 0
   16     268435456 0
   17     536870912 0
   18    1073741824 0
   19    2147483648 0
   20    4294967296 0
   21    8589934592 0
   22   17179869184 0
   23   34359738368 0
   24   68719476736 0
   25  137438953472 0
   26  274877906944 0
   27  549755813888 0
   28 1099511627776 0
   29 2199023255552 0
   30 4398046511104 0
   31 8796093022208 0
2015-09-03 09:07:14 +03:00
Avi Kivity
3a69561061 gdb: add 'scylla memory' command
Useful for analyzing memory leaks:

(gdb) scylla memory
objsz spansz    usedobj       memory  wst%
    1   4096          0            0   0.0
    1   4096          0            0   0.0
    1   4096          0            0   0.0
    1   4096          0            0   0.0
    2   4096          0            0   0.0
    2   4096          0            0   0.0
    3   4096          0            0   0.0
    3   4096          0            0   0.0
    4   4096          0            0   0.0
    5   4096          0            0   0.0
    6   4096          0            0   0.0
    7   4096          0            0   0.0
    8   4096        422         8192  58.8
   10   4096          0            0   0.0
   12   4096          0            0   0.0
   14   4096          0         8192  99.8
   16   4096        409         8192  20.1
   20   4096          0            0   0.0
   24   4096          0            0   0.0
   28   4096        653        24576  25.4
   32   4096       1069        36864   7.2
   40   4096          0            0   0.0
   48   4096          0            0   0.0
   56   4096       1228        73728   6.5
   64   4096        616        40960   3.8
   80   4096          0            0   0.0
   96   4096          0            0   0.0
  112   4096        919       110592   5.4
  128   4096        141        24576  26.6
  160   8192          0            0   0.0
  192   8192          0            0   0.0
  224   8192        128        49152  40.1
  256   8192         72        40960  55.0
  320  16384          0            0   0.0
  384  16384          0            0   0.0
  448  16384         60        49152  43.8
  512  16384         29        49152  69.8
  640  32768          0            0   0.0
  768  32768          0            0   0.0
  896  32768         47        98304  55.6
 1024  32768          5        98304  94.8
 1280  65536          0            0   0.0
 1536  65536          0            0   0.0
 1792  65536         31       196608  70.2
 2048  65536          8       196608  91.7
 2560 131072          0            0   0.0
 3072 131072          0            0   0.0
 3584 131072         34       393216  67.4
 4096 131072          0       393216 100.0
 5120 262144          0            0   0.0
 6144 262144          0            0   0.0
 7168 262144         33       786432  68.4
 8192 262144          4       786432  95.8
10240 524288          0            0   0.0
12288 524288          0            0   0.0
14336 524288         33      1572864  68.4
16384 524288          0      1572864 100.0
2015-07-30 10:56:01 +02:00
Tomasz Grabiec
81eb51b8f8 scylla-gdb.py: Fixes for GDB with python3
Fixes complaints about inability to convert gdb.Value to int.
2015-07-28 11:31:08 +02:00
Avi Kivity
72cc2c0115 gdb: list database, keyspace, column_family
(gdb) scylla databases
    0 (database*)0x60000009c900
    1 (database*)0x60100011bf00
(gdb) scylla keyspaces
    0 "system"             (keyspace*)0x6000000cacf8
    1 "system"             (keyspace*)0x601000114018
(gdb) scylla column_families
    0 "5a1ff267-ace0-3f12-8563-cfae6103c65e" "system"/"sstable_activity"                   (column_family*)0x60000010bf88
    0 "b4dbb7b4-dc49-3fb5-b3bf-ce6e434832ca" "system"/"compaction_history"                 (column_family*)0x60000010c148
    0 "55d76438-4e55-3f8b-9f6e-676d4af3976d" "system"/"range_xfers"                        (column_family*)0x60000010c4c8
    0 "59dfeaea-8db2-3341-91ef-109974d81484" "system"/"peer_events"                        (column_family*)0x60000010c688
    0 "37f71aca-7dc2-383b-a706-72528af04d4f" "system"/"peers"                              (column_family*)0x60000010c848
    0 "7ad54392-bcdd-35a6-8417-4e047860b377" "system"/"local"                              (column_family*)0x60000010ca08
    0 "b7b7f0c2-fd0a-3410-8c05-3ef614bb7c2d" "system"/"paxos"                              (column_family*)0x60000010cbc8
    0 "d1b675fe-2b50-3ca4-8e49-c0f81989dcad" "system"/"schema_functions"                   (column_family*)0x60000010d488
    0 "296e9c04-9bec-3085-827d-c17d3df2122a" "system"/"schema_columns"                     (column_family*)0x60000010d9c8
    0 "9f5c6374-d485-3229-9a0a-5094af9ad1e3" "system"/"IndexInfo"                          (column_family*)0x60000010d108
    0 "0359bc71-7123-3ee1-9a4a-b9dfb11fc125" "system"/"schema_triggers"                    (column_family*)0x60000010d808
    0 "0290003c-977e-397c-ac3e-fdfdc01d626b" "system"/"batchlog"                           (column_family*)0x60000010cd88
    0 "3aa75225-4f82-350b-8d5c-430fa221fa0a" "system"/"schema_usertypes"                   (column_family*)0x60000010d648
    0 "55080ab0-5d9c-3886-90a4-acb25fe1f77b" "system"/"compactions_in_progress"            (column_family*)0x60000010c308
    0 "b0f22357-4458-3cdb-9631-c43e59ce3676" "system"/"schema_keyspaces"                   (column_family*)0x60000010db88
    0 "45f5b360-24bc-3f83-a363-1034ea4fa697" "system"/"schema_columnfamilies"              (column_family*)0x60000010e008
    0 "a5fc57fc-9d6c-3bfd-a3fc-01ad54686fea" "system"/"schema_aggregates"                  (column_family*)0x60000010d2c8
    0 "2666e205-73ef-38b3-90fe-fecf96e8f0c7" "system"/"hints"                              (column_family*)0x60000010cf48
    1 "5a1ff267-ace0-3f12-8563-cfae6103c65e" "system"/"sstable_activity"                   (column_family*)0x601000121f88
    1 "b4dbb7b4-dc49-3fb5-b3bf-ce6e434832ca" "system"/"compaction_history"                 (column_family*)0x601000122148
    1 "55d76438-4e55-3f8b-9f6e-676d4af3976d" "system"/"range_xfers"                        (column_family*)0x6010001224c8
    1 "59dfeaea-8db2-3341-91ef-109974d81484" "system"/"peer_events"                        (column_family*)0x601000122688
    1 "37f71aca-7dc2-383b-a706-72528af04d4f" "system"/"peers"                              (column_family*)0x601000122848
    1 "7ad54392-bcdd-35a6-8417-4e047860b377" "system"/"local"                              (column_family*)0x601000122a08
    1 "b7b7f0c2-fd0a-3410-8c05-3ef614bb7c2d" "system"/"paxos"                              (column_family*)0x601000122bc8
    1 "d1b675fe-2b50-3ca4-8e49-c0f81989dcad" "system"/"schema_functions"                   (column_family*)0x601000123488
    1 "296e9c04-9bec-3085-827d-c17d3df2122a" "system"/"schema_columns"                     (column_family*)0x6010001239c8
    1 "9f5c6374-d485-3229-9a0a-5094af9ad1e3" "system"/"IndexInfo"                          (column_family*)0x601000123108
    1 "0359bc71-7123-3ee1-9a4a-b9dfb11fc125" "system"/"schema_triggers"                    (column_family*)0x601000123808
    1 "0290003c-977e-397c-ac3e-fdfdc01d626b" "system"/"batchlog"                           (column_family*)0x601000122d88
    1 "3aa75225-4f82-350b-8d5c-430fa221fa0a" "system"/"schema_usertypes"                   (column_family*)0x601000123648
    1 "55080ab0-5d9c-3886-90a4-acb25fe1f77b" "system"/"compactions_in_progress"            (column_family*)0x601000122308
    1 "b0f22357-4458-3cdb-9631-c43e59ce3676" "system"/"schema_keyspaces"                   (column_family*)0x601000123b88
    1 "45f5b360-24bc-3f83-a363-1034ea4fa697" "system"/"schema_columnfamilies"              (column_family*)0x601000124008
    1 "a5fc57fc-9d6c-3bfd-a3fc-01ad54686fea" "system"/"schema_aggregates"                  (column_family*)0x6010001232c8
    1 "2666e205-73ef-38b3-90fe-fecf96e8f0c7" "system"/"hints"                              (column_family*)0x601000122f48
2015-07-26 18:54:13 +03:00
Avi Kivity
e8dbfdb56b gdb: pretty-print uuids 2015-07-26 18:54:12 +03:00
Avi Kivity
53856bf2d1 Add gdb pretty-printing script 2015-07-26 18:54:11 +03:00