Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seGD7-005TjC-IV for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 15:46:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1seGD6-00BEpu-5f for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 15:46:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seGD5-00BEpl-IM for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 15:46:51 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1seGD2-004ix5-3B for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 15:46:50 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2cf98ba0559so4709010a91.2 for ; Wed, 14 Aug 2024 08:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20230601.gappssmtp.com; s=20230601; t=1723650407; x=1724255207; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=g3RcmB5P3CFyA8Uor3+oJ1MhDphTUF28exlO+anymUo=; b=xZqvS/IsX+7ktSqtlXRUsUJrdzCP8zoknAjEtf1UMW4Hno3Ou0vsI3AB5W1OcJw4qL rqpw6pdXNAVVcQlEyceN2rt0Rhxi2o65NvPpFe5Mlu0hjTALtNkV7rLJwCeGKHPb6CRB k7kgLhJdnWCBTCXDTnYYCSYgMVP20XDMMKaGAGmriXSWKwR0yppDRIybPkbPPxRNZgCG /KY3t/lizQSdIMqCczXUWGm0WFEI4IOpsvs4KNJiWtALs1+RtFFeqjpLwd57TIGPzZuz bNm3H2nCFMVtaX4V6v+UtNKLBnaAzKasretzYYNslOIERzmsl/mGLbNchY789SPb1A2c D/lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723650407; x=1724255207; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g3RcmB5P3CFyA8Uor3+oJ1MhDphTUF28exlO+anymUo=; b=kw8iRixFw1ZEMC1R6ohT/rkJvYxMU6M/G3TOe9IViUpP+SrFy2VTE6JlH13AZNxOuX ZRT6Pv4Ydg3WL4VPH4LkZNWUvjwbbW8UTvOyTyk/0azYTvB/WdKFxhEa3gq8XaywREgY Dps6Iw2rYpmt8ICRnD9q/6RL71yog1i68Y/fOhvXmqUhg9rl9HABBeBf18+U1RTdkhIk EdLHHFuXr+24WZ6NcMUmRzQ6BF6Jd2bg2lNxAG8gf4tIVzdk/0KdJ0V0JbFn6uGPDgZu peRifZIoGA6QYXFDBjBgdUwXK516/AhhHA0Y9Q0/Ocb/MbP5nDd3poXBqL8NkOL9JGAU 9kxw== X-Forwarded-Encrypted: i=1; AJvYcCVrJ1xSs9CoJD0K9eNLW0i8+mThiWmUk5Qdk4WIrG0SjaNDUYc3Ty7/eAQvb79ZkWCR1Rxah+miVqNhfG5RIpFZGTcvim4n4v5fcTlh3YQvIfUW X-Gm-Message-State: AOJu0YxMeUHVZlQ6uhW42K59eCYv4bTEylcWDYcGbgrJoPKJp/bxW9tI pzMNQt7nSgqlSLJOKtc7yJMOWfhkMOWJ1F7rmx1RFLnjy5pWQdPNJn/+SkQXznw= X-Google-Smtp-Source: AGHT+IEXir9jpRBbjZqEsoAd47Ocntg0qamzRMpVYGwk3jEGfXi5M6iR1uMnwdiEXhHoZzRQz+kieQ== X-Received: by 2002:a17:90a:10d6:b0:2cd:3e75:4e51 with SMTP id 98e67ed59e1d1-2d3aab929bbmr3956068a91.39.1723650406641; Wed, 14 Aug 2024 08:46:46 -0700 (PDT) Received: from [192.168.2.139] ([50.39.255.79]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2d3ac7fb5c5sm1895615a91.32.2024.08.14.08.46.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Aug 2024 08:46:45 -0700 (PDT) Message-ID: <991fd3e7-f414-4320-8674-e9651ece1b4e@illuminatedcomputing.com> Date: Wed, 14 Aug 2024 08:46:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: format_datum debugging function To: Peter Eisentraut , Aleksander Alekseev , PostgreSQL Hackers References: <286814e4-46d4-44d6-be45-c2ee979021e1@illuminatedcomputing.com> <463c034f-a1bb-4361-ada7-83e994d86bfb@illuminatedcomputing.com> Content-Language: en-US From: Paul Jungwirth In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/14/24 02:16, Peter Eisentraut wrote: > On 12.08.24 23:15, Paul Jungwirth wrote: >> On 8/12/24 04:32, Aleksander Alekseev wrote: >>>> [...] This function takes a Datum and the appropriate out function, and returns a char *. So you >>>> can do this: >>>> >>>> (gdb) call format_datum(range_out, $1) >>>> $2 = 0x59162692d938 "[1,4)" >>>> >>>> I assume a patch like this doesn't need documentation. Does it need a test? Anything else? >>> >>> I think you forgot to attach the patch. Or is it just a proposal? >> >> Sorry, patch attached here. > > I don't think it's safe to call output functions at arbitrary points from a debugger.  But if you're > okay with that during development, say, then I think you could just call > OidOutputFunctionCall(F_RANGE_OUT, $1)? I assumed it wasn't safe everywhere (e.g. there is potentially a TOAST lookup), but for debugging a patch that's okay with me. Are you doing something to get macro expansion? I've never gotten my gdb to see #defines, although in theory this configure line should do it, right?: ./configure 'CFLAGS=-ggdb -Og -g3 -fno-omit-frame-pointer' --enable-tap-tests --enable-cassert --enable-debug --prefix=${HOME}/local I also tried -gdwarf and -gdwarf-4 and -gdwarf-5 (all still with -Og -g3). If it makes a difference, I'm attaching to a process: paul@tal:~/src/postgresql$ gdb -p 1175735 GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". Attaching to process 1175735 Reading symbols from /home/paul/local/bin/postgres... Reading symbols from /lib/x86_64-linux-gnu/libz.so.1... (No debugging symbols found in /lib/x86_64-linux-gnu/libz.so.1) Reading symbols from /lib/x86_64-linux-gnu/libm.so.6... Reading symbols from /usr/lib/debug/.build-id/a5/08ec5d8bf12fb7fd08204e0f87518e5cd0b102.debug... Reading symbols from /lib/x86_64-linux-gnu/libicui18n.so.70... (No debugging symbols found in /lib/x86_64-linux-gnu/libicui18n.so.70) Reading symbols from /lib/x86_64-linux-gnu/libicuuc.so.70... (No debugging symbols found in /lib/x86_64-linux-gnu/libicuuc.so.70) Reading symbols from /lib/x86_64-linux-gnu/libc.so.6... Reading symbols from /usr/lib/debug/.build-id/49/0fef8403240c91833978d494d39e537409b92e.debug... Reading symbols from /lib64/ld-linux-x86-64.so.2... Reading symbols from /usr/lib/debug/.build-id/41/86944c50f8a32b47d74931e3f512b811813b64.debug... Reading symbols from /lib/x86_64-linux-gnu/libstdc++.so.6... (No debugging symbols found in /lib/x86_64-linux-gnu/libstdc++.so.6) Reading symbols from /lib/x86_64-linux-gnu/libgcc_s.so.1... (No debugging symbols found in /lib/x86_64-linux-gnu/libgcc_s.so.1) Reading symbols from /lib/x86_64-linux-gnu/libicudata.so.70... (No debugging symbols found in /lib/x86_64-linux-gnu/libicudata.so.70) [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". 0x000079878e325dea in epoll_wait (epfd=7, events=0x573f0e475820, maxevents=1, timeout=-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30 30 ../sysdeps/unix/sysv/linux/epoll_wait.c: No such file or directory. (gdb) b range_in Breakpoint 1 at 0x573f0d9b5042: file rangetypes.c, line 91. (gdb) c Continuing. Breakpoint 1, range_in (fcinfo=0x7fff6d8fea90) at rangetypes.c:91 91 { (gdb) fin Run till exit from #0 range_in (fcinfo=0x7fff6d8fea90) at rangetypes.c:91 0x0000573f0da8c87e in InputFunctionCall (flinfo=0x7fff6d8feb20, str=0x573f0e47a258 "[3,5)", typioparam=3904, typmod=-1) at fmgr.c:1547 1547 result = FunctionCallInvoke(fcinfo); Value returned is $1 = 95928334988456 (gdb) call OidOutputFunctionCall(F_RANGE_OUT, $1) No symbol "F_RANGE_OUT" in current context. If I know the oid, then this works: (gdb) call OidOutputFunctionCall(3835, $1) $2 = 0x5f9be16ca4d8 "[3,5)" That is a big improvement, but still a little annoying. Thanks, -- Paul ~{:-) pj@illuminatedcomputing.com