-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,545 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# gdbpg.py contains scripts to nicely print the postgres datastructures | ||
# while in a gdb session. Since the vscode debugger is based on gdb this | ||
# actually also works when debugging with vscode. Providing nice tools | ||
# to understand the internal datastructures we are working with. | ||
source /root/gdbpg.py | ||
|
||
# when debugging postgres it is convenient to _always_ have a breakpoint | ||
# trigger when an error is logged. Because .gdbinit is sourced before gdb | ||
# is fully attached and has the sources loaded. To make sure the breakpoint | ||
# is added when the library is loaded we temporary set the breakpoint pending | ||
# to on. After we have added out breakpoint we revert back to the default | ||
# configuration for breakpoint pending. | ||
# The breakpoint is hard to read, but at entry of the function we don't have | ||
# the level loaded in elevel. Instead we hardcode the location where the | ||
# level of the current error is stored. Also gdb doesn't understand the | ||
# ERROR symbol so we hardcode this to the value of ERROR. It is very unlikely | ||
# this value will ever change in postgres, but if it does we might need to | ||
# find a way to conditionally load the correct breakpoint. | ||
set breakpoint pending on | ||
break elog.c:errfinish if errordata[errordata_stack_depth].elevel == 21 | ||
set breakpoint pending auto | ||
|
||
echo \n | ||
echo ----------------------------------------------------------------------------------\n | ||
echo when attaching to a postgres backend a breakpoint will be set on elog.c:errfinish \n | ||
echo it will only break on errors being raised in postgres \n | ||
echo \n | ||
echo to disable this breakpoint from vscode run `-exec disable 1` in the debug console \n | ||
echo this assumes it's the first breakpoint loaded as it is loaded from .gdbinit \n | ||
echo this can be verified with `-exec info break`, enabling can be done with \n | ||
echo `-exec enable 1` \n | ||
echo ----------------------------------------------------------------------------------\n | ||
echo \n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
postgresql-*.tar.bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
\timing on | ||
\pset linestyle unicode | ||
\pset border 2 | ||
\setenv PAGER 'pspg --no-mouse -bX --no-commandbar --no-topbar' | ||
\set HISTSIZE 100000 | ||
\set PROMPT1 '\n%[%033[1m%]%M %n@%/:%> (PID: %p)%R%[%033[0m%]%# ' | ||
\set PROMPT2 ' ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
docopt = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.9" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#! /usr/bin/env pipenv-shebang | ||
"""Generate C/C++ properties file for VSCode. | ||
Uses pgenv to iterate postgres versions and generate | ||
a C/C++ properties file for VSCode containing the | ||
include paths for the postgres headers. | ||
Usage: | ||
generate_c_cpp_properties-json.py <target_path> | ||
generate_c_cpp_properties-json.py (-h | --help) | ||
generate_c_cpp_properties-json.py --version | ||
Options: | ||
-h --help Show this screen. | ||
--version Show version. | ||
""" | ||
import json | ||
import subprocess | ||
|
||
from docopt import docopt | ||
|
||
|
||
def main(args): | ||
target_path = args['<target_path>'] | ||
|
||
output = subprocess.check_output(['pgenv', 'versions']) | ||
# typical output is: | ||
# 14.8 pgsql-14.8 | ||
# * 15.3 pgsql-15.3 | ||
# 16beta2 pgsql-16beta2 | ||
# where the line marked with a * is the currently active version | ||
# | ||
# we are only interested in the first word of each line, which is the version number | ||
# thus we strip the whitespace and the * from the line and split it into words | ||
# and take the first word | ||
versions = [line.strip('* ').split()[0] for line in output.decode('utf-8').splitlines()] | ||
|
||
# create the list of configurations per version | ||
configurations = [] | ||
for version in versions: | ||
configurations.append(generate_configuration(version)) | ||
|
||
# create the json file | ||
c_cpp_properties = { | ||
"configurations": configurations, | ||
"version": 4 | ||
} | ||
|
||
# write the c_cpp_properties.json file | ||
with open(target_path, 'w') as f: | ||
json.dump(c_cpp_properties, f, indent=4) | ||
|
||
|
||
def generate_configuration(version): | ||
"""Returns a configuration for the given postgres version. | ||
>>> generate_configuration('14.8') | ||
{ | ||
"name": "Citus Development Configuration - Postgres 14.8", | ||
"includePath": [ | ||
"/usr/local/include", | ||
"/home/citus/.pgenv/src/postgresql-14.8/src/**", | ||
"${workspaceFolder}/**", | ||
"${workspaceFolder}/src/include/", | ||
], | ||
"configurationProvider": "ms-vscode.makefile-tools" | ||
} | ||
""" | ||
return { | ||
"name": f"Citus Development Configuration - Postgres {version}", | ||
"includePath": [ | ||
"/usr/local/include", | ||
f"/home/citus/.pgenv/src/postgresql-{version}/src/**", | ||
"${workspaceFolder}/**", | ||
"${workspaceFolder}/src/include/", | ||
], | ||
"configurationProvider": "ms-vscode.makefile-tools" | ||
} | ||
|
||
|
||
if __name__ == '__main__': | ||
arguments = docopt(__doc__, version='0.1.0') | ||
main(arguments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Attach Citus (devcontainer)", | ||
"type": "cppdbg", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}", | ||
"program": "/home/citus/.pgenv/pgsql/bin/postgres", | ||
"additionalSOLibSearchPath": "/home/citus/.pgenv/pgsql/lib", | ||
"setupCommands": [ | ||
{ | ||
"text": "handle SIGUSR1 noprint nostop pass", | ||
"description": "let gdb not stop when SIGUSR1 is sent to process", | ||
"ignoreFailures": true | ||
} | ||
], | ||
}, | ||
{ | ||
"name": "Open core file", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "/home/citus/.pgenv/pgsql/bin/postgres", | ||
"coreDumpPath": "${input:corefile}", | ||
"cwd": "${workspaceFolder}", | ||
"MIMode": "gdb", | ||
} | ||
], | ||
"inputs": [ | ||
{ | ||
"id": "corefile", | ||
"type": "command", | ||
"command": "extension.commandvariable.file.pickFile", | ||
"args": { | ||
"dialogTitle": "Select core file", | ||
"include": "**/core*", | ||
}, | ||
}, | ||
], | ||
} |
Oops, something went wrong.