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 091E4385843A for ; Wed, 6 Mar 2024 12:59:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 091E4385843A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 091E4385843A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709729992; cv=none; b=yAfKNxBREaJew9Q0DIR6L4tDhwDBmDx5xQlV7+GmOEz1viox4b6KJNxcffszKKwb1e9Lu46qHz/d/dvOEKrXBTSCCd3gzy+rWqscTnzYEk5dxDJ1vVqma95wNy9pVY6QPqsqC89mEYDPzp+/vPRrTV3m66gMWboSoZQdRpodP2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709729992; c=relaxed/simple; bh=MwAcKT8vGiueyW0/TvKtuwhZH0zq0Jce2WkcrpWReG0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=EDAVAlE9D4N635oaAwdoPlz1+dLMlG8U5/t5bUofMHw4ssenlZPm/ZymDwF32RCS/hTLkENjmfcb7f59PS3CZJh99oHor+8bxKbr7vA9F76wD+jOFEa5PoLXc7nIH42ZS99gmhYE7GSN5P2NvQ9ck/bNan/8PONf6tEqg5NOSYA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709729989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xl6UgE5Mtz0HuYQl8gg58fATQChkBGrZtTNj0Q7hZoQ=; b=TugLdDTxl+CjizTSIlZpyyfTjlEH0FMaT5iTMnCGLJm0oPrt7YAiUJ1dt/WA4D5Jjkopoc G0CQ8J7uFR+aLLsH0ZAT/pGhwgF+7vqLaDUBtijXhSOnk/zHiiysCzKQi+aQZ7CWDzQjt1 RgZDGj5tUavuunZXV2WtW/g4ZEOmDtI= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-226-lOvbPH4PN8KggVLrTKr2RA-1; Wed, 06 Mar 2024 07:59:48 -0500 X-MC-Unique: lOvbPH4PN8KggVLrTKr2RA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-33d30a3d6f8so2537276f8f.3 for ; Wed, 06 Mar 2024 04:59:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709729987; x=1710334787; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Xl6UgE5Mtz0HuYQl8gg58fATQChkBGrZtTNj0Q7hZoQ=; b=f0wvqdxHV9Ap6qzMQX/G4EjfC6kBREkq/BSEdbygXAcld/8N7EWwgmj3HxLLaHEFJT emsboL4KwekDbnGdL/k3YEaOIJokcRAbX/HDNWuZy19aETvy59SHQEdC9yj6aC+HV9Hy 6Y3DJX8wSyal124vtgtiY0BWoPuE0x1wYgy5oIdK1kRISxM+uuR5xsHDs/+FKfroE4oR +R6uva+1y/5wLfzi3rhAxZ1d76w3fo/L4fOWuFK7Vb1juH60a4xFik/+Y6Yp98u0ykDo eIRsHNPK42dxEN9m7AwiSJxJWDsR+bzkvrjU2po5+alpNtv/3MlQ4981PLibvAkopqLG uJhA== X-Gm-Message-State: AOJu0Yyk5dmYnymenjNd1liuQB6X3/8zhGP3F94pr4CZU4PAyDgD2nyr /5aRFuUfMOfb0Vq88dT68vif/jFP7hjT063afegKt1ZedsTlh57EdEDH/7gljEjqTWvdsKPVqWJ t+IFA9H4qArcj2AsTLQ8BtId5Ist6tER1shcibXwwhBhOTs9aAsiVMFTNg2UG3BRMEjjgPqa079 yMr1PaISwP1ML32tNU/5U99tOadhf0k1H8jxI0lksy1A== X-Received: by 2002:a05:6000:90d:b0:33d:4fca:b7dc with SMTP id cw13-20020a056000090d00b0033d4fcab7dcmr10570084wrb.62.1709729986906; Wed, 06 Mar 2024 04:59:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEed5rL96LdSy20CmNreGgxpJ8SYWzJhSB2EEXxGgY2C5o4d5apU5jC3bmS5EB+CpCV2VcJaQ== X-Received: by 2002:a05:6000:90d:b0:33d:4fca:b7dc with SMTP id cw13-20020a056000090d00b0033d4fcab7dcmr10570069wrb.62.1709729986339; Wed, 06 Mar 2024 04:59:46 -0800 (PST) Received: from [192.168.0.129] (ip-94-112-227-180.bb.vodafone.cz. [94.112.227.180]) by smtp.gmail.com with ESMTPSA id cc4-20020a5d5c04000000b0033e45e4f22bsm5771224wrb.73.2024.03.06.04.59.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Mar 2024 04:59:45 -0800 (PST) Message-ID: <79f52395-c808-4773-ba08-1225f18bdeda@redhat.com> Date: Wed, 6 Mar 2024 13:59:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PING][PATCH] gdb: Change "list ." command's error when no debuginfo is available From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Simon Marchi References: <20240213143624.140852-1-blarsen@redhat.com> In-Reply-To: <20240213143624.140852-1-blarsen@redhat.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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: On 13/02/2024 15:36, Guinevere Larsen wrote: > From: Simon Marchi > > Currently, when a user tries to list the current location, there are 2 > different error messages that can happen, either: > > (gdb) list . > No symbol table is loaded. Use the "file" command. > or > (gdb) list . > No debug information available to print source lines. > > The difference here is if gdb can find any symtabs at all or not, which > is not a difference a user should concern themselves with. This commit > changes it so that the error is always: > > (gdb) list . > No debug information available to print source lines at current PC (0x55555555511d). > or > (gdb) list . > No debug information available to print source lines at default location. > > The difference now is if the inferior has started already, which is > controlled by the user and may be useful. > > Unfortunately, it isn't as easy to differentiate if the symtab found for > other list parameters is correct, so other invocations, such as "list +" > still retain their original error message. > > Co-Authored-By: Simon Marchi Ping! I apparently made Simon both the author and co-author oops. One of those 2 would have my info instead, I don't really mind which. -- Cheers, Guinevere Larsen She/Her/Hers > --- > gdb/cli/cli-cmds.c | 48 ++++++++++++++++++++++++++++++++-------------- > 1 file changed, 34 insertions(+), 14 deletions(-) > > diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c > index df11f956245..31f0b6d9907 100644 > --- a/gdb/cli/cli-cmds.c > +++ b/gdb/cli/cli-cmds.c > @@ -1236,37 +1236,39 @@ list_command (const char *arg, int from_tty) > /* Pull in the current default source line if necessary. */ > if (arg == NULL || ((arg[0] == '+' || arg[0] == '-' || arg[0] == '.') && arg[1] == '\0')) > { > - set_default_source_symtab_and_line (); > - symtab_and_line cursal = get_current_source_symtab_and_line (); > - > /* If this is the first "list" since we've set the current > source line, center the listing around that line. */ > if (get_first_line_listed () == 0 && (arg == nullptr || arg[0] != '.')) > { > - list_around_line (arg, cursal); > + set_default_source_symtab_and_line (); > + list_around_line (arg, get_current_source_symtab_and_line ()); > } > > /* "l" and "l +" lists the next few lines, unless we're listing past > the end of the file. */ > else if (arg == nullptr || arg[0] == '+') > { > + set_default_source_symtab_and_line (); > + const symtab_and_line cursal = get_current_source_symtab_and_line (); > if (last_symtab_line (cursal.symtab) >= cursal.line) > print_source_lines (cursal.symtab, > source_lines_range (cursal.line), 0); > else > - { > - error (_("End of the file was already reached, use \"list .\" to" > - " list the current location again")); > - } > + error (_("End of the file was already reached, use \"list .\" to" > + " list the current location again")); > } > > /* "l -" lists previous ten lines, the ones before the ten just > listed. */ > else if (arg[0] == '-') > { > + set_default_source_symtab_and_line (); > + const symtab_and_line cursal = get_current_source_symtab_and_line (); > + > if (get_first_line_listed () == 1) > error (_("Already at the start of %s."), > symtab_to_filename_for_display (cursal.symtab)); > + > source_lines_range range (get_first_line_listed (), > source_lines_range::BACKWARD); > print_source_lines (cursal.symtab, range, 0); > @@ -1275,25 +1277,43 @@ list_command (const char *arg, int from_tty) > /* "list ." lists the default location again. */ > else if (arg[0] == '.') > { > + std::optional cursal; > if (target_has_stack ()) > { > /* Find the current line by getting the PC of the currently > selected frame, and finding the line associated to it. */ > frame_info_ptr frame = get_selected_frame (nullptr); > CORE_ADDR curr_pc = get_frame_pc (frame); > - cursal = find_pc_line (curr_pc, 0); > + cursal.emplace (find_pc_line (curr_pc, 0)); > + > + if (cursal->symtab == nullptr) > + error > + (_("No debug information available to print source lines at " > + "current PC (%s)."), paddress (get_frame_arch (frame), > + curr_pc)); > } > else > { > /* The inferior is not running, so reset the current source > location to the default (usually the main function). */ > clear_current_source_symtab_and_line (); > - set_default_source_symtab_and_line (); > - cursal = get_current_source_symtab_and_line (); > + try > + { > + set_default_source_symtab_and_line (); > + } > + catch (const gdb_exception &e) > + { > + error (_("No debug information available to print source " > + "lines at default location")); > + } > + cursal.emplace (get_current_source_symtab_and_line ()); > + > + // Not sure if always true, just guessing. > + gdb_assert (cursal->symtab != nullptr); > } > - if (cursal.symtab == nullptr) > - error (_("No debug information available to print source lines.")); > - list_around_line (arg, cursal); > + > + list_around_line (arg, *cursal); > + > /* Set the repeat args so just pressing "enter" after using "list ." > will print the following lines instead of the same lines again. */ > if (from_tty)