> For the complete documentation index, see [llms.txt](https://wiki.golos.id/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.golos.id/witnesses/node/gdb.md).

# Нода с отладкой GDB

Бывает, что из-за ошибок демон golosd вылетает с сообщением Segmentation fault или Aborted, в папке /var/lib/golosd появляется core dumped. При этом больше никакой информации. В таком случае пригодится отладка через [gdb](https://ru.wikipedia.org/wiki/GNU_Debugger).

Устанавливаем необходимые пакеты:

```
sudo apt-get update
```

```
sudo apt-get install -y \
        autoconf \
        automake \
        autotools-dev \
        bsdmainutils \
        build-essential \
        cmake \
        doxygen \
        git \
        ccache \
        libboost-all-dev \
        libreadline-dev \
        libssl-dev \
        libtool \
        ncurses-dev \
        pbzip2 \
        pkg-config \
        python3 \
        python3-dev \
        python3-pip \
        runit
```

```
sudo pip3 install gcovr
```

Копируем исходные файлы для сборки ноды из github:

```
git clone https://github.com/golos-blockchain/chain-node.git && cd chain-node
```

```
git submodule update --init --recursive -f
```

Задаём значения переменных и конфигурируем проект:

```
mkdir build && cd build
```

```
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_GOLOS_TESTNET=FALSE \
    -DBUILD_SHARED_LIBRARIES=FALSE \
    -DLOW_MEMORY_NODE=FALSE \
    -DCHAINBASE_CHECK_LOCKING=FALSE \
    ..
```

Запуск сборки с установкой демона в `/usr/local/`, исполнив:

```
make -j $(nproc) && sudo make install
```

## Подготовка файлов

```
mkdir -p ~/chain-node/build/programs/golosd/witness_node_data_dir/blockchain
```

```
sudo cp ~/chain-node/share/golosd/snapshot5392323.json ~/chain-node/build/programs/golosd/ && 
sudo cp ~/chain-node/share/golosd/seednodes ~/chain-node/build/programs/golosd/witness_node_data_dir/ && 
sudo cp ~/chain-node/share/golosd/config/config_witness.ini ~/chain-node/build/programs/golosd/witness_node_data_dir/config.ini
```

Возможно понадобится прописать сид-ноды в конфиг:\
`p2p-seed-node = golos1.lexai.host:4243`\
`p2p-seed-node = golos2.lexai.host:4243`

Копируем в папку `.../golosd/witness_node_data_dir/blockchain` бэкап файлов блоклогс и шаред-мемори, чтобы не терять время на синхронизацию сети (возможно скачать [здесь](https://wiki.golos.id/witnesses/node/guide#ustanavlivaem-nodu)).

## Запуск GDB

Устанавливаем отладчик gdb

```
sudo apt-get install gdb -y
```

Переходим в папку проекта

```
cd ~/chain-node/build/programs/golosd
```

Запускаем демон через gdb

```
gdb ./golosd
```

На вопрос *Quit this debugging session? (y or n), отменяем вводом **n***

Включаем сохранение лога (в файл gdb.txt) рядом с файлом запуска

```
set logging on
```

Подтверждаем запуск

```
run
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.golos.id/witnesses/node/gdb.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
