Re: Printing bitmap objects in the debugger

Поиск
Список
Период
Сортировка
От Pavan Deolasee
Тема Re: Printing bitmap objects in the debugger
Дата
Msg-id CABOikdMK_jB_yZkRk6C=aAyQgK2AnAiafemL-9jTSini328Vbw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Printing bitmap objects in the debugger  (Pavan Deolasee <pavan.deolasee@gmail.com>)
Ответы Re: Printing bitmap objects in the debugger  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Re: Printing bitmap objects in the debugger  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers

On Wed, Sep 14, 2016 at 3:46 PM, Pavan Deolasee <pavan.deolasee@gmail.com> wrote:


 lately I'm using LVM debugger (which probably does not have something equivalent), 

And I was so clueless about lldb's powerful scripting interface. For example, you can write something like this in bms_utils.py: 

import lldb

def print_bms_members (bms):
    words = bms.GetChildMemberWithName("words")
    nwords = int(bms.GetChildMemberWithName("nwords").GetValue())

    ret = 'nwords = {0} bitmap: '.format(nwords,)
    for i in range(0, nwords):
        ret += hex(int(words.GetChildAtIndex(0, lldb.eNoDynamicValues, True).GetValue()))

    return ret

And then do this while attached to lldb debugger:

Process 99659 stopped
* thread #1: tid = 0x59ba69, 0x00000001090b012f postgres`bms_add_member(a=0x00007fe60a0351f8, x=10) + 15 at bitmapset.c:673, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001090b012f postgres`bms_add_member(a=0x00007fe60a0351f8, x=10) + 15 at bitmapset.c:673
   670 int wordnum,
   671 bitnum;
   672
-> 673 if (x < 0)
   674 elog(ERROR, "negative bitmapset member not allowed");
   675 if (a == NULL)
   676 return bms_make_singleton(x);
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> from bms_utils import *
>>> bms = lldb.frame.FindVariable ("a")
>>> print print_bms_members(bms)
nwords = 1 bitmap: 0x200


The complete API reference is available here http://lldb.llvm.org/python_reference/index.html

Looks like an interesting SoC project to write useful lldb/gdb scripts to print internal structures for ease of debugging :-)

Thanks,
Pavan

--
 Pavan Deolasee                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Write Ahead Logging for Hash Indexes
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Vacuum: allow usage of more than 1GB of work mem