Author Topic: Debugger Scripts - avoiding template matches  (Read 1470 times)

Offline nomadwolf

  • Single posting newcomer
  • *
  • Posts: 3
Debugger Scripts - avoiding template matches
« on: April 30, 2016, 06:16:43 am »
I'm trying to use the gdb_types script to register a new type, let's say 'foo'
However, I do not want that to match when foo is used within a template type, such as tuple<foo, int, int>

I'm not particularly adept with RegExps, but the scripts that come with C::B would suggest using
[^[:alnum:]_]*foo[^[:alnum:]_]*")
However, that also matches the tuple example above

I essentially don't want to have a < before or a comma after 'foo', which leads me to try
(?<![a-zA-Z0-9<])foo(?![a-zA-Z0-9,])
That doesn't work when I try to use that in the script, but it does work as I expect when I run it through an online RegExp checker.
(i.e. 'foo' should pass, '<foo' shouldn't, nor should 'foo,')

Other option would be
[^a-zA-Z0-9<]+CEID[^a-zA-Z0-9,]+
but that won't match 'foo' by itself.

thoughts & help?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5339
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debugger Scripts - avoiding template matches
« Reply #1 on: April 30, 2016, 03:47:45 pm »
I'm trying to use the gdb_types script to register a new type, let's say 'foo'
...
...
thoughts & help?
Hi, welcome to our forum.
I suggest that you can use "GDB python pretty printer" to do the customized print.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline nomadwolf

  • Single posting newcomer
  • *
  • Posts: 3
Re: Debugger Scripts - avoiding template matches
« Reply #2 on: April 30, 2016, 06:11:31 pm »
Hi, welcome to our forum.
I suggest that you can use "GDB python pretty printer" to do the customized print.

Oooh, that is much more better.  Works for locals, function parameters, and sub-types.  Thanks!
Now I just have to learn some basic python...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13196
    • Travis build status
Re: Debugger Scripts - avoiding template matches
« Reply #3 on: May 01, 2016, 07:28:01 pm »
Yep, the original debug scripts will be as soon as I find some time to do it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]