~ubuntu-branches/debian/jessie/gdb/jessie

« back to all changes in this revision

Viewing changes to gdb/printcmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2010-03-20 01:21:29 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320012129-t7h25y8zgr8c2369
Tags: 7.1-1
* New upstream release, including:
  - PIE support (Closes: #346409).
  - C++ improvements, including static_cast<> et al, namespace imports,
    and bug fixes in printing virtual base classes.
  - Multi-program debugging.  One GDB can now debug multiple programs
    at the same time.
  - Python scripting improvements, including gdb.parse_and_eval.
  - Updated MIPS Linux signal frame layout (Closes: #570875).
  - No internal error stepping over _dl_debug_state (Closes: #569551).
* Update to Standards-Version: 3.8.4 (no changes required).
* Include more relevant (and smaller) docs in the gdbserver package
  (Closes: #571132).
* Do not duplicate documentation in gdb64, gdb-source, and libgdb-dev.
* Fix crash when switching into TUI mode (Closes: #568489).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4
4
   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5
 
   2008, 2009 Free Software Foundation, Inc.
 
5
   2008, 2009, 2010 Free Software Foundation, Inc.
6
6
 
7
7
   This file is part of GDB.
8
8
 
49
49
#include "solib.h"
50
50
#include "parser-defs.h"
51
51
#include "charset.h"
 
52
#include "arch-utils.h"
52
53
 
53
54
#ifdef TUI
54
55
#include "tui/tui.h"            /* For tui_active et.al.   */
135
136
  {
136
137
    /* Chain link to next auto-display item.  */
137
138
    struct display *next;
 
139
 
138
140
    /* The expression as the user typed it.  */
139
141
    char *exp_string;
 
142
 
140
143
    /* Expression to be evaluated and displayed.  */
141
144
    struct expression *exp;
 
145
 
142
146
    /* Item number of this auto-display item.  */
143
147
    int number;
 
148
 
144
149
    /* Display format specified.  */
145
150
    struct format_data format;
 
151
 
 
152
    /* Program space associated with `block'.  */
 
153
    struct program_space *pspace;
 
154
 
146
155
    /* Innermost block required by this expression when evaluated */
147
156
    struct block *block;
 
157
 
148
158
    /* Status of this display (enabled or disabled) */
149
159
    int enabled_p;
150
160
  };
553
563
   settings of the demangle and asm_demangle variables.  */
554
564
 
555
565
void
556
 
print_address_symbolic (CORE_ADDR addr, struct ui_file *stream,
 
566
print_address_symbolic (struct gdbarch *gdbarch, CORE_ADDR addr,
 
567
                        struct ui_file *stream,
557
568
                        int do_demangle, char *leadin)
558
569
{
559
570
  char *name = NULL;
566
577
  struct cleanup *cleanup_chain = make_cleanup (free_current_contents, &name);
567
578
  make_cleanup (free_current_contents, &filename);
568
579
 
569
 
  if (build_address_symbolic (addr, do_demangle, &name, &offset,
 
580
  if (build_address_symbolic (gdbarch, addr, do_demangle, &name, &offset,
570
581
                              &filename, &line, &unmapped))
571
582
    {
572
583
      do_cleanups (cleanup_chain);
606
617
   success, when all the info in the OUT paramters is valid. Return 1
607
618
   otherwise. */
608
619
int
609
 
build_address_symbolic (CORE_ADDR addr,  /* IN */
 
620
build_address_symbolic (struct gdbarch *gdbarch,
 
621
                        CORE_ADDR addr,  /* IN */
610
622
                        int do_demangle, /* IN */
611
623
                        char **name,     /* OUT */
612
624
                        int *offset,     /* OUT */
649
661
 
650
662
  if (symbol)
651
663
    {
 
664
      /* If this is a function (i.e. a code address), strip out any
 
665
         non-address bits.  For instance, display a pointer to the
 
666
         first instruction of a Thumb function as <function>; the
 
667
         second instruction will be <function+2>, even though the
 
668
         pointer is <function+3>.  This matches the ISA behavior.  */
 
669
      addr = gdbarch_addr_bits_remove (gdbarch, addr);
 
670
 
652
671
      name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
653
672
      if (do_demangle || asm_demangle)
654
673
        name_temp = SYMBOL_PRINT_NAME (symbol);
713
732
               CORE_ADDR addr, struct ui_file *stream)
714
733
{
715
734
  fputs_filtered (paddress (gdbarch, addr), stream);
716
 
  print_address_symbolic (addr, stream, asm_demangle, " ");
 
735
  print_address_symbolic (gdbarch, addr, stream, asm_demangle, " ");
 
736
}
 
737
 
 
738
/* Return a prefix for instruction address:
 
739
   "=> " for current instruction, else "   ".  */
 
740
 
 
741
const char *
 
742
pc_prefix (CORE_ADDR addr)
 
743
{
 
744
  if (has_stack_frames ())
 
745
    {
 
746
      struct frame_info *frame;
 
747
      CORE_ADDR pc;
 
748
 
 
749
      frame = get_selected_frame (NULL);
 
750
      pc = get_frame_pc (frame);
 
751
 
 
752
      if (pc == addr)
 
753
        return "=> ";
 
754
    }
 
755
  return "   ";
717
756
}
718
757
 
719
758
/* Print address ADDR symbolically on STREAM.  Parameter DEMANGLE
734
773
  else if (opts.addressprint)
735
774
    {
736
775
      fputs_filtered (paddress (gdbarch, addr), stream);
737
 
      print_address_symbolic (addr, stream, do_demangle, " ");
 
776
      print_address_symbolic (gdbarch, addr, stream, do_demangle, " ");
738
777
    }
739
778
  else
740
779
    {
741
 
      print_address_symbolic (addr, stream, do_demangle, "");
 
780
      print_address_symbolic (gdbarch, addr, stream, do_demangle, "");
742
781
    }
743
782
}
744
783
 
808
847
  while (count > 0)
809
848
    {
810
849
      QUIT;
 
850
      if (format == 'i')
 
851
        fputs_filtered (pc_prefix (next_address), gdb_stdout);
811
852
      print_address (next_gdbarch, next_address, gdb_stdout);
812
853
      printf_filtered (":");
813
854
      for (i = maxelts;
1449
1490
      new->exp_string = xstrdup (exp);
1450
1491
      new->exp = expr;
1451
1492
      new->block = innermost_block;
 
1493
      new->pspace = current_program_space;
1452
1494
      new->next = display_chain;
1453
1495
      new->number = ++display_number;
1454
1496
      new->format = fmt;
1565
1607
  if (d->enabled_p == 0)
1566
1608
    return;
1567
1609
 
 
1610
  /* The expression carries the architecture that was used at parse time.
 
1611
     This is a problem if the expression depends on architecture features
 
1612
     (e.g. register numbers), and the current architecture is now different.
 
1613
     For example, a display statement like "display/i $pc" is expected to
 
1614
     display the PC register of the current architecture, not the arch at
 
1615
     the time the display command was given.  Therefore, we re-parse the
 
1616
     expression if the current architecture has changed.  */
 
1617
  if (d->exp != NULL && d->exp->gdbarch != get_current_arch ())
 
1618
    {
 
1619
      xfree (d->exp);
 
1620
      d->exp = NULL;
 
1621
      d->block = NULL;
 
1622
    }
 
1623
 
1568
1624
  if (d->exp == NULL)
1569
1625
    {
1570
1626
      volatile struct gdb_exception ex;
1585
1641
    }
1586
1642
 
1587
1643
  if (d->block)
1588
 
    within_current_scope = contained_in (get_selected_block (0), d->block);
 
1644
    {
 
1645
      if (d->pspace == current_program_space)
 
1646
        within_current_scope = contained_in (get_selected_block (0), d->block);
 
1647
      else
 
1648
        within_current_scope = 0;
 
1649
    }
1589
1650
  else
1590
1651
    within_current_scope = 1;
1591
1652
  if (!within_current_scope)
1810
1871
  const union exp_element *const elts = exp->elts;
1811
1872
 
1812
1873
  if (d->block != NULL
 
1874
      && d->pspace == solib->pspace
1813
1875
      && solib_contains_address_p (solib, d->block->startaddr))
1814
1876
    return 1;
1815
1877
 
1826
1888
        {
1827
1889
          const struct block *const block = elts[i + 1].block;
1828
1890
          const struct symbol *const symbol = elts[i + 2].symbol;
1829
 
          const struct obj_section *const section =
1830
 
            SYMBOL_OBJ_SECTION (symbol);
1831
1891
 
1832
1892
          if (block != NULL
1833
 
              && solib_contains_address_p (solib, block->startaddr))
 
1893
              && solib_contains_address_p (solib,
 
1894
                                           block->startaddr))
1834
1895
            return 1;
1835
1896
 
1836
 
          if (section && section->objfile == solib->objfile)
 
1897
          /* SYMBOL_OBJ_SECTION (symbol) may be NULL.  */
 
1898
          if (SYMBOL_SYMTAB (symbol)->objfile == solib->objfile)
1837
1899
            return 1;
1838
1900
        }
1839
1901
      endpos -= oplen;
2580
2642
        /* Skip to the next substring.  */
2581
2643
        current_substring += strlen (current_substring) + 1;
2582
2644
      }
2583
 
    /* Print the portion of the format string after the last argument.  */
2584
 
    puts_filtered (last_arg);
 
2645
    /* Print the portion of the format string after the last argument.
 
2646
       Note that this will not include any ordinary %-specs, but it
 
2647
       might include "%%".  That is why we use printf_filtered and not
 
2648
       puts_filtered here.  Also, we pass a dummy argument because
 
2649
       some platforms have modified GCC to include -Wformat-security
 
2650
       by default, which will warn here if there is no argument.  */
 
2651
    printf_filtered (last_arg, 0);
2585
2652
  }
2586
2653
  do_cleanups (old_cleanups);
2587
2654
}