get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/818549/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 818549,
    "url": "http://patchwork.ozlabs.org/api/patches/818549/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150642390797.3900.15056414492991775809.stgit@Misha-PC.lan02.inno/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<150642390797.3900.15056414492991775809.stgit@Misha-PC.lan02.inno>",
    "list_archive_url": null,
    "date": "2017-09-26T11:05:08",
    "name": "[11/43] windbg: parsing data stream",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "0a78bffc8c6ffc0cf6527a788ac402637c3a71ff",
    "submitter": {
        "id": 71645,
        "url": "http://patchwork.ozlabs.org/api/people/71645/?format=api",
        "name": "Mikhail Abakumov",
        "email": "mikhail.abakumov@ispras.ru"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150642390797.3900.15056414492991775809.stgit@Misha-PC.lan02.inno/mbox/",
    "series": [
        {
            "id": 5104,
            "url": "http://patchwork.ozlabs.org/api/series/5104/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=5104",
            "date": "2017-09-26T11:04:06",
            "name": "Windbg supporting",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/5104/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/818549/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/818549/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y1dft6480z9tXP\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 21:15:49 +1000 (AEST)",
            "from localhost ([::1]:46744 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dwnq3-0004C4-9b\n\tfor incoming@patchwork.ozlabs.org; Tue, 26 Sep 2017 07:15:43 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:59245)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1dwng0-0003mQ-4R\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 07:05:24 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1dwnfq-0000VE-GT\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 07:05:20 -0400",
            "from mail.ispras.ru ([83.149.199.45]:51818)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1dwnfq-0000Tw-5t\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 07:05:10 -0400",
            "from Misha-PC.lan02.inno (unknown [85.142.117.226])\n\tby mail.ispras.ru (Postfix) with ESMTPSA id 71A5254009E;\n\tTue, 26 Sep 2017 14:05:09 +0300 (MSK)"
        ],
        "From": "Mihail Abakumov <mikhail.abakumov@ispras.ru>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Tue, 26 Sep 2017 14:05:08 +0300",
        "Message-ID": "<150642390797.3900.15056414492991775809.stgit@Misha-PC.lan02.inno>",
        "In-Reply-To": "<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>",
        "References": "<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>",
        "User-Agent": "StGit/0.17.1-dirty",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 3.x [fuzzy]",
        "X-Received-From": "83.149.199.45",
        "Subject": "[Qemu-devel] [PATCH 11/43] windbg: parsing data stream",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "sw@weilnetz.de, lprosek@redhat.com, dovgaluk@ispras.ru,\n\trkagan@virtuozzo.com, pbonzini@redhat.com, den@openvz.org",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "Added function of parsing data stream from windbg to packet.\n\nSigned-off-by: Mihail Abakumov <mikhail.abakumov@ispras.ru>\nSigned-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru>\nSigned-off-by: Dmitriy Koltunov <koltunov@ispras.ru>\n---\n windbgstub.c |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 110 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/windbgstub.c b/windbgstub.c\nindex 32984d0f92..7bc3585e53 100755\n--- a/windbgstub.c\n+++ b/windbgstub.c\n@@ -57,6 +57,105 @@ typedef struct WindbgState {\n \n static WindbgState *windbg_state;\n \n+static void windbg_ctx_handler(ParsingContext *ctx)\n+{}\n+\n+static void windbg_read_byte(ParsingContext *ctx, uint8_t byte)\n+{\n+    switch (ctx->state) {\n+    case STATE_LEADER:\n+        ctx->result = RESULT_NONE;\n+        if (byte == PACKET_LEADER_BYTE || byte == CONTROL_PACKET_LEADER_BYTE) {\n+            if (ctx->index > 0 && byte != PTR(ctx->packet.PacketLeader)[0]) {\n+                ctx->index = 0;\n+            }\n+            PTR(ctx->packet.PacketLeader)[ctx->index] = byte;\n+            ++ctx->index;\n+            if (ctx->index == sizeof(ctx->packet.PacketLeader)) {\n+                ctx->state = STATE_PACKET_TYPE;\n+                ctx->index = 0;\n+            }\n+        } else if (byte == BREAKIN_PACKET_BYTE) {\n+            ctx->result = RESULT_BREAKIN_BYTE;\n+            ctx->index = 0;\n+        } else {\n+            ctx->index = 0;\n+        }\n+        break;\n+\n+    case STATE_PACKET_TYPE:\n+        PTR(ctx->packet.PacketType)[ctx->index] = byte;\n+        ++ctx->index;\n+        if (ctx->index == sizeof(ctx->packet.PacketType)) {\n+            ctx->packet.PacketType = lduw_p(&ctx->packet.PacketType);\n+            if (ctx->packet.PacketType >= PACKET_TYPE_MAX) {\n+                ctx->state = STATE_LEADER;\n+                ctx->result = RESULT_UNKNOWN_PACKET;\n+            } else {\n+                ctx->state = STATE_PACKET_BYTE_COUNT;\n+            }\n+            ctx->index = 0;\n+        }\n+        break;\n+\n+    case STATE_PACKET_BYTE_COUNT:\n+        PTR(ctx->packet.ByteCount)[ctx->index] = byte;\n+        ++ctx->index;\n+        if (ctx->index == sizeof(ctx->packet.ByteCount)) {\n+            ctx->packet.ByteCount = lduw_p(&ctx->packet.ByteCount);\n+            ctx->state = STATE_PACKET_ID;\n+            ctx->index = 0;\n+        }\n+        break;\n+\n+    case STATE_PACKET_ID:\n+        PTR(ctx->packet.PacketId)[ctx->index] = byte;\n+        ++ctx->index;\n+        if (ctx->index == sizeof(ctx->packet.PacketId)) {\n+            ctx->packet.PacketId = ldl_p(&ctx->packet.PacketId);\n+            ctx->state = STATE_PACKET_CHECKSUM;\n+            ctx->index = 0;\n+        }\n+        break;\n+\n+    case STATE_PACKET_CHECKSUM:\n+        PTR(ctx->packet.Checksum)[ctx->index] = byte;\n+        ++ctx->index;\n+        if (ctx->index == sizeof(ctx->packet.Checksum)) {\n+            ctx->packet.Checksum = ldl_p(&ctx->packet.Checksum);\n+            if (ctx->packet.PacketLeader == CONTROL_PACKET_LEADER) {\n+                ctx->state = STATE_LEADER;\n+                ctx->result = RESULT_CONTROL_PACKET;\n+            } else if (ctx->packet.ByteCount > PACKET_MAX_SIZE) {\n+                ctx->state = STATE_LEADER;\n+                ctx->result = RESULT_ERROR;\n+            } else {\n+                ctx->state = STATE_PACKET_DATA;\n+            }\n+            ctx->index = 0;\n+        }\n+        break;\n+\n+    case STATE_PACKET_DATA:\n+        ctx->data.buf[ctx->index] = byte;\n+        ++ctx->index;\n+        if (ctx->index == ctx->packet.ByteCount) {\n+            ctx->state = STATE_TRAILING_BYTE;\n+            ctx->index = 0;\n+        }\n+        break;\n+\n+    case STATE_TRAILING_BYTE:\n+        if (byte == PACKET_TRAILING_BYTE) {\n+            ctx->result = RESULT_DATA_PACKET;\n+        } else {\n+            ctx->result = RESULT_ERROR;\n+        }\n+        ctx->state = STATE_LEADER;\n+        break;\n+    }\n+}\n+\n static int windbg_chr_can_receive(void *opaque)\n {\n     return PACKET_MAX_SIZE;\n@@ -64,8 +163,18 @@ static int windbg_chr_can_receive(void *opaque)\n \n static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size)\n {\n+    static ParsingContext ctx = {\n+        .state = STATE_LEADER,\n+        .result = RESULT_NONE,\n+        .name = \"\"\n+    };\n+\n     if (windbg_state->is_loaded) {\n-        /* T0D0: parse data */\n+        int i;\n+        for (i = 0; i < size; i++) {\n+            windbg_read_byte(&ctx, buf[i]);\n+            windbg_ctx_handler(&ctx);\n+        }\n     }\n }\n \n",
    "prefixes": [
        "11/43"
    ]
}