From nobody Fri Apr 12 09:37:40 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VGBLX2Z0bz5H3yD; Fri, 12 Apr 2024 09:37:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VGBLX24xHz4Dvr; Fri, 12 Apr 2024 09:37:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712914660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8HpmlX2fZbDoeSw2lNfjG0VxXcTYpg7/jpra+KCAJaw=; b=Ig8gsuPqPherHfaB3+Uo2sNMt/VmcRW8t1kegFtG4xs7m15k2nn1N/9HyofISzzpW+B/gB jygVgtyBFXATiyqwwBP3XEGW6xFdqbqb+P8e5W8FRq06wrnpubdDPdYiAf6Xw74JQMf6G7 9dEZAJuU0k25xn3QuoQiAQqjVhuo3kcFXybDYLbCa7LbCxvqJi/EChzAbdFAPBHaQiPpiV IjJDc8A1xXV4GuAhLOxR9hq7EZY0pbvL7Pi45RPluh9eaQKwNO9FrVnqVWjVtVKHPjs61s ykS6JM+n6eqW9NqKWaDJuj6QSpenKoi2CBgvVerGKK7XWympAXjnHW1N6RRr6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712914660; a=rsa-sha256; cv=none; b=MhtynjuFu3ukY15J7g56zpM8JAz3rIvHqyVwAUi+mijeH+IlwXg3IJmXxDKiOj0q9yBCgb 7PTrcR863wF8wyodngiRI+OuH/NVMXE8iLrxT0EGTjzN/92dtUv/qadBeQ7l45RUNK4n09 HT5E0L0fqjyHjqRFKraIoRo3lEA3Pdl8K1g5Yo7+82hQTqK3wt2EUfXrztMyjZH8Plhfze 9Cr35vrMdN4MXswt5C7rzXcoxTem4YK3ZmRqjGrwfIWUjXb6fJ/HbaHAQisWAIngCAW33y PD3vtCtzVUwaeQaB+/GJRxcLEGIgBgbpsrpU7ohAJ6hCmOway6cjK04FeB4uig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712914660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8HpmlX2fZbDoeSw2lNfjG0VxXcTYpg7/jpra+KCAJaw=; b=F7DOi/Mo1UCmja8GuW/yMnDTVPLPCx1WfjAYWYZq4NrIQuIbjPHLQFUo1JwRfsJgBnxiIl /P7wAfpPqKAg3QvtAz4rfC3CnqVmXpB0nPApUmzjHGTKDUgOa5HIwac245QRNv6ihkL3wA qAj6QJiuuXGg8knFWBJ/5nh9e8TujKjAsjYdUiyaZarwv4eoFuInlDjahq+x6iaFX90e+u tC7ttNUQR3f7BvHDDbN/1ClToeIPynOlWD0hjLcysE1gyL6UVQW7Kv9UoNs0uhp1MaOtyj p306wHPCEPb08W9A3mOXaQBPpsyU95OmcerzErV0qeXBLoW8LSKutBOL3hkoOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VGBLX1hk9zksj; Fri, 12 Apr 2024 09:37:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43C9be6P096565; Fri, 12 Apr 2024 09:37:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43C9beDY096562; Fri, 12 Apr 2024 09:37:40 GMT (envelope-from git) Date: Fri, 12 Apr 2024 09:37:40 GMT Message-Id: <202404120937.43C9beDY096562@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: f4a6036a3a0d - main - ddb: Start to generalise breakpoints List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f4a6036a3a0d6749a435a4c8decfdb59c64ec619 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=f4a6036a3a0d6749a435a4c8decfdb59c64ec619 commit f4a6036a3a0d6749a435a4c8decfdb59c64ec619 Author: Andrew Turner AuthorDate: 2024-03-21 14:11:17 +0000 Commit: Andrew Turner CommitDate: 2024-04-12 09:29:13 +0000 ddb: Start to generalise breakpoints To allow for hardware breakpoints it is useful to reuse the same management code. Start to generalise the code by moving common data into a new struct and pas this to internal functions to work with. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D44461 --- sys/ddb/db_break.c | 92 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 35 deletions(-) diff --git a/sys/ddb/db_break.c b/sys/ddb/db_break.c index 91d927f03eaf..65045d909890 100644 --- a/sys/ddb/db_break.c +++ b/sys/ddb/db_break.c @@ -44,56 +44,74 @@ #include #include +struct db_breakpoint_type { + db_breakpoint_t db_next_free_breakpoint; + db_breakpoint_t db_breakpoint_limit; + db_breakpoint_t db_free_breakpoints; + db_breakpoint_t db_breakpoint_list; +}; + #define NBREAKPOINTS 100 static struct db_breakpoint db_break_table[NBREAKPOINTS]; -static db_breakpoint_t db_next_free_breakpoint = &db_break_table[0]; -static db_breakpoint_t db_free_breakpoints = 0; -static db_breakpoint_t db_breakpoint_list = 0; - -static db_breakpoint_t db_breakpoint_alloc(void); -static void db_breakpoint_free(db_breakpoint_t bkpt); -static void db_delete_breakpoint(vm_map_t map, db_addr_t addr); -static db_breakpoint_t db_find_breakpoint(vm_map_t map, db_addr_t addr); + +static struct db_breakpoint_type db_breakpoint = { + .db_next_free_breakpoint = &db_break_table[0], + .db_breakpoint_limit = &db_break_table[NBREAKPOINTS], + .db_free_breakpoints = NULL, + .db_breakpoint_list = NULL, +}; + +static db_breakpoint_t db_breakpoint_alloc( + struct db_breakpoint_type *bkpt_type); +static void db_breakpoint_free(struct db_breakpoint_type *bkpt_typ, + db_breakpoint_t bkpt); +static void db_delete_breakpoint(struct db_breakpoint_type *bkpt_type, + vm_map_t map, db_addr_t addr); +static db_breakpoint_t db_find_breakpoint(struct db_breakpoint_type *bkpt_type, + vm_map_t map, db_addr_t addr); static void db_list_breakpoints(void); -static void db_set_breakpoint(vm_map_t map, db_addr_t addr, int count); +static void db_set_breakpoint(struct db_breakpoint_type *bkpt_type, + vm_map_t map, db_addr_t addr, int count); static db_breakpoint_t -db_breakpoint_alloc(void) +db_breakpoint_alloc(struct db_breakpoint_type *bkpt_type) { register db_breakpoint_t bkpt; - if ((bkpt = db_free_breakpoints) != 0) { - db_free_breakpoints = bkpt->link; + if ((bkpt = bkpt_type->db_free_breakpoints) != 0) { + bkpt_type->db_free_breakpoints = bkpt->link; return (bkpt); } - if (db_next_free_breakpoint == &db_break_table[NBREAKPOINTS]) { + if (bkpt_type->db_next_free_breakpoint == + bkpt_type->db_breakpoint_limit) { db_printf("All breakpoints used.\n"); return (0); } - bkpt = db_next_free_breakpoint; - db_next_free_breakpoint++; + bkpt = bkpt_type->db_next_free_breakpoint; + bkpt_type->db_next_free_breakpoint++; return (bkpt); } static void -db_breakpoint_free(db_breakpoint_t bkpt) +db_breakpoint_free(struct db_breakpoint_type *bkpt_type, db_breakpoint_t bkpt) { - bkpt->link = db_free_breakpoints; - db_free_breakpoints = bkpt; + bkpt->link = bkpt_type->db_free_breakpoints; + bkpt_type->db_free_breakpoints = bkpt; } static void -db_set_breakpoint(vm_map_t map, db_addr_t addr, int count) +db_set_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, + db_addr_t addr, int count) { register db_breakpoint_t bkpt; - if (db_find_breakpoint(map, addr)) { + if (db_find_breakpoint(bkpt_type, map, addr)) { db_printf("Already set.\n"); return; } - bkpt = db_breakpoint_alloc(); + bkpt = db_breakpoint_alloc(bkpt_type); if (bkpt == 0) { db_printf("Too many breakpoints.\n"); return; @@ -105,17 +123,18 @@ db_set_breakpoint(vm_map_t map, db_addr_t addr, int count) bkpt->init_count = count; bkpt->count = count; - bkpt->link = db_breakpoint_list; - db_breakpoint_list = bkpt; + bkpt->link = bkpt_type->db_breakpoint_list; + bkpt_type->db_breakpoint_list = bkpt; } static void -db_delete_breakpoint(vm_map_t map, db_addr_t addr) +db_delete_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, + db_addr_t addr) { register db_breakpoint_t bkpt; register db_breakpoint_t *prev; - for (prev = &db_breakpoint_list; + for (prev = &bkpt_type->db_breakpoint_list; (bkpt = *prev) != 0; prev = &bkpt->link) { if (db_map_equal(bkpt->map, map) && @@ -129,15 +148,16 @@ db_delete_breakpoint(vm_map_t map, db_addr_t addr) return; } - db_breakpoint_free(bkpt); + db_breakpoint_free(bkpt_type, bkpt); } static db_breakpoint_t -db_find_breakpoint(vm_map_t map, db_addr_t addr) +db_find_breakpoint(struct db_breakpoint_type *bkpt_type, vm_map_t map, + db_addr_t addr) { register db_breakpoint_t bkpt; - for (bkpt = db_breakpoint_list; + for (bkpt = bkpt_type->db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { @@ -151,7 +171,7 @@ db_find_breakpoint(vm_map_t map, db_addr_t addr) db_breakpoint_t db_find_breakpoint_here(db_addr_t addr) { - return db_find_breakpoint(db_map_addr(addr), addr); + return db_find_breakpoint(&db_breakpoint, db_map_addr(addr), addr); } static bool db_breakpoints_inserted = true; @@ -175,7 +195,7 @@ db_set_breakpoints(void) register db_breakpoint_t bkpt; if (!db_breakpoints_inserted) { - for (bkpt = db_breakpoint_list; + for (bkpt = db_breakpoint.db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) if (db_map_current(bkpt->map)) { @@ -191,7 +211,7 @@ db_clear_breakpoints(void) register db_breakpoint_t bkpt; if (db_breakpoints_inserted) { - for (bkpt = db_breakpoint_list; + for (bkpt = db_breakpoint.db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) if (db_map_current(bkpt->map)) { @@ -209,13 +229,13 @@ db_list_breakpoints(void) { register db_breakpoint_t bkpt; - if (db_breakpoint_list == 0) { + if (db_breakpoint.db_breakpoint_list == 0) { db_printf("No breakpoints set\n"); return; } db_printf(" Map Count Address\n"); - for (bkpt = db_breakpoint_list; + for (bkpt = db_breakpoint.db_breakpoint_list; bkpt != 0; bkpt = bkpt->link) { db_printf("%s%8p %5d ", @@ -231,7 +251,8 @@ db_list_breakpoints(void) void db_delete_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) { - db_delete_breakpoint(db_map_addr(addr), (db_addr_t)addr); + db_delete_breakpoint(&db_breakpoint, db_map_addr(addr), + (db_addr_t)addr); } /* Set breakpoint with skip count */ @@ -242,7 +263,8 @@ db_breakpoint_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif) if (count == -1) count = 1; - db_set_breakpoint(db_map_addr(addr), (db_addr_t)addr, count); + db_set_breakpoint(&db_breakpoint, db_map_addr(addr), (db_addr_t)addr, + count); } /* list breakpoints */