def parse_response(gdb_mi_text):
stream = StringStream(gdb_mi_text, debug=_DEBUG)<EOL>if _GDB_MI_NOTIFY_RE.match(gdb_mi_text):<EOL><INDENT>token, message, payload = _get_notify_msg_and_payload(gdb_mi_text, stream)<EOL>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:message>": message,<EOL>"<STR_LIT>": payload,<EOL>"<STR_LIT>": token,<EOL>}<EOL><DEDENT>elif _GDB_MI_RESULT_RE.match(gdb_mi_text):<EOL><INDENT>token, message, payload = _get_result_msg_and_payload(gdb_mi_text, stream)<EOL>return {<EOL>"<STR_LIT:type>": "<STR_LIT:result>",<EOL>"<STR_LIT:message>": message,<EOL>"<STR_LIT>": payload,<EOL>"<STR_LIT>": token,<EOL>}<EOL><DEDENT>elif _GDB_MI_CONSOLE_RE.match(gdb_mi_text):<EOL><INDENT>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:message>": None,<EOL>"<STR_LIT>": _GDB_MI_CONSOLE_RE.match(gdb_mi_text).groups()[<NUM_LIT:0>],<EOL>}<EOL><DEDENT>elif _GDB_MI_LOG_RE.match(gdb_mi_text):<EOL><INDENT>return {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:message>": None,<EOL>"<STR_LIT>": _GDB_MI_LOG_RE.match(gdb_mi_text).groups()[<NUM_LIT:0>],<EOL>}<EOL><DEDENT>elif _GDB_MI_TARGET_OUTPUT_RE.match(gdb_mi_text):<EOL><INDENT>return {<EOL>"<STR_LIT:type>": "<STR_LIT:target>",<EOL>"<STR_LIT:message>": None,<EOL>"<STR_LIT>": _GDB_MI_TARGET_OUTPUT_RE.match(gdb_mi_text).groups()[<NUM_LIT:0>],<EOL>}<EOL><DEDENT>elif response_is_finished(gdb_mi_text):<EOL><INDENT>return {"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT:message>": None, "<STR_LIT>": None}<EOL><DEDENT>else:<EOL><INDENT>return {"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT:message>": None, "<STR_LIT>": gdb_mi_text}<EOL><DEDENT>
Parse gdb mi text and turn it into a dictionary.

    See https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Stream-Records.html#GDB_002fMI-Stream-Records
    for details on types of gdb mi output.

    Args:
        gdb_mi_text (str): String output from gdb

    Returns:
        dict with the following keys:
        type (either 'notify', 'result', 'console', 'log', 'target', 'done'),
        message (str or None),
        payload (str, list, dict, or None)