]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: version: make the version strings variables, not constants
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2019 07:44:55 +0000 (09:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2019 07:56:57 +0000 (09:56 +0200)
It currently is not possible to figure the exact haproxy version from a
core file for the sole reason that the version is stored into a const
string and as such ends up in the .text section that is not part of a
core file. By turning them into variables we move them to the data
section and they appear in core files. In order to help finding them,
we just prepend an extra variable in front of them and we're able to
immediately spot the version strings from a core file:

  $ strings core | fgrep -A2 'HAProxy version'
  HAProxy version follows
  2.1-dev2-e0f48a-88
  2019/10/15

(These are haproxy_version and haproxy_date respectively). This may be
backported to 2.0 since this part is not support to impact anything but
the developer's time spent debugging.

include/common/version.h
src/version.c

index 49427468c562f1e1bf131274d7ae608351ffe916..248c22e23872e18d9bec567e8d35a9f30083ce85 100644 (file)
@@ -66,9 +66,9 @@
 #error "Must define CONFIG_HAPROXY_DATE"
 #endif
 
-extern const char *haproxy_version;
-extern const char *haproxy_date;
-extern const char *stats_version_string;
+extern char haproxy_version[];
+extern char haproxy_date[];
+extern char stats_version_string[];
 
 #endif /* _COMMON_VERSION_H */
 
index f50f24beac26dd51b219f34a0b21483a9273f9ed..dae7b3df0d4b454d49790e4e9c80b28539104746 100644 (file)
@@ -6,6 +6,10 @@
 
 #include <common/version.h>
 
-const char *haproxy_version      = HAPROXY_VERSION;
-const char *haproxy_date         = HAPROXY_DATE;
-const char *stats_version_string = STATS_VERSION_STRING;
+/* These ones are made variables and not constants so that they are stored into
+ * the data region and prominently appear in core files.
+ */
+char haproxy_version_here[] = "HAProxy version follows";
+char haproxy_version[]      = HAPROXY_VERSION;
+char haproxy_date[]         = HAPROXY_DATE;
+char stats_version_string[] = STATS_VERSION_STRING;