Electrolysis/Debugging: Difference between revisions

Line 105: Line 105:
To profile those messages, use the tool in {{bug|596725}}. You will get summarized output by message count and latency.
To profile those messages, use the tool in {{bug|596725}}. You will get summarized output by message count and latency.


== Working backwards from a C++ Message ID to its IPDL message ==
== Working backwards from a C++ Message to its IPDL message ==
 
The low-level C++ class used to transport IPDL messages around is <code>Message</code>.  You'll see objects of this type in debuggers.  Each source IPDL message declaration is assigned a unique ID.  In C++, this can be read from <code>Message.type()</code>.  Just before <code>Message</code>s are delivered to IPDL actors, they're also assigned a pretty name, accessible through <code>Message.name()</code>.
 
Sometimes however, errors occur before <code>Message.name()</code> is assigned.  For example, if a message is attempted to be dispatched to an actor that doesn't exist (probably because the actor was erroneously __delete__'d), then you'll see an error message like
###!!! [Parent][RPCChannel] Error: Route error: message sent to unknown actor ID
and if you tried to read <code>Message.name()</code> in the parent process (in this example, where the dispatch failed), you would get back "???".
 
It's possible in this case to work backwards from <code>Message.type()</code> to the IPDL message it represents.  First you need to break the ID into its source protocol and the message enum within that protocol.  You can do this by running
$ python $srcdir/ipc/ipdl/msgtype-components [MSGID]
Let's take the ID 3 as a random example.  As of m-c 66096f867849, you would see
$ python $srcdir/ipc/ipdl/msgtype-components 3
protocol 0 message 3
Next we need to look up protocol 0.  Open $objdir/ipc/ipdl/_ipdlheaders/IPCMessageStart.h.  The protocol number is the enum value for IPCMessageStart (yes, the name is weird; long story).  In this example, 0 is PAudioMsgStart, which is the PAudio protocol.
Next we need to look up the PAudio message.  Open $objdir/ipc/ipdl/_ipdlheaders/mozilla/dom/PAudio.h.  The message number is the '''ordinal''', not the actual value, for MessageType, starting from 0'th message.  (This is because the protocol number is encoded in the message ID.)  In this example, 3 (the third message) is Msg_SetVolume__ID.
So, in this example, <code>Message.type() = 3</code> refers to PAudio:SetVolume.
Confirmed users
699

edits