vscode を使用して Redis を読み取り、ステップ実行します。

目次

1 Redis の概要

2 つの構成ステップ

3つの関数呼び出しチェーン


1 Redis の概要

Redis は完全にオープンソースで無料で、BSD プロトコルに準拠しており、高性能のキーと値のデータベースです。

Redis およびその他のキー/値キャッシュ製品には、次の 3 つの特徴があります。

  • Redis はデータの永続化をサポートしています。これにより、データをディスク上のメモリに保持し、再起動時に再度ロードして使用できます。
  • Redis は、単純なキーと値の型のデータをサポートするだけでなく、リスト、セット、zset、ハッシュなどのデータ構造のストレージも提供します。
  • Redis はデータ バックアップ、つまりマスター/スレーブ モードでのデータ バックアップをサポートしています。

Redis公式ウェブサイト:Redis中国語ウェブサイト

git リポジトリ: https://github.com/redis/redis.git

2 つの構成ステップ

Mac コンピューターに vscode をインストールし、必要なプラグインをダウンロードし、Linux 仮想マシンを起動し、ssh コマンドを使用して Linux 仮想マシン上の git clone redis ソフトウェアに接続し、vscode を使用して redis フォルダーを開きます。

redis フォルダーに新しい .vscode フォルダーを作成し、新しい task.json と launch.json を作成します。

launch.jsonは以下の通り

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "redis",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/src/redis-server",
            "args": [
                "redis.conf"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "preLaunchTask": "build",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
          ]
        }
    ]
}

task.jsonは次のとおりです

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build", 
            "type": "shell", 
            "command": "make",
            "args": [
                "CFLAGS=\"-g -O0\""
            ]
        }
    ]
} 

その後、デバッグを行うことができ、src/server.c の main 関数にブレークポイントを追加することでシングルステップ デバッグを行うことができます。

添付された redis コマンド:

redis-server コマンドを使用してサーバープログラムを起動し、新しく作成したコマンドウィンドウで redis-cli を起動して使用します。

3つの関数呼び出しチェーン

シングルステップ デバッグを使用して、redis 関数の呼び出しチェーンをトレースできます。set コマンドの呼び出しチェーンをトレースしたい場合は、setCommand 関数にブレークポイントを設定し、redis-cli にセット名 1000 を入力します。このようにsetCommandで停止することができます。

 このようにして、set コマンド全体の関数呼び出しチェーンを明確に確認できます。

×

おすすめ

転載: blog.csdn.net/daida2008/article/details/124553506