VirtualBox

Changeset 86327 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Sep 28, 2020 4:20:50 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140613
Message:

Debugger: Allow for different I/O providers instead of only TCP

So far TCP was the only option to communicate remotely with the internal debugger, the other option
was to use the console from the GUI directly. This commit reworks basic I/O to allow for different
providers where TCP is just one option. The second one being introduced is an IPC provider using a local
socket or named pipe depending on the platform. This allows for Windows kernel debugging over a pipe
using the KD stub in VirtualBox and WinDbg running on the host (not tested yet).

Furthermore this commit allows multiple stubs to be listening for connections at the same time, so
one can have a GDB stub listening on one TCP port and the native VBox debugger listening on another one
or even using a different I/O provider. Only one session can be active at a time though, because sharing
debugger states is impossible. To configure this the following CFGM keys need to be set for each listener:

"DBGC/<Some unique ID>/Provider" "tcp|ipc"
"DBGC/<Some unique ID>/StubType" "native|gdb|kd"
"DBGC/<Some unique ID>/Address" "<ip>|<local named pipe or socket path>"
"DBGC/<Some unique ID>/Port" "<port>" (for TCP only)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbg.h

    r86098 r86327  
    11031103
    11041104
    1105 
    1106 /** Pointer to a DBGC backend. */
    1107 typedef struct DBGCBACK *PDBGCBACK;
    1108 
    1109 /**
    1110  * Checks if there is input.
    1111  *
    1112  * @returns true if there is input ready.
    1113  * @returns false if there not input ready.
    1114  * @param   pBack       Pointer to the backend structure supplied by
    1115  *                      the backend. The backend can use this to find
    1116  *                      it's instance data.
    1117  * @param   cMillies    Number of milliseconds to wait on input data.
    1118  */
    1119 typedef DECLCALLBACKTYPE(bool, FNDBGCBACKINPUT,(PDBGCBACK pBack, uint32_t cMillies));
    1120 /** Pointer to a FNDBGCBACKINPUT() callback. */
    1121 typedef FNDBGCBACKINPUT *PFNDBGCBACKINPUT;
    1122 
    1123 /**
    1124  * Read input.
    1125  *
    1126  * @returns VBox status code.
    1127  * @param   pBack       Pointer to the backend structure supplied by
    1128  *                      the backend. The backend can use this to find
    1129  *                      it's instance data.
    1130  * @param   pvBuf       Where to put the bytes we read.
    1131  * @param   cbBuf       Maximum nymber of bytes to read.
    1132  * @param   pcbRead     Where to store the number of bytes actually read.
    1133  *                      If NULL the entire buffer must be filled for a
    1134  *                      successful return.
    1135  */
    1136 typedef DECLCALLBACKTYPE(int, FNDBGCBACKREAD,(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead));
    1137 /** Pointer to a FNDBGCBACKREAD() callback. */
    1138 typedef FNDBGCBACKREAD *PFNDBGCBACKREAD;
    1139 
    1140 /**
    1141  * Write (output).
    1142  *
    1143  * @returns VBox status code.
    1144  * @param   pBack       Pointer to the backend structure supplied by
    1145  *                      the backend. The backend can use this to find
    1146  *                      it's instance data.
    1147  * @param   pvBuf       What to write.
    1148  * @param   cbBuf       Number of bytes to write.
    1149  * @param   pcbWritten  Where to store the number of bytes actually written.
    1150  *                      If NULL the entire buffer must be successfully written.
    1151  */
    1152 typedef DECLCALLBACKTYPE(int, FNDBGCBACKWRITE,(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten));
    1153 /** Pointer to a FNDBGCBACKWRITE() callback. */
    1154 typedef FNDBGCBACKWRITE *PFNDBGCBACKWRITE;
    1155 
    1156 /**
    1157  * Ready / busy notification.
    1158  *
    1159  * @param   pBack       Pointer to the backend structure supplied by
    1160  *                      the backend. The backend can use this to find
    1161  *                      it's instance data.
    1162  * @param   fReady      Whether it's ready (true) or busy (false).
    1163  */
    1164 typedef DECLCALLBACKTYPE(void, FNDBGCBACKSETREADY,(PDBGCBACK pBack, bool fReady));
    1165 /** Pointer to a FNDBGCBACKSETREADY() callback. */
    1166 typedef FNDBGCBACKSETREADY *PFNDBGCBACKSETREADY;
    1167 
    1168 
    1169 /**
    1170  * The communication backend provides the console with a number of callbacks
    1171  * which can be used
    1172  */
    1173 typedef struct DBGCBACK
    1174 {
    1175     /** Check for input. */
    1176     PFNDBGCBACKINPUT    pfnInput;
    1177     /** Read input. */
    1178     PFNDBGCBACKREAD     pfnRead;
    1179     /** Write output. */
    1180     PFNDBGCBACKWRITE    pfnWrite;
    1181     /** Ready / busy notification. */
    1182     PFNDBGCBACKSETREADY pfnSetReady;
    1183 } DBGCBACK;
    1184 
    1185 DBGDECL(int)    DBGCCreate(PUVM pUVM, PDBGCBACK pBack, unsigned fFlags);
     1105/** Pointer to a const I/O callback table. */
     1106typedef const struct DBGCIO *PCDBGCIO;
     1107
     1108/**
     1109 * I/O callback table.
     1110 */
     1111typedef struct DBGCIO
     1112{
     1113    /**
     1114     * Destroys the given I/O instance.
     1115     *
     1116     * @returns nothing.
     1117     * @param   pDbgcIo     Pointer to the I/O structure supplied by the I/O provider.
     1118     */
     1119    DECLCALLBACKMEMBER(void, pfnDestroy, (PCDBGCIO pDbgcIo));
     1120
     1121    /**
     1122     * Wait for input available for reading.
     1123     *
     1124     * @returns Flag whether there is input ready upon return.
     1125     * @retval  true if there is input ready.
     1126     * @retval  false if there not input ready.
     1127     * @param   pDbgcIo     Pointer to the I/O structure supplied by
     1128     *                      the I/O provider. The backend can use this to find it's instance data.
     1129     * @param   cMillies    Number of milliseconds to wait on input data.
     1130     */
     1131    DECLCALLBACKMEMBER(bool, pfnInput, (PCDBGCIO pDbgcIo, uint32_t cMillies));
     1132
     1133    /**
     1134     * Read input.
     1135     *
     1136     * @returns VBox status code.
     1137     * @param   pDbgcIo     Pointer to the I/O structure supplied by
     1138     *                      the I/O provider. The backend can use this to find it's instance data.
     1139     * @param   pvBuf       Where to put the bytes we read.
     1140     * @param   cbBuf       Maximum nymber of bytes to read.
     1141     * @param   pcbRead     Where to store the number of bytes actually read.
     1142     *                      If NULL the entire buffer must be filled for a
     1143     *                      successful return.
     1144     */
     1145    DECLCALLBACKMEMBER(int, pfnRead, (PCDBGCIO pDbgcIo, void *pvBuf, size_t cbBuf, size_t *pcbRead));
     1146
     1147    /**
     1148     * Write (output).
     1149     *
     1150     * @returns VBox status code.
     1151     * @param   pDbgcIo     Pointer to the I/O structure supplied by
     1152     *                      the I/O provider. The backend can use this to find it's instance data.
     1153     * @param   pvBuf       What to write.
     1154     * @param   cbBuf       Number of bytes to write.
     1155     * @param   pcbWritten  Where to store the number of bytes actually written.
     1156     *                      If NULL the entire buffer must be successfully written.
     1157     */
     1158    DECLCALLBACKMEMBER(int, pfnWrite, (PCDBGCIO pDbgcIo, const void *pvBuf, size_t cbBuf, size_t *pcbWritten));
     1159
     1160    /**
     1161     * Ready / busy notification.
     1162     *
     1163     * @returns nothing.
     1164     * @param   pDbgcIo     Pointer to the I/O structure supplied by
     1165     *                      the I/O provider. The backend can use this to find it's instance data.
     1166     * @param   fReady      Whether it's ready (true) or busy (false).
     1167     */
     1168    DECLCALLBACKMEMBER(void, pfnSetReady, (PCDBGCIO pDbgcIo, bool fReady));
     1169
     1170} DBGCIO;
     1171/** Pointer to an I/O callback table. */
     1172typedef DBGCIO *PDBGCIO;
     1173
     1174
     1175DBGDECL(int)    DBGCCreate(PUVM pUVM, PCDBGCIO pIo, unsigned fFlags);
    11861176DBGDECL(int)    DBGCRegisterCommands(PCDBGCCMD paCommands, unsigned cCommands);
    11871177DBGDECL(int)    DBGCDeregisterCommands(PCDBGCCMD paCommands, unsigned cCommands);
    1188 DBGDECL(int)    DBGCTcpCreate(PUVM pUVM, void **ppvUser);
    1189 DBGDECL(int)    DBGCTcpTerminate(PUVM pUVM, void *pvData);
     1178
     1179DBGDECL(int)    DBGCIoCreate(PUVM pUVM, void **ppvData);
     1180DBGDECL(int)    DBGCIoTerminate(PUVM pUVM, void *pvData);
    11901181
    11911182/** @} */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette