gpdb
gpdb copied to clipboard
greenplum 6: --enable-debug doesn't seem to work
I am trying to debug greenplum 6.25.3, and for start I'm trying to build it with --enable-debug flag. From my point of view for debugging optimizations of code (-O3 flag for C code) should be turned off, but adding flag --enable-debug doesn't change that. Optimization with or without it is -O3. I have changed that part of code in configure file, and during build have encountered that error:
greenplum/old_tablespace_file_parser.c: In function ‘OldTablespaceFileParser_parse_file’:
greenplum/old_tablespace_file_parser.c:46:28: error: ‘__s’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
tokens[number_of_tokens] = strtok_r(token, "\n", &newline_position);
^
greenplum/old_tablespace_file_parser.c:32:1: note: ‘__s’ was declared here
parse_row(int current_row_index, OldTablespaceFileParser_Document *document, char row[MAX_ROW_LENGTH])
^~~~~~~~~
I am using gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3) for building. This error can be ignored if you get rid of -Werror=uninitialized flag in CFLAGS. This issue seems to be the case for most of previous 6.25.3 versions until 6.12.1. Didn't try lower versions. The question is: is this an intended behaviour that -O3 flag stays even if --enable-debug flag is present? And a second question is how to debug greenplum correctly? I'm not entirely sure yet that I'm diggin in the right direction.
enable-debug is not same as Optimization level. You need to pass CFLAGS or modify makefile.
Changing configure did same trick, but passing CFLAGS sure is a better option. But still how to debug greenplum correctly? Is changing optimization level a correct direction to start?
Hi, usually, I configure the Greenplum with the following commands.
CFLAGS="-Og -g3 -ggdb" ./configure --enable-debug ...
After building it, you can attach gdb to the server process.
But still how to debug greenplum correctly? Is changing optimization level a correct direction to start?
Not sure what do you mean by "debugging Greenplum correctly"? If you want to debug with gdb, then the above steps should be enough. If you want to use other debugging tools, you might need some other steps.
I didn't really mean that there is the one correct way to debug greenplum, but a convenient way, that is actually used widely. Thanks for the answer @higuoxing , maybe i will end up trying it your way, but I am not really used to gdb, so an alternative method would be appreciated.
I didn't really mean that there is the one correct way to debug greenplum, but a convenient way, that is actually used widely. Thanks for the answer @higuoxing , maybe i will end up trying it your way, but I am not really used to gdb, so an alternative method would be appreciated.
Which debugging tool do you prefer? I may help you set it up.
It seems like i have figured out how to debug on vscode, I'm still struggling with debugging authentication process (want to make an extension which includes usage of ClientAuthentication_hook). After a minute (approximately) of debugging an error keeps occuring, I suppose there is a timeout or something similar. I failed to find any variable that would fix that (or at least delay that error). Debugging of processes after authentication works fine atm.
Closing issue. If anyone interested: https://www.highgo.ca/2023/07/28/debugging-postgresql-on-a-remote-machine-with-visual-studio-code-a-step-by-step-guide/ This guide on debugging. Worked fine on greenplum with almost none changes. For debugging authentication just added pg_usleep for 20 sec in ClientAuthentication function. While pg_usleep is waiting, a process of postgress is created and one is able to attach to process through debugger. Not the best solution, but was enough for me.