[lldb-dev] Question regarding argument types of "BreakpointHitCallback"

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Apr 30 12:22:10 PDT 2020



> On Apr 30, 2020, at 8:50 AM, Vangelis Tsiatsianas via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hello,
> 
> I would like to ask a question regarding "BreakpointHitCallback", which is declared as such:
> 
> bool (*BreakpointHitCallback)(void *baton,
>                               StoppointCallbackContext *context,
>                               lldb::user_id_t break_id,
>                               lldb::user_id_t break_loc_id);
> 
> Is there any particular reason that "break_id" and "break_loc_id" are of type "user_id_t" (64-bit unsigned) instead of "break_id_t" (32-bit signed), which is used both for "Stoppoint::m_bid" and "StoppointLocation::m_loc_id"?

I believe this callback predated the time when we added break_id and break_loc_id, and since arguments are part of the signature of C++ functions, we didn't change it in order to keep the public API from changing. Or this could have just been a mistake. Either way, we have a stable API and can't really change it.
> 
> This causes an issue mainly with internal breakpoints, since the callback of an internal breakpoint with (ID == 0xfffffffe) is called with (break_id == 0xfffffffffffffffe), forcing the callback to cast the argument back to a 32-bit signed in order to use it correctly, e.g. when the IDs are stored and need to be looked up.
> 
> A small example attempting to illustrate the problem: https://godbolt.org/z/y8LbK2 <https://godbolt.org/z/y8LbK2>
Sorry for the issue, but I think we are stuck with it now.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200430/c5a03e08/attachment.html>


More information about the lldb-dev mailing list