This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [python][patch] Add GDB Parameters functionality


On 04/27/2010 08:36 PM, Eli Zaretskii wrote:

>>> I asked to say something about this translation, or provide an
>>> example.
>>
>> I'm just not sure what to say other than GDB will translate and encode
>> any escape sequences in the string.  In fact, 'encoded' will probably
>> just do here without the 'translated' verb - it seems redundant with
>> the new encoded text. I think that is clearer. How about that with a
>> cross-reference to encoding (pxref{Character Sets})?
> 
> Can you give me a couple of examples of this "translation"?  Then I
> could suggest some simple explanation.

The simplest example I can think of is escaping octal to print
characters.  So take this super simple string parameter:


class TestStringParam (gdb.Parameter):
      show_doc = "Show some string"
      set_doc = "Set some string"
      def __init__ (self, name):
         super (TestStringParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_STRING)
         self.value = "foo"
test_file_param = TestStringParam ('test-string-param')

Invoke it in GDB via the python command:

(gdb) python
>class TestStringParam (gdb.Parameter):
>      show_doc = "Show some string"
>      set_doc = "Set some string"
>      def __init__ (self, name):
>         super (TestStringParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_STRING)
>         self.value = "foo"
>test_file_param = TestStringParam ('test-string-param')
>end

Now test it:

(gdb) set test-string-param plain old text
(gdb) show test-string-para
Some string is "plain old text".

(gdb) set test-string-param \107\157\157\144\040\104\141\171 sir!
(gdb) show test-string-para
Some string is "Good Day sir!".

Does that help?

Cheers,

Phil



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]