bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting gdb's "frame" command to be quiet? + convenience hash tables?


From: James Salsman
Subject: getting gdb's "frame" command to be quiet? + convenience hash tables?
Date: Sun, 2 Jun 2002 13:55:30 -0700 (PDT)

Dear gdb maintainers:

Please let me know whether I should file the bug report and/or enhancement 
request indicated below.  Citations to GDB source locations from which I 
might be able to derive candidate patches would be very welcome, too.

I am using gdb to trace calls to malloc and calloc in a program where
over 100,000 calls are made to those functions.  I wish to use breakpoints 
on those functions to log stack backtraces that are different than the 
previous stack backtraces.  

Presently, I have tried this, which contrary to gdb documentation:

define remember_malloc_pcs
  frame 1                            # caller -- THIS SHOULDN'T PRINT!!!
  set $m_f1_pc = $pc                 # $m_... for malloc, $c_... for calloc
  frame 2                            # caller's caller
  set $m_f2_pc = $pc                 # remember program counters
end                                  # frame 3 omitted for brevity...

break malloc
commands
  silent                             # I wish!
  remember_malloc_pcs                # user-defined (above) --- NOT SILENT
  frame 2                            # caller's caller
  set $m_f2_pc = $pc                 # remember program counters
  # frame 3 omitted for brevity...
  if ($prev_m_f1_pc == $m_f1_pc && $prev_m_f2_pc == $m_f2_pc) 
    continue  # this was the backtrace previously printed so don't be redundant
    end
  backtrace                          # print for the trace log
  set $prev_m_f1_pc = $m_f1_pc       # remember to initalize all of these...
  set $prev_m_f2_pc = $m_f1_pc       #... $prev_ vars before first breakpoint
  continue                           # resume program execution
end

Question 1:  How can I cause "frame" to be quiet and not print?  The 
documentation ("help frame") *suggests* it will not print when used 
from a user-defined function, but that is not the case.  I.e.:

   (gdb) help frame
   Select and print a stack frame.
   With no argument, print the selected stack frame.  (See also "info frame").
   An argument specifies the frame to select.
   It can be a stack frame number or the address of the frame.
   With argument, nothing is printed if input is coming from
   a command file or a user-defined command.
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
I have tried using the commands above in a user-defined subroutine, and it 
does not keep output from being printed.

  (BUG REPORT:  INCORRECT DOCUMENTATION ON "frame")

Question 2:  [How] can I use a hash table of strings (like an AWK 
associative array, e.g.) to store the names of the functions in the 
stack frames for later comparison to see if they have been seen before?

  (POTENTIAL ENHANCEMENT REQUEST:  ADD CONVENIENCE HASH TABLES)

Thank you all for your kind volunteerism and help on these questions 
if at all possible.

Best wishes,
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]