From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by sourceware.org (Postfix) with ESMTPS id 6C76E3858D3C for ; Mon, 16 May 2022 18:40:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C76E3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f42.google.com with SMTP id n6-20020a05600c3b8600b0039492b44ce7so82895wms.5 for ; Mon, 16 May 2022 11:40:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gLnhD7cBUh971HLm5fmQHq9C01nl+n3VMYqHUMtfDsI=; b=AeOXiRONB1pcC5V7M3PSj1zOV8ciSZ3lXWvwp+Vf93yQKMrQ7paQCjMr9QiGNxVtos dm+ow5eWBfOkWoytz96qYqig95pei+2C4tYPZvenK71+FOmXsVaIWsrnwhvpJexUYYQm o8aDt5JsFyOkS6MnzmtB5gMxyobw0uxV3UBB11keKTvT459VbyPr7JDjvzZkWlDoKQio nxBgBJ7mbtJgC9qn9Jp7HHZFs9EhsmerrrPdnbdcvOO1QWNX3nJ761h/V8yxX7SiyJkY 3K55L5h/nkoR29iUFOTAGC/+a0hD1bBNPKDbj/awV846Mr2SzOrgxOhSHgJLIvJX2x1S 9VQw== X-Gm-Message-State: AOAM532ogf5MRRCoTfSMxVpDeY2a5A1uQTsD/sNSZfqDL3wC4qZ9jddZ uWLHnidwi64pHmBs60i/TkmSIzzBrak= X-Google-Smtp-Source: ABdhPJxwMVQTH3+C/5B4eooBnkA+yH9X6xtSAYz0uETpnOJ3P9H6laaOHOVXkLe9O8uNs6QuSu5cbg== X-Received: by 2002:a05:600c:1e83:b0:395:b8e8:d256 with SMTP id be3-20020a05600c1e8300b00395b8e8d256mr18030413wmb.134.1652726434646; Mon, 16 May 2022 11:40:34 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id l20-20020a1ced14000000b003942a244ee4sm15082wmh.41.2022.05.16.11.40.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 May 2022 11:40:33 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 01/23] add_location_to_breakpoint -> breakpoint::add_location Date: Mon, 16 May 2022 19:40:08 +0100 Message-Id: <20220516184030.665489-2-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220516184030.665489-1-pedro@palves.net> References: <20220516184030.665489-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 18:40:38 -0000 Make add_location_to_breakpoint be a method of struct breakpoint. A patch later in the series will move this to base_breakpoint, but for now, it needs to be here. Change-Id: I5bdc2ec1a7c2d66f26f51bf6f6adc8384a90b129 --- gdb/breakpoint.c | 70 +++++++++++++++++++++++------------------------- gdb/breakpoint.h | 3 +++ 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9abc1443d96..385c92a6e7b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -114,9 +114,6 @@ static void mention (const breakpoint *); static struct breakpoint *set_raw_breakpoint_without_location (struct gdbarch *, enum bptype); -static struct bp_location *add_location_to_breakpoint (struct breakpoint *, - const struct symtab_and_line *); - /* This function is used in gdbtk sources and thus can not be made static. */ static struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch, @@ -7308,7 +7305,7 @@ static void init_raw_breakpoint (struct breakpoint *b, struct symtab_and_line sal, enum bptype bptype) { - add_location_to_breakpoint (b, &sal); + b->add_location (sal); if (bptype != bp_catchpoint) gdb_assert (sal.pspace != NULL); @@ -8109,16 +8106,15 @@ handle_automatic_hardware_breakpoints (bp_location *bl) } } -static struct bp_location * -add_location_to_breakpoint (struct breakpoint *b, - const struct symtab_and_line *sal) +bp_location * +breakpoint::add_location (const symtab_and_line &sal) { - struct bp_location *loc, **tmp; + struct bp_location *new_loc, **tmp; CORE_ADDR adjusted_address; - struct gdbarch *loc_gdbarch = get_sal_arch (*sal); + struct gdbarch *loc_gdbarch = get_sal_arch (sal); if (loc_gdbarch == NULL) - loc_gdbarch = b->gdbarch; + loc_gdbarch = gdbarch; /* Adjust the breakpoint's address prior to allocating a location. Once we call allocate_location(), that mostly uninitialized @@ -8127,31 +8123,31 @@ add_location_to_breakpoint (struct breakpoint *b, not want its scan of the location chain to find a breakpoint and location that's only been partially initialized. */ adjusted_address = adjust_breakpoint_address (loc_gdbarch, - sal->pc, b->type); + sal.pc, type); /* Sort the locations by their ADDRESS. */ - loc = b->allocate_location (); - for (tmp = &(b->loc); *tmp != NULL && (*tmp)->address <= adjusted_address; + new_loc = allocate_location (); + for (tmp = &(loc); *tmp != NULL && (*tmp)->address <= adjusted_address; tmp = &((*tmp)->next)) ; - loc->next = *tmp; - *tmp = loc; - - loc->requested_address = sal->pc; - loc->address = adjusted_address; - loc->pspace = sal->pspace; - loc->probe.prob = sal->prob; - loc->probe.objfile = sal->objfile; - gdb_assert (loc->pspace != NULL); - loc->section = sal->section; - loc->gdbarch = loc_gdbarch; - loc->line_number = sal->line; - loc->symtab = sal->symtab; - loc->symbol = sal->symbol; - loc->msymbol = sal->msymbol; - loc->objfile = sal->objfile; - - set_breakpoint_location_function (loc); + new_loc->next = *tmp; + *tmp = new_loc; + + new_loc->requested_address = sal.pc; + new_loc->address = adjusted_address; + new_loc->pspace = sal.pspace; + new_loc->probe.prob = sal.prob; + new_loc->probe.objfile = sal.objfile; + gdb_assert (new_loc->pspace != NULL); + new_loc->section = sal.section; + new_loc->gdbarch = loc_gdbarch; + new_loc->line_number = sal.line; + new_loc->symtab = sal.symtab; + new_loc->symbol = sal.symbol; + new_loc->msymbol = sal.msymbol; + new_loc->objfile = sal.objfile; + + set_breakpoint_location_function (new_loc); /* While by definition, permanent breakpoints are already present in the code, we don't mark the location as inserted. Normally one would expect @@ -8166,10 +8162,10 @@ add_location_to_breakpoint (struct breakpoint *b, (If GDB later needs to continue execution past the permanent breakpoint, it manually increments the PC, thus avoiding executing the breakpoint instruction.) */ - if (bp_loc_is_permanent (loc)) - loc->permanent = 1; + if (bp_loc_is_permanent (new_loc)) + new_loc->permanent = 1; - return loc; + return new_loc; } @@ -8375,7 +8371,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, } else { - loc = add_location_to_breakpoint (b, &sal); + loc = b->add_location (sal); if ((flags & CREATE_BREAKPOINT_FLAGS_INSERTED) != 0) loc->inserted = 1; } @@ -12646,7 +12642,7 @@ update_breakpoint_locations (struct breakpoint *b, switch_to_program_space_and_thread (sal.pspace); - new_loc = add_location_to_breakpoint (b, &sal); + new_loc = b->add_location (sal); /* Reparse conditions, they might contain references to the old symtab. */ @@ -13537,7 +13533,7 @@ insert_single_step_breakpoint (struct gdbarch *gdbarch, sal.pc = pc; sal.section = find_pc_overlay (pc); sal.explicit_pc = 1; - add_location_to_breakpoint (tp->control.single_step_breakpoints, &sal); + tp->control.single_step_breakpoints->add_location (sal); update_global_location_list (UGLL_INSERT); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index ac738fd7c2d..fb8651c55c3 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -739,6 +739,9 @@ struct breakpoint /* Nothing to do. */ } + /* Add a location for SAL to this breakpoint. */ + bp_location *add_location (const symtab_and_line &sal); + /* Return a range of this breakpoint's locations. */ bp_location_range locations () const; -- 2.36.0