GDB (API)
/home/stan/gdb/linux/gdb/data-directory/python/gdb/command/prompt.py
Go to the documentation of this file.
00001 # Extended prompt.
00002 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
00003 
00004 # This program is free software; you can redistribute it and/or modify
00005 # it under the terms of the GNU General Public License as published by
00006 # the Free Software Foundation; either version 3 of the License, or
00007 # (at your option) any later version.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 # GNU General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU General Public License
00015 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 """GDB command for working with extended prompts."""
00018 
00019 import gdb
00020 import gdb.prompt
00021 
00022 class _ExtendedPrompt(gdb.Parameter):
00023 
00024     """Set the extended prompt.
00025 
00026 Usage: set extended-prompt VALUE
00027 
00028 Substitutions are applied to VALUE to compute the real prompt.
00029 
00030 The currently defined substitutions are:
00031 
00032 """
00033     # Add the prompt library's dynamically generated help to the
00034     # __doc__ string.
00035     __doc__ = __doc__ + gdb.prompt.prompt_help()
00036 
00037     set_doc = "Set the extended prompt."
00038     show_doc = "Show the extended prompt."
00039 
00040     def __init__(self):
00041         super(_ExtendedPrompt, self).__init__("extended-prompt",
00042                                               gdb.COMMAND_SUPPORT,
00043                                               gdb.PARAM_STRING_NOESCAPE)
00044         self.value = ''
00045         self.hook_set = False
00046 
00047     def get_show_string (self, pvalue):
00048         if self.value is not '':
00049            return "The extended prompt is: " + self.value
00050         else:
00051            return "The extended prompt is not set."
00052 
00053     def get_set_string (self):
00054         if self.hook_set == False:
00055            gdb.prompt_hook = self.before_prompt_hook
00056            self.hook_set = True
00057         return ""
00058 
00059     def before_prompt_hook(self, current):
00060         if self.value is not '':
00061             newprompt = gdb.prompt.substitute_prompt(self.value)
00062             return newprompt.replace('\\', '\\\\')
00063         else:
00064             return None
00065 
00066 _ExtendedPrompt()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines