From 224a00949a322e569714b2023d2f768be3de6572 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 9 Feb 2023 13:39:10 -0800 Subject: [PATCH] pbot-vm: guest-gdb: fix potential undefined `$start` when optimizations are enabled --- applets/pbot-vm/guest/bin/guest-gdb | 12 ++++++++++-- lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/applets/pbot-vm/guest/bin/guest-gdb b/applets/pbot-vm/guest/bin/guest-gdb index 07490996..b026de0d 100755 --- a/applets/pbot-vm/guest/bin/guest-gdb +++ b/applets/pbot-vm/guest/bin/guest-gdb @@ -292,8 +292,16 @@ sub get_main_start_end($context) { my ($line, $code) = split /\t/, $output->{_text}; - # this line isn't part of main() yet - next if $line < $start; + if (not defined $start) { + # info functions didn't work, try to find main + if ($code =~ /main\s*\(/) { + $start = $line; + } + next; + } else { + # this line isn't part of main() yet + next if $line < $start; + } # blank out contents of string and char literals so we don't count # any braces within diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index a78b513e..03554351 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4616, - BUILD_DATE => "2023-02-02", + BUILD_REVISION => 4617, + BUILD_DATE => "2023-02-09", }; sub initialize {}