From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6CAA03858C54 for ; Fri, 10 Mar 2023 10:01:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CAA03858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678442484; 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: in-reply-to:in-reply-to:references:references; bh=seyzn/DOW81I/lGyRPOp2uUcd1qrdyoCJUbSqeUTCF4=; b=UNy9QWnEThB0wQmp5oeASuBd1tPwKmgqd/mGSBeJ8ZbjllVmAWVaJuA3lLEuIM+rWKxhnr zrZIlN2vBkNTkscEkRS/HI63LfIabkZSFo++fu05pgkIXQk+UnzRhPQgLdEkjkiCYDbEqC lBMiaSai8WVoH1ZetX+nzlQmtxDZK18= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-H81V_RZ8PDWdqgoZUxI9eQ-1; Fri, 10 Mar 2023 05:01:22 -0500 X-MC-Unique: H81V_RZ8PDWdqgoZUxI9eQ-1 Received: by mail-wm1-f71.google.com with SMTP id k20-20020a05600c1c9400b003e2249bd2b4so1606691wms.5 for ; Fri, 10 Mar 2023 02:01:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678442481; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=seyzn/DOW81I/lGyRPOp2uUcd1qrdyoCJUbSqeUTCF4=; b=fFet4oCCDP/Q6u7QvyrjxD6NYLYs2MA/IJ1TMN9MiAhaZyo3CZ7N6d+y0EPrRO+cja uGnHdfvC8FhJYjv0eXDItzld8MTSJgWlIE6QWuuMdbtSPLctsD/MUJDv5qEl2LAZk2R2 B4iaJ4J3tRwa1u0qdcIDo8nVlQxkJ4Wi13HlELlqpkC0CAwoZ1vP6z8sZZOUjEk1XfzT P8JGcu35nKJzDDI423Fx804sGpN8R+9CIBhwQ2YvuCXIRStS6VFPLDCSqmAr9LJzQq5r Ur0t5aVOeaDjMwCdlLwMos0GilLlmXqo8r5GMdp/GmbtqZZ8u96bxjo5bHmL7HJXRJ6x YQDg== X-Gm-Message-State: AO0yUKV3pr8GtIod1XSand+v1rThnuLnu8l8PotDoH/eC+d4xHDKexcs mWeCZCK7inWND/wHJW3uHKOOvan2Z4W+pB+Lvy88U+yjZHXacXKk4ABfFFVpNRa6YzoQfy3Iltl sXGhXiZ3QBNw1aqkqHg5cXY5u4pJOmA== X-Received: by 2002:a05:600c:3107:b0:3dc:55d9:ec8 with SMTP id g7-20020a05600c310700b003dc55d90ec8mr1935444wmo.41.1678442481578; Fri, 10 Mar 2023 02:01:21 -0800 (PST) X-Google-Smtp-Source: AK7set+ahsbHGz1VlujD8HzVykmA2gxos0lw3cxJPYOf+/+yetsTqEdRArYEj7hPz7e9AWHtBCJ/yg== X-Received: by 2002:a05:600c:3107:b0:3dc:55d9:ec8 with SMTP id g7-20020a05600c310700b003dc55d90ec8mr1935426wmo.41.1678442481251; Fri, 10 Mar 2023 02:01:21 -0800 (PST) Received: from [192.168.0.45] (ip-94-112-225-44.bb.vodafone.cz. [94.112.225.44]) by smtp.gmail.com with ESMTPSA id k26-20020a7bc41a000000b003e21638c0edsm1622574wmi.45.2023.03.10.02.01.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Mar 2023 02:01:20 -0800 (PST) Message-ID: <1c58e1c4-8047-4b60-5800-5d6b4d4743d9@redhat.com> Date: Fri, 10 Mar 2023 11:01:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/1] gdb, breakpoint: add breakpoint location debugging logs To: Christina Schimpe , gdb-patches@sourceware.org References: <20230221090501.1487842-1-christina.schimpe@intel.com> <20230221090501.1487842-2-christina.schimpe@intel.com> From: Bruno Larsen In-Reply-To: <20230221090501.1487842-2-christina.schimpe@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 21/02/2023 10:05, Christina Schimpe via Gdb-patches wrote: > From: Mihails Strasuns > > Add new commands: > > set debug breakpoints on|off > show debug breakpoints > > This patch introduces new debugging information that prints > breakpoint location insertion and removal flow. > > The debug output looks like: > ~~~ > (gdb) set debug breakpoints on > (gdb) disassemble main > Dump of assembler code for function main: > 0x0000555555555129 <+0>: endbr64 > 0x000055555555512d <+4>: push %rbp > 0x000055555555512e <+5>: mov %rsp,%rbp > => 0x0000555555555131 <+8>: mov $0x0,%eax > 0x0000555555555136 <+13>: pop %rbp > 0x0000555555555137 <+14>: ret > End of assembler dump. > (gdb) break *0x0000555555555137 > Breakpoint 2 at 0x555555555137: file main.c, line 4. > [breakpoints] update_global_location_list: UGLL_MAY_INSERT > (gdb) c > Continuing. > [breakpoints] update_global_location_list: UGLL_INSERT > [breakpoints] insert_bp_location: bp_location (0x562881637fb0) at address 0x555555555137 in main at main.c:4 > [breakpoints] insert_bp_location: bp_location (0x56288179a4f0) at address 0x7ffff7fd37b5 > [breakpoints] insert_bp_location: bp_location (0x56288179ea60) at address 0x7ffff7fe509e > [breakpoints] insert_bp_location: bp_location (0x5628817184d0) at address 0x7ffff7fe63f4 <_dl_close_worker+2356> > [breakpoints] remove_breakpoint_1: bp_location (0x562881637fb0) due to regular remove at address 0x555555555137 in main at main.c:4 > [breakpoints] remove_breakpoint_1: bp_location (0x56288179a4f0) due to regular remove at address 0x7ffff7fd37b5 > [breakpoints] remove_breakpoint_1: bp_location (0x56288179ea60) due to regular remove at address 0x7ffff7fe509e > [breakpoints] remove_breakpoint_1: bp_location (0x5628817184d0) due to regular remove at address 0x7ffff7fe63f4 <_dl_close_worker+2356> > > Breakpoint 2, 0x0000555555555137 in main () at main.c:4 > 4 } > ~~~ > > Co-Authored-By: Christina Schimpe Other than a small nit, this looks ok to me, Reviewed-By: Bruno Larsen (please note that the rb tag is not enough for pushing). > --- > gdb/NEWS | 4 +++ > gdb/breakpoint.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ > gdb/doc/gdb.texinfo | 8 ++++++ > 3 files changed, 78 insertions(+) > > diff --git a/gdb/NEWS b/gdb/NEWS > index 75cd11b204e..f64e0a68c85 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -3,6 +3,10 @@ > > *** Changes since GDB 13 > > +* set debug breakpoints on|off > + show debug breakpoints > + Print additional debug messages about breakpoint insertion and removal. > + > * Multi-target feature configuration > > GDB now supports the individual configuration of remote targets' feature > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 0db3adaf916..1c8a05c6cbd 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -163,6 +163,8 @@ static bool bl_address_is_meaningful (bp_location *loc); > > static int find_loc_num_by_location (const bp_location *loc); > > +static std::string breakpoint_location_to_buffer (bp_location *bl); > + > /* update_global_location_list's modes of operation wrt to whether to > insert locations now. */ > enum ugll_insert_mode > @@ -198,6 +200,22 @@ enum ugll_insert_mode > UGLL_INSERT > }; > > +static const char * > +ugll_insert_mode_text (ugll_insert_mode insert_mode) > +{ > + switch (insert_mode) > + { > + case UGLL_DONT_INSERT: > + return "UGLL_DONT_INSERT"; > + case UGLL_MAY_INSERT: > + return "UGLL_MAY_INSERT"; > + case UGLL_INSERT: > + return "UGLL_INSERT"; > + } > + > + gdb_assert_not_reached ("must handle all enum values"); > +} > + > static void update_global_location_list (enum ugll_insert_mode); > > static void update_global_location_list_nothrow (enum ugll_insert_mode); > @@ -508,6 +526,19 @@ show_always_inserted_mode (struct ui_file *file, int from_tty, > value); > } > > +static bool debug_breakpoints = 0; s/0/false. -- Cheers, Bruno > + > +#define breakpoint_debug_printf(fmt, ...) \ > + debug_prefixed_printf_cond (debug_breakpoints, "breakpoints",fmt,\ > + ##__VA_ARGS__) > + > +static void > +show_debug_breakpoints (struct ui_file *file, int from_tty, > + struct cmd_list_element *c, const char *value) > +{ > + gdb_printf (file, _("Breakpoint location debugging is %s.\n"), value); > +} > + > /* See breakpoint.h. */ > > int > @@ -2710,6 +2741,11 @@ insert_bp_location (struct bp_location *bl, > if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update)) > return 0; > > + breakpoint_debug_printf ("bp_location (%s) at address %s %s", > + host_address_to_string (bl), > + paddress (bl->gdbarch, bl->address), > + breakpoint_location_to_buffer (bl).c_str ()); > + > /* Note we don't initialize bl->target_info, as that wipes out > the breakpoint location's shadow_contents if the breakpoint > is still inserted at that location. This in turn breaks > @@ -3270,6 +3306,8 @@ remove_breakpoints_inf (inferior *inf) > { > int val; > > + breakpoint_debug_printf ("remove_breakpoints_inf (%d)", inf->num); > + > for (bp_location *bl : all_bp_locations ()) > { > if (bl->pspace != inf->pspace) > @@ -3914,6 +3952,13 @@ detach_breakpoints (ptid_t ptid) > static int > remove_breakpoint_1 (struct bp_location *bl, enum remove_bp_reason reason) > { > + breakpoint_debug_printf ("bp_location (%s) due to %s at address %s %s", > + host_address_to_string (bl), > + (reason == REMOVE_BREAKPOINT > + ? "regular remove" : "detach"), > + paddress (bl->gdbarch, bl->address), > + breakpoint_location_to_buffer (bl).c_str ()); > + > int val; > > /* BL is never in moribund_locations by our callers. */ > @@ -6216,6 +6261,16 @@ print_breakpoint_location (const breakpoint *b, > } > } > > +static std::string > +breakpoint_location_to_buffer (bp_location *bl) > +{ > + string_file stb; > + current_uiout->redirect (&stb); > + print_breakpoint_location (bl->owner, bl); > + current_uiout->redirect (nullptr); > + return stb.string (); > +} > + > static const char * > bptype_string (enum bptype type) > { > @@ -11146,6 +11201,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode) > /* Last breakpoint location program space that was marked for update. */ > int last_pspace_num = -1; > > + breakpoint_debug_printf ("%s", ugll_insert_mode_text (insert_mode)); > + > /* Used in the duplicates detection below. When iterating over all > bp_locations, points to the first bp_location of a given address. > Breakpoints and watchpoints of different types are never > @@ -14876,6 +14933,15 @@ when execution stops."), > &breakpoint_set_cmdlist, > &breakpoint_show_cmdlist); > > + add_setshow_boolean_cmd ("breakpoints", class_maintenance, > + &debug_breakpoints, _("\ > +Set breakpoint location debugging."), _("\ > +Show breakpoint location debugging."), _("\ > +When non-zero, breakpoint location specific debugging is enabled."), > + NULL, > + show_debug_breakpoints, > + &setdebuglist, &showdebuglist); > + > add_setshow_enum_cmd ("condition-evaluation", class_breakpoint, > condition_evaluation_enums, > &condition_evaluation_mode_1, _("\ > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 2a2077c29d1..cf33bd351b1 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -28272,6 +28272,14 @@ debugging info. > Turn on or off debugging messages for built-in XML parsers. > @item show debug xml > Displays the current state of XML debugging messages. > + > +@item set debug breakpoints > +@cindex breakpoint debugging info > +Turns on or off display of @value{GDBN} debugging info for breakpoint insertion > +and removal. The default is off. > +@item show debug breakpoints > +Displays the current state of displaying @value{GDBN} debugging info for > +breakpoint insertion and removal. > @end table > > @node Other Misc Settings