This is an archive of the discontinued LLVM Phabricator instance.

A little bit more pointer safety in the Breakpoint code
ClosedPublic

Authored by zturner on Sep 12 2016, 11:06 PM.

Details

Summary

This started out when I noticed a potential pitfall in the API of SetCallback where you could potentially get the class into a bad state. Ultimately I wasn't able to fix that in this patch, although I did include a comment in this patch explaining the problem and some possible fixes. But my initial attempts to fix it before I decided that the best approach wasn't clear ended up in this patch, which I think is still a net positive, so I'm uploading it anyway.

Basically, it makes the Baton classes a little bit more type-safe by plumbing unique_ptrs through a few more places so that you never have to deal with raw pointers, and it also makes it so Batons can clean up after themselves by default, so anyone implementing a new baton doesn't have to reimplement the exact same code in the destructor every time.

Also fixes a compiler error since SIZE_T_MAX isn't defined.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner updated this revision to Diff 71110.Sep 12 2016, 11:06 PM
zturner retitled this revision from to A little bit more pointer safety in the Breakpoint code.
zturner updated this object.
zturner added a reviewer: jingham.
zturner added subscribers: lldb-commits, Restricted Project.
zturner updated this revision to Diff 71185.Sep 13 2016, 9:28 AM

There were a few outstanding compiler errors that I missed in my previous patch as I was doing it on a build without Python. This should catch all of them.

jingham accepted this revision.Sep 13 2016, 10:50 AM
jingham edited edge metadata.

Looks fine. The only bad effect of making a CommandBaton, then going out of your way to put it in a plain old BatonSP before passing it to us rather than a CommandBatonSP is that the serialization code won't know it is a command baton, and won't serialize it. We use the llvm isa stuff in a bunch of places so if this becomes a problem it would be natural to fix it that way.

This revision is now accepted and ready to land.Sep 13 2016, 10:50 AM
This revision was automatically updated to reflect the committed changes.