This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 2/2] C++-ify break-catch-throw
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> So something like this. Builds and gdb starts, but I have
Pedro> not regtested it.
Thanks for doing this. I should have noticed the compile_rx_or_error
problem in my patch -- IIRC I wrote compile_rx_or_error and even
violated my own rule about cleanup naming (that cleanup-returning
functions should start "make_cleanup_") at the time. Double ouch.
Pedro> In a couple places, this either forces moving the regex object
Pedro> to the heap, or to wrap it in gdb::optional. In the cases
Pedro> where we already have to keep the regex string around,
Pedro> it ends up being not maximally efficient memory-wise, but I don't
Pedro> think it really matters. We're considering std::string for
Pedro> those same strings, which grows the structs more than that, anyway
Pedro> (for size/capacity).
I was thinking that perhaps the regexp object should just have its own
optionality. But, I think your way is also fine, maybe more principled
in a way.
I didn't look at all the cases, but at least for "catch throw" it
doesn't seem to matter much. For a few bytes in that structure to be a
problem, someone would have to use thousands or millions of catchpoints,
which seems absurd.
Pedro> WDYT?
Looks great, I will wait for this to land before round 2.
Pedro> +ada_add_standard_exceptions (gdb_regex *preg, VEC(ada_exc_info) **exceptions)
The various callees could use const if the exec method was const.
Pedro> + /* Compile a regexp and throw an exception on error, including
Pedro> + MESSAGE. REGEX and MESSAGE must not be NULL. */
Pedro> + gdb_regex (const char *regex, int cflags,
Pedro> + const char *message);
Use ATTRIBUTE_NONNULL?
Pedro> + /* Wrapper around ::regexec. */
Pedro> + int exec (const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
Pedro> +
Pedro> + /* Wrapper around ::re_search. */
Pedro> + int search (const char *string, int size,
Pedro> + int startpos, int range, struct re_registers *regs);
Could both be 'const', I think.
Tom