Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC][patch 0/9] Python support in GDB
@ 2008-04-29 15:59 Thiago Jung Bauermann
  2008-04-29 15:59 ` [RFC][patch 6/9] export frames to Python Thiago Jung Bauermann
                   ` (10 more replies)
  0 siblings, 11 replies; 147+ messages in thread
From: Thiago Jung Bauermann @ 2008-04-29 15:59 UTC (permalink / raw)
  To: gdb-patches

Hi everybody,

This patch series adds Python scripting support to GDB, and exposes
some of its subsystems hopefully in a "pythonic" way. These patches
correspond to the contents of the git repository at gitorious.org,
rebased to apply cleanly on top of CVS HEAD as of 04/27.

Unfortunately I wasn't able to resolve the conflicts on the MI code
when I did the rebase, so I had to leave the MI part out. Sorry about
this, Vladimir. I pushed to gitorious the branch containig the HEAD
version I used as base for the patches (it is the patches-base branch),
so I believe it will be easy for you to generate the missing patch.
Let me know if you would like me to help with this.

Regarding the ChangeLogs, I tried to put the right authors for each
patch. If I didn't attribute blame correctly, please let me know.

We now would like your opinion and input, especially regarding what
is/should be exposed to Python and how. We implemented what we thought
was useful, and covered the use cases we had in mind. Please point out
if the current implementation doesn't cover your use case, or a use
case that would be useful to support.

And, of course, if you think this is all well and good and the greatest
thing since sliced bread, consider this an RFA. :-)

By the way, here is a Python implementation of the backtrace command
which shows its output in reverse (correct, actually!) order. It is
relatively complex so it shows well how Python scripting currently
looks like in GDB (but it doesn't use all of what is exposed):

python
import sys

def argument_symbol (sym):
  sym_class = sym.get_class ()
  if (sym_class == gdb.SYMBOL_LOC_ARG or
      sym_class == gdb.SYMBOL_LOC_REF_ARG or
      sym_class == gdb.SYMBOL_LOC_REGPARM or
      sym_class == gdb.SYMBOL_LOC_REGPARM_ADDR or
      sym_class == gdb.SYMBOL_LOC_LOCAL_ARG or
      sym_class == gdb.SYMBOL_LOC_BASEREG_ARG or
      sym_class == gdb.SYMBOL_LOC_COMPUTED_ARG):
    return True
  
  return False

def print_frame_args (func, frame):
  if not func:
    return

  first = True
  block = func.get_value ()
  for sym in block:
    if not argument_symbol (sym):
      continue;

    if len(sym.get_linkage_name ()):
      nsym, is_field_of_this, symtab  = gdb.lookup_symbol (sym.get_linkage_name (), block, gdb.SYMBOL_VAR_DOMAIN)
      if nsym.get_class () != gdb.SYMBOL_LOC_REGISTER:
        sym = nsym

    if not first:
      sys.stdout.write (", ")

    sys.stdout.write (sym.get_print_name () + "=")
    val = frame.read_var_value (sym)
    if val:
      val.common_print (None, False, 2, 0)
    else:
      sys.stdout.write ("???")

    first = False

def gdb_rbacktrace ():
  frames = gdb.get_frames ()
  num_frames = len (frames)

  if num_frames > 0 and frames[num_frames - 1].get_unwind_stop_reason() > gdb.FRAME_UNWIND_FIRST_ERROR:
    print "Backtrace stopped: " + gdb.frame_stop_reason_string (frames[num_frames - 1].get_unwind_stop_reason())

  for i in reversed (range (len (frames))):
    sys.stdout.write ("#%-2d" % i)

    if frames[i].get_type () == gdb.DUMMY_FRAME:
      sys.stdout.write (" <function called from gdb>\n")
      continue
    elif frames[i].get_type () == gdb.SIGTRAMP_FRAME:
      sys.stdout.write (" <signal handler called>\n")
      continue

    sal = frames[i].find_sal ()
    pc = frames[i].get_pc ()
    name = frames[i].get_name ()
    if not name:
      name = "??"

    if pc != sal.get_pc () or not sal.symtab:
      sys.stdout.write (" 0x%08x in" % pc)

    sys.stdout.write (" " + name + " (")

    func = gdb.find_pc_function (frames[i].get_address_in_block ())
    print_frame_args (func, frames[i])
    sys.stdout.write (")")

    if sal.symtab and sal.symtab.get_filename ():
      sys.stdout.write (" at " + sal.symtab.get_filename ())
      sys.stdout.write (":" + str (sal.get_line ()))

    if not frames[i].get_name () or (not sal.symtab or not sal.symtab.get_filename ()):
      lib = gdb.solib_address (pc)
      if lib:
	sys.stdout.write (" from " + lib)

    sys.stdout.write ("\n")
end

define rbt
python gdb_rbacktrace ()
end

-- 
[]'s
Thiago Jung Bauermann
Software Engineer
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 147+ messages in thread

end of thread, other threads:[~2008-08-17 20:16 UTC | newest]

Thread overview: 147+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-29 15:59 [RFC][patch 0/9] Python support in GDB Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 6/9] export frames to Python Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 8/9] export symtab mechanism " Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 9/9] export threads " Thiago Jung Bauermann
2008-04-29 15:59 ` [RFC][patch 3/9] export hooks mechanism " Thiago Jung Bauermann
2008-04-29 21:29   ` Tom Tromey
2008-04-30 18:27     ` Joel Brobecker
2008-04-30 21:30       ` Tom Tromey
2008-05-27 18:22         ` Tom Tromey
2008-04-30 18:29     ` Daniel Jacobowitz
2008-04-30 23:00       ` Tom Tromey
2008-05-29  7:55   ` Daniel Jacobowitz
2008-05-30 14:59     ` Tom Tromey
2008-06-15 22:53       ` Thiago Jung Bauermann
2008-06-15 22:58         ` Tom Tromey
2008-06-16  3:22           ` Daniel Jacobowitz
2008-06-17 18:13             ` Thiago Jung Bauermann
2008-06-17 22:20               ` Joel Brobecker
2008-06-23 17:58                 ` Tom Tromey
2008-04-29 15:59 ` [RFC][patch 5/9] permit GDB commands implemented in Python Thiago Jung Bauermann
2008-04-29 16:08 ` [RFC][patch 7/9] export block and symbol mechanism to Python Thiago Jung Bauermann
2008-04-29 18:11 ` [RFC][patch 4/9] export breakpoints " Thiago Jung Bauermann
2008-04-29 18:15 ` [RFC][patch 1/9] initial Python support Thiago Jung Bauermann
2008-05-05  8:12   ` Thiago Jung Bauermann
2008-05-05 14:39     ` Daniel Jacobowitz
2008-05-05 14:46       ` Thiago Jung Bauermann
2008-05-05 16:50         ` Daniel Jacobowitz
2008-05-06  2:38           ` Thiago Jung Bauermann
2008-05-11 22:24           ` Thiago Jung Bauermann
2008-05-11 22:26             ` Daniel Jacobowitz
2008-05-12 20:33               ` Thiago Jung Bauermann
2008-05-12 20:39                 ` Daniel Jacobowitz
2008-05-12 21:00                   ` Thiago Jung Bauermann
2008-05-29  0:29   ` Daniel Jacobowitz
2008-05-30 13:07     ` Function syntax (Was: [RFC][patch 1/9] initial Python support) Tom Tromey
2008-06-08 15:24       ` Doug Evans
2008-06-08 15:32         ` Function syntax Tom Tromey
2008-06-08 18:21       ` Function syntax (Was: [RFC][patch 1/9] initial Python support) Daniel Jacobowitz
2008-06-09 13:48         ` Thiago Jung Bauermann
2008-06-09 18:43           ` Daniel Jacobowitz
2008-06-10  0:24             ` Function syntax Tom Tromey
2008-06-10  0:04           ` Tom Tromey
2008-06-11  0:04             ` Thiago Jung Bauermann
2008-06-10  0:00         ` Tom Tromey
2008-05-30 14:47     ` [RFC][patch 1/9] initial Python support Tom Tromey
2008-06-15 22:35     ` thiagoju
2008-06-23 17:36       ` Tom Tromey
2008-07-06 17:28         ` Tom Tromey
2008-07-08  4:12           ` Thiago Jung Bauermann
2008-07-15  7:38       ` [RFA] " Thiago Jung Bauermann
2008-07-15 17:19         ` Tom Tromey
2008-07-15 18:33           ` Thiago Jung Bauermann
2008-07-15 19:03             ` Tom Tromey
2008-07-16  7:14               ` Thiago Jung Bauermann
2008-07-16 14:39           ` Tom Tromey
2008-07-16 22:02             ` Thiago Jung Bauermann
2008-07-18 19:50               ` Daniel Jacobowitz
2008-07-18 23:24                 ` Tom Tromey
2008-07-19  0:45                   ` Daniel Jacobowitz
2008-07-19 19:50                 ` [RFA] iRe: " Thiago Jung Bauermann
2008-07-19 21:13                   ` Daniel Jacobowitz
2008-07-19 22:13                     ` Thiago Jung Bauermann
2008-07-20 23:47                   ` Thiago Jung Bauermann
2008-07-21  2:03                     ` Daniel Jacobowitz
2008-07-23 17:46                       ` [obvious] Wipe out CONFIG_INITS Thiago Jung Bauermann
2008-07-20 22:43                 ` [RFA] Re: [RFC][patch 1/9] initial Python support Tom Tromey
2008-07-21  1:59                   ` Daniel Jacobowitz
2008-07-21 15:29                 ` [RFA][patch 1/9] Yet another respin of the patch with " Thiago Jung Bauermann
2008-07-21 16:47                   ` Thiago Jung Bauermann
2008-07-26 13:07                   ` Eli Zaretskii
2008-07-26 13:43                     ` Daniel Jacobowitz
2008-07-26 14:02                       ` Eli Zaretskii
2008-07-26 14:42                         ` Daniel Jacobowitz
2008-07-26 17:06                           ` Eli Zaretskii
2008-07-26 17:26                             ` Tom Tromey
2008-07-26 19:21                               ` Eli Zaretskii
2008-07-26 17:40                             ` Daniel Jacobowitz
2008-07-26 17:10                           ` Tom Tromey
2008-07-26 17:40                             ` Eli Zaretskii
2008-07-26 18:00                               ` Tom Tromey
2008-07-26 18:29                                 ` Eli Zaretskii
2008-07-26 18:45                                   ` Tom Tromey
2008-07-26 19:34                                     ` Eli Zaretskii
2008-07-30 14:59                                       ` Thiago Jung Bauermann
2008-07-30 17:57                                         ` Eli Zaretskii
2008-08-04  4:44                                           ` Thiago Jung Bauermann
2008-08-04 19:18                                             ` Eli Zaretskii
2008-08-05  3:42                                               ` Thiago Jung Bauermann
2008-07-26 17:04                     ` Tom Tromey
2008-07-26 17:35                       ` Daniel Jacobowitz
2008-07-26 17:42                         ` Tom Tromey
2008-07-26 19:18                           ` Eli Zaretskii
2008-08-04  2:52                             ` Thiago Jung Bauermann
2008-08-04  3:22                               ` Eli Zaretskii
2008-08-04 12:15                                 ` Daniel Jacobowitz
2008-08-04 19:50                                   ` Eli Zaretskii
2008-08-05  2:08                                     ` Daniel Jacobowitz
2008-08-05  2:41                                       ` Thiago Jung Bauermann
2008-08-05  3:32                                       ` Eli Zaretskii
2008-08-05 12:19                                         ` Daniel Jacobowitz
2008-08-05 18:10                                           ` Eli Zaretskii
2008-08-05 18:23                                             ` Daniel Jacobowitz
2008-08-05 18:50                                               ` Eli Zaretskii
2008-08-05 18:58                                                 ` Daniel Jacobowitz
2008-07-26 19:20                         ` Eli Zaretskii
2008-07-26 18:11                       ` Eli Zaretskii
2008-07-26 18:30                         ` Daniel Jacobowitz
2008-07-26 19:26                           ` Eli Zaretskii
2008-08-01 20:04                           ` Tom Tromey
2008-08-02 17:38                             ` Daniel Jacobowitz
2008-08-02 17:50                               ` Tom Tromey
2008-08-02 19:00                               ` Eli Zaretskii
2008-08-05  4:19                         ` Thiago Jung Bauermann
2008-08-05 18:14                           ` Eli Zaretskii
2008-08-06  5:35                             ` [RFA][patch 1/9] Initial Python support, patch du jour Thiago Jung Bauermann
2008-08-06 18:24                               ` Eli Zaretskii
2008-08-06 19:53                                 ` Thiago Jung Bauermann
2008-08-04  4:44                     ` [RFA][patch 1/9] Yet another respin of the patch with initial Python support Thiago Jung Bauermann
2008-08-04 19:22                       ` Eli Zaretskii
2008-08-05  1:24                         ` Thiago Jung Bauermann
2008-08-02 17:41                   ` Daniel Jacobowitz
2008-08-02 19:02                     ` Eli Zaretskii
2008-08-02 19:07                       ` Daniel Jacobowitz
2008-07-15 18:01         ` [RFA] Re: [RFC][patch 1/9] " Thiago Jung Bauermann
2008-04-29 18:17 ` [RFC][patch 2/9] export values mechanism to Python Thiago Jung Bauermann
2008-05-29  1:23   ` Daniel Jacobowitz
2008-06-03  0:19     ` Tom Tromey
2008-06-03 13:04       ` Daniel Jacobowitz
2008-06-03 14:52         ` Tom Tromey
2008-07-07  6:03       ` Thiago Jung Bauermann
2008-07-07 23:44         ` Tom Tromey
2008-07-26  2:55           ` Daniel Jacobowitz
2008-07-26 17:17             ` Tom Tromey
2008-07-26 17:41               ` Daniel Jacobowitz
2008-07-30  3:01                 ` Tom Tromey
2008-07-30 14:26                   ` Thiago Jung Bauermann
2008-08-13  6:45         ` [python] acessing struct elements Thiago Jung Bauermann
2008-08-13 12:38           ` Daniel Jacobowitz
2008-08-13 20:38             ` Thiago Jung Bauermann
2008-08-17 20:16           ` Tom Tromey
2008-04-29 18:38 ` [RFC][patch 0/9] Python support in GDB Eli Zaretskii
2008-04-29 20:37   ` Thiago Jung Bauermann
2008-04-29 21:22     ` Tom Tromey
2008-04-30  7:54       ` Eli Zaretskii
2008-04-30 19:38         ` Thiago Jung Bauermann
2008-04-30 19:52           ` Eli Zaretskii
2008-05-02 18:30 ` Vladimir Prus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox