欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在Centos7中使用vscode和gdb調(diào)試PG插件的方法

 更新時(shí)間:2022年09月14日 14:56:19   作者:半瓶以上 一瓶未滿  
這篇文章主要介紹了在Centos7中使用vscode和gdb調(diào)試PG插件,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

安裝vscode

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
yum check-update
sudo yum install code

給vscode安裝擴(kuò)展

C/C++

C/C++ Extension Pack

vscode中g(shù)db調(diào)試

打開文件夾(默認(rèn)創(chuàng)建工作區(qū)隱藏文件夾)

打開C/C++文件,光標(biāo)放在文件內(nèi)

按F1,輸入C/C++,選擇C/C++:Edit configuration,生成c_cpp_properties.json配置文件。一般來說不需要更改,若想更好的智能提示,可以在includePath里添加新的目錄。例如

"/home/postgres/pgcode/postgres-REL_14_2/src/include",
"/home/postgres/pgcode/postgres-REL_14_2/src/include/portability",
"/home/postgres/pgcode/postgres-REL_14_2/src/interfaces/libpq"

調(diào)試動(dòng)態(tài)庫(kù)

在本機(jī)上調(diào)試PG插件citus,citus的源碼放在PG源碼的contrib中。

在調(diào)試,點(diǎn)擊“創(chuàng)建 launch.json”,右下角點(diǎn)擊“添加配置”,在彈出的窗口選擇“C/C++ :(gdb)附加”。

"program": "/home/postgres/pgREL1402/bin/postgres"

調(diào)試程序

例如調(diào)試pg_dump。

假如在命令行里我們輸入如下命令

pg_dump "host=192.168.0.109 port=15431 user=tua password=123 dbname=testddl" -s -t tm

在調(diào)試?yán)镄枰葍r(jià)成

"program": "/home/postgres/pgREL1402/bin/pg_dump",
"args": ["host=192.168.0.109 port=15431 user=tua password=123 dbname=testddl","-s","-t","tm"],

最后點(diǎn)擊“開始調(diào)試”或者F5進(jìn)入調(diào)試。

識(shí)別需要attach的PG進(jìn)程

在psql命令行里執(zhí)行東西后,怎樣調(diào)試呢?需要將gdb附加到對(duì)應(yīng)psql的PG后臺(tái)進(jìn)程。可以通過下面語(yǔ)句找出來。

SELECT procpid, start, now() - start AS lap, current_query 
FROM (SELECT backendid, 
        pg_stat_get_backend_pid(S.backendid) AS procpid, 
        pg_stat_get_backend_activity_start(S.backendid) AS start, 
       pg_stat_get_backend_activity(S.backendid) AS current_query 
    FROM 
        (SELECT pg_stat_get_backend_idset() AS backendid) AS S 
    ) AS S WHERE current_query <> '<IDLE>' ORDER BY lap DESC;

到此這篇關(guān)于在Centos7中使用vscode和gdb調(diào)試PG插件的文章就介紹到這了,更多相關(guān)vscode和gdb調(diào)試PG插件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論