From nobody Sun Feb 8 23:48:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496756982542112.11920375148532; Tue, 6 Jun 2017 06:49:42 -0700 (PDT) Received: from localhost ([::1]:38520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIErc-0005Dc-1z for importer@patchew.org; Tue, 06 Jun 2017 09:49:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIEpq-0004AW-QU for qemu-devel@nongnu.org; Tue, 06 Jun 2017 09:47:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIEpl-00006B-Ua for qemu-devel@nongnu.org; Tue, 06 Jun 2017 09:47:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIEpl-00005f-Ma for qemu-devel@nongnu.org; Tue, 06 Jun 2017 09:47:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4591A334583 for ; Tue, 6 Jun 2017 13:47:44 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-106.ams2.redhat.com [10.36.116.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id D06435C3FD; Tue, 6 Jun 2017 13:47:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B791980DA8; Tue, 6 Jun 2017 15:47:38 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4591A334583 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4591A334583 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 15:47:36 +0200 Message-Id: <20170606134736.26080-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 06 Jun 2017 13:47:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] keymaps: add tracing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Drop commented debug logging, add trace points instead. Also cleanup parser code a bit, the key name is copied into a new variable instead of patching the input line, that way we can log the unmodified line. Signed-off-by: Gerd Hoffmann --- ui/keymaps.c | 33 ++++++++++++++++++--------------- ui/trace-events | 5 +++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ui/keymaps.c b/ui/keymaps.c index 8899a0b31e..fa00b82027 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "keymaps.h" #include "sysemu/sysemu.h" +#include "trace.h" =20 static int get_keysym(const name2keysym_t *table, const char *name) @@ -71,18 +72,14 @@ static void add_to_key_range(struct key_range **krp, in= t code) { =20 static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *= k) { if (keysym < MAX_NORMAL_KEYCODE) { - /* fprintf(stderr,"Setting keysym %s (%d) to %d\n", - line, keysym, keycode); */ + trace_keymap_add("normal", keysym, keycode, line); k->keysym2keycode[keysym] =3D keycode; } else { if (k->extra_count >=3D MAX_EXTRA_COUNT) { fprintf(stderr, "Warning: Could not assign keysym %s (0x%x)" " because of memory constraints.\n", line, keysym); } else { -#if 0 - fprintf(stderr, "Setting %d: %d,%d\n", - k->extra_count, keysym, keycode); -#endif + trace_keymap_add("extra", keysym, keycode, line); k->keysym2keycode_extra[k->extra_count]. keysym =3D keysym; k->keysym2keycode_extra[k->extra_count]. @@ -99,9 +96,11 @@ static kbd_layout_t *parse_keyboard_layout(const name2ke= ysym_t *table, FILE *f; char * filename; char line[1024]; + char keyname[64]; int len; =20 filename =3D qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language); + trace_keymap_parse(filename); f =3D filename ? fopen(filename, "r") : NULL; g_free(filename); if (!f) { @@ -130,18 +129,21 @@ static kbd_layout_t *parse_keyboard_layout(const name= 2keysym_t *table, if (!strncmp(line, "include ", 8)) { parse_keyboard_layout(table, line + 8, k); } else { - char *end_of_keysym =3D line; - while (*end_of_keysym !=3D 0 && *end_of_keysym !=3D ' ') { - end_of_keysym++; + int offset =3D 0; + while (line[offset] !=3D 0 && + line[offset] !=3D ' ' && + offset < sizeof(keyname) - 1) { + keyname[offset] =3D line[offset]; + offset++; } - if (*end_of_keysym) { + keyname[offset] =3D 0; + if (strlen(keyname)) { int keysym; - *end_of_keysym =3D 0; - keysym =3D get_keysym(table, line); + keysym =3D get_keysym(table, keyname); if (keysym =3D=3D 0) { /* fprintf(stderr, "Warning: unknown keysym %s\n", lin= e);*/ } else { - const char *rest =3D end_of_keysym + 1; + const char *rest =3D line + offset + 1; int keycode =3D strtol(rest, NULL, 0); =20 if (strstr(rest, "numlock")) { @@ -165,10 +167,10 @@ static kbd_layout_t *parse_keyboard_layout(const name= 2keysym_t *table, =20 if (strstr(rest, "addupper")) { char *c; - for (c =3D line; *c; c++) { + for (c =3D keyname; *c; c++) { *c =3D qemu_toupper(*c); } - keysym =3D get_keysym(table, line); + keysym =3D get_keysym(table, keyname); if (keysym) { add_keysym(line, keysym, keycode | SCANCODE_SHIFT, k); @@ -194,6 +196,7 @@ int keysym2scancode(void *kbd_layout, int keysym) kbd_layout_t *k =3D kbd_layout; if (keysym < MAX_NORMAL_KEYCODE) { if (k->keysym2keycode[keysym] =3D=3D 0) { + trace_keymap_unmapped(keysym); fprintf(stderr, "Warning: no scancode found for keysym %d\n", keysym); } diff --git a/ui/trace-events b/ui/trace-events index 93fe5482e6..19ce5f85f6 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -46,3 +46,8 @@ qemu_spice_create_primary_surface(int qid, uint32_t sid, = void *surface, int asyn qemu_spice_destroy_primary_surface(int qid, uint32_t sid, int async) "%d s= id=3D%u async=3D%d" qemu_spice_wakeup(uint32_t qid) "%d" qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint= 32_t bottom) "lr %d -> %d, tb -> %d -> %d" + +# ui/keymaps.c +keymap_parse(const char *file) "file %s" +keymap_add(const char *type, int sym, int code, const char *line) "%-6s sy= m=3D0x%04x code=3D0x%04x (line: %s)" +keymap_unmapped(int sym) "sym=3D0x%04x" --=20 2.9.3