Mastering regular expression searches inside PVRTraceGUI

As part of our PowerVR SDK v3.3 development, we chose to refine navigation in PVRTraceGUI – our OpenGL ES analysis utility. This work consisted of many minor tweaks to simplify the interface. It also included a bigger change – a brand new search engine. One of the most important features of the new, streamlined Find dialog is its powerful regular expression search engine.

PVRTrace_find

In this blog post, I’ll detail a few tricks I’ve picked so far (despite being a regular expression novice) to significantly speed up my OpenGL ES debugging process.

What are regular expressions?

For those unfamiliar, regular expressions (a.k.a. RegEx) allow explicit definition of search patterns. They’re extremely useful when you want to search for something more specific than a single keyword. Before going any further, it’s worth mentioning that PVRTraceGUI actually supports Extended RegEx. This basically means there are some additional metacharacters to make life easier (this section of the Wikipedia RegEx article explains the differences).

Complex regular expressions can look a little daunting. Appendix A of the PVRTrace User Manual includes a table of all supported metacharacters. For convenience, I’ve included a cheat sheet below. If you can, I’d recommend also trying an online RegEx prototyping tool while reading this (e.g. www.rubular.com) to help you wrap your head around the basics.

Metacharacter Description
. Matches any single character.
[ ] A bracket expression. Matches a single character that is contained within the brackets.
[^ ] Matches a single character that is not contained within the brackets.
^ Matches the starting position within the string.
$ Matches the ending position of the string or the position just before a string-ending newline.
( ) Defines a marked subexpression.
n Matches what the nth marked subexpression matched, where n is a digit from 1 to 9
* Matches the preceding element zero or more times.
{m,n} Matches the preceding element at least m and not more than n times. For example, a{3,5} matches only “aaa”, “aaaa”, and “aaaaa”.
? Matches the preceding element zero or one time. For example, ab?c matches only “ac” or “abc”.
+ Matches the preceding element one or more times. For example, ab+c matches “abc”, “abbc”, “abbbc”, and so on, but not “ac”.
| The choice (also known as alternation or set union) operator matches either the expression before or the expression after the operator. For example, abc|def matches “abc” or “def”.
b Matches a word boundary.

Do the Find dialog’s options affect the search?

PVRTrace_find2

Regular expression searches can be used at the same time as the dialog’s other options.

  • “Look in” – Search in the Current Frame, the Whole Trace or a Frame Range. In multi-threaded applications, you can also choose which rendering thread should be searched
  • “Match case” – By default, the search is case-insensitive. Enabling this flag forces all pattern matches to be case-sensitive

How can I use regular expressions?

A very simple use I’ve found is to isolate all occurrences of a specific GL name with a family of calls. For example, the pattern below will find the creation, linking & binding of a particular shader program (135311933).

Program.*b135311933b

TheChase_findA

This pattern uses the ‘.’ metacharacter to capture any character type (a-z, A-Z, 0-9 etc.). The ‘*’ indicates that any number of the previous character should be captured (zero or more). Together, ‘.*’ tells the RegEx engine that we don’t care what characters are between the two search terms. The ‘b’ word boundary metacharacters ensure we match the word exactly and ignore cases where the word is a sub-string of a larger word (e.g. ignore 135311933456). When the expression is executed, PVRTraceGUI’s Search widget will list all matches in call order, grouped by the frame number they occurred in.

TheChase_findA_results

From this expression, we can go further and expand the search to include other GL calls that take the program name as an argument.

(Program|ActiveAttrib|ActiveUniform|AttachedShaders
|AttribLocation|GetUniform).*b135311933b

TheChase_findB_results

In this search, the ‘(‘ and ‘)’ brackets are used to define a sub expression. ‘|’ metacharacters indicate an OR operation. It’s possible to include multiple sub-expressions, so we can easily expand this search to include several GL names:

(Program|ActiveAttrib|ActiveUniform|AttachedShaders
|AttribLocation|GetUniform).*b(135311933|40810583|50050715)b

TheChase_findC_results

Any more suggestions?

As the search is performed on all textual data captured in the GL and EGL call stream, we can search for any call and/or parameter name. For example, the pattern below finds all compressed ETC2 texture data uploads where the resolution is 512×512, regardless of format (i.e. COMPRESSED_RGB8_ETC2, COMPRESSED_SRGB8_ETC2, COMPRESSED_SRGB8_ALPHA8_ETC2_EAC etc.).

glCompressedTex.*Image.*GL_COMPRESSED_.*ETC2.*b512b, b512b,

This is great! Where can I learn more?

There are countless wikis, blog posts and documents out there that explain clever uses of RegEx patterns to find needles in haystacks. The online tool I mentioned earlier is really useful (www.rubular.com). The best thing to do though is capture a PVRT, load it into PVRTraceGUI and start experimenting!

Search by Tag

Search for posts by tag.

Search by Author

Search for posts by one of our authors.

Featured posts
Popular posts

Blog Contact

If you have any enquiries regarding any of our blog posts, please contact:

United Kingdom

benny.har-even@imgtec.com
Tel: +44 (0)1923 260 511

Related blog articles

British Engineering Excellence Award

PowerVR Vision & AI design team collect another award

We’re delighted that the design team for our PowerVR Series2NX Neural Network Accelerator (NNA) has been honoured with a prestigious British Engineering Excellence Award (BEEA). The BEEAs were established in 2009 to demonstrate the high calibre of engineering design and innovation in the

Series8XT AR/VR Banner

Imagination Technologies: the ray tracing pioneers

After a period out of the spotlight, ray tracing technology has recently come back into focus, taking up a lot of column inches in the tech press. The primary reason is because graphics cards for the PC gaming market have

Amazon Fire Stick 4K pic

Amazon Lights up its Fire TV Stick 4K with PowerVR

Amazon, the internet shopping giant, announced earlier this week the latest version of its media streaming device, the Fire TV Stick 4K. First released in 2016, the Fire TV stick brings catch-up streaming services to any TV with an HDMI

Stay up-to-date with Imagination

Sign up to receive the latest news and product updates from Imagination straight to your inbox.

  • This field is for validation purposes and should be left unchanged.
>
Contact Us

Contact Us