使用pdb调试openstack (How to debug openstack using pdb )

openstack断点pdb调试 1、以neutron的ovn代码为例,说明使用方法。代码文件是/usr/lib/python2.7/site-packages/ovsdbapp/backend/ovs_idl/idlutils.py,在需要打断点的位置输入import pdb;pdb.set_trace() 代码和pdb断点位置如下: 2、使用如下命令停止neutron-server的服务: systemctl stop n... 阅读详情

终于摸索出了一个调试openstack的简单方法,使用pdb进行单步调试,对于分析代码很有帮助。注意,这个方法只适用于用devstack安装的openstack。

调试主要是使用了一个脚本,这个脚本不记得是从哪下载的了,是用来重启使用devstack安装的openstack的各个服务的,后来,我又结合devstack的stack.sh和unstack.sh的脚本,向里面添加了一点内容,添加的功能主要是杀死前一个screen,即始终保持只有一个名为stack的screen,还添加了重启nova-conductor服务的功能。

脚本下载地址

下载之后,加上可执行权限,然后把它放在/opt/stack/devstack/目录下。


调试步骤:

1.  修改代码

在需要开始调试的地方加上这两句代码:

import pdb

pdb.set_trace()


2.  使用上面的脚本重启各个服务

stack@ubuntu:~/devstack$ ./restart_stack.sh


3.  进入screen,进行调试

stack@ubuntu:~/devstack$ screen -x stack


so easy!


需要注意的是:

1. 在第2步,如果某个服务一直在waiting,说明这个服务用到了在第1步修改的代码,那么这个时候,就要使用Ctrl+Z,把当前的进行切换到后台,然后进入到screen中,找到该服务对应的窗口,可以进行调试,如果不需要在服务启动时就进行调试的话,按‘c’,让它继续执行。之后Ctrl+a  d,退出screen,用fg把./restart_stack.sh的后台进程调出来,继续执行。

2. 在第3步,如果报类似这样“Cannot open your terminal '/dev/pts/21' - please check.”的错的话,就先输入script /dev/null,然后再进screen.

3. 脚本中的第一句,是用来重启网络的,需要输入root密码,如果不需要重启网络,就注释掉吧。


附脚本:

#!/usr/bin/env bash

# restart the interfaces
sudo /etc/init.d/networking restart

# close previrous screen
SCREEN=$(which screen)
if [[ -n "$SCREEN" ]]; then
    SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
    if [[ -n "$SESSION" ]]; then
	echo "close session: $SESSION"
	echo ""
        screen -X -S $SESSION quit
    fi
fi

TOP_DIR=$(cd $(dirname "$0") && pwd)

# create a new named screen to run processes in
screen -d -m -S stack -t stack -s /bin/bash
sleep 1
# set a reasonable statusbar
if [ -z "$SCREEN_HARDSTATUS" ]; then
    SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
fi
screen -r stack -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"

SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}

# Specify which services to launch.  These generally correspond to
# screen tabs. If you like to add other services that are not enabled
# by default you can append them in your ENABLED_SERVICES variable in
# your localrc. For example for swift you can just add this in your
# localrc to add it with the other services:
# ENABLED_SERVICES="$ENABLED_SERVICES,swift"
ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,n-vol,n-sch,n-novnc,n-xvnc,n-cauth,horizon,mysql,rabbit

# is_service_enabled() checks if the service(s) specified as arguments are
# enabled by the user in **ENABLED_SERVICES**.
#
# If there are multiple services specified as arguments the test performs a
# boolean OR or if any of the services specified on the command line
# return true.
#
# There is a special cases for some 'catch-all' services::
#   **nova** returns true if any service enabled start with **n-**
#   **glance** returns true if any service enabled start with **g-**
#   **quantum** returns true if any service enabled start with **q-**
function is_service_enabled() {
    services=$@
    for service in ${services}; do
        [[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
        [[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
        [[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
        [[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
    done
    return 1
}

DEST=${DEST:-/opt/stack}

# Set the destination directories for openstack projects
NOVA_DIR=$DEST/nova
HORIZON_DIR=$DEST/horizon
GLANCE_DIR=$DEST/glance
GLANCECLIENT_DIR=$DEST/python-glanceclient
KEYSTONE_DIR=$DEST/keystone
NOVACLIENT_DIR=$DEST/python-novaclient
KEYSTONECLIENT_DIR=$DEST/python-keystoneclient
OPENSTACKCLIENT_DIR=$DEST/python-openstackclient
NOVNC_DIR=$DEST/noVNC
SWIFT_DIR=$DEST/swift
SWIFT3_DIR=$DEST/swift3
QUANTUM_DIR=$DEST/quantum
QUANTUM_CLIENT_DIR=$DEST/python-quantumclient
MELANGE_DIR=$DEST/melange
MELANGECLIENT_DIR=$DEST/python-melangeclient

# By default the location of swift drives and objects is located inside
# the swift source directory. SWIFT_DATA_DIR variable allow you to redefine
# this.
SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DEST}/data/swift}

# We are going to have the configuration files inside the source
# directory, change SWIFT_CONFIG_DIR if you want to adjust that.
SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift}

# devstack will create a loop-back disk formatted as XFS to store the
# swift data. By default the disk size is 1 gigabyte. The variable
# SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change
# that.
SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}

# The ring uses a configurable number of bits from a path’s MD5 hash as
# a partition index that designates a device. The number of bits kept
# from the hash is known as the partition power, and 2 to the partition
# power indicates the partition count. Partitioning the full MD5 hash
# ring allows other parts of the cluster to work in batches of items at
# once which ends up either more efficient or at least less complex than
# working with each item separately or the entire cluster all at once.
# By default we define 9 for the partition count (which mean 512).
SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}

# This variable allows you to configure how many replicas you want to be
# configured for your Swift cluster.  By default the three replicas would need a
# bit of IO and Memory on a VM you may want to lower that to 1 if you want to do
# only some quick testing.
SWIFT_REPLICAS=${SWIFT_REPLICAS:-3}

if is_service_enabled swift; then
    # If we are using swift, we can default the s3 port to swift instead
    # of nova-objectstore
    S3_SERVICE_PORT=${S3_SERVICE_PORT:-8080}
fi

# Set default port for nova-objectstore
S3_SERVICE_PORT=${S3_SERVICE_PORT:-3333}

# Set the tenant for service accounts in Keystone
SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}

HOST_IP_IFACE=${HOST_IP_IFACE:-eth0}
# Use the eth0 IP unless an explicit is set by ``HOST_IP`` environment variable
if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then
    HOST_IP=`LC_ALL=C /sbin/ifconfig ${HOST_IP_IFACE} | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
    if [ "$HOST_IP" = "" ]; then
        echo "Could not determine host ip address."
        echo "Either localrc specified dhcp on ${HOST_IP_IFACE} or defaulted to eth0"
        exit 1
    fi
fi

SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}

# Glance connection info.  Note the port must be specified.
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292}

# Set Keystone interface configuration
KEYSTONE_API_PORT=${KEYSTONE_API_PORT:-5000}
KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST}
KEYSTONE_AUTH_PORT=${KEYSTONE_AUTH_PORT:-35357}
KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-http}
KEYSTONE_SERVICE_HOST=${KEYSTONE_SERVICE_HOST:-$SERVICE_HOST}
KEYSTONE_SERVICE_PORT=${KEYSTONE_SERVICE_PORT:-5000}
KEYSTONE_SERVICE_PROTOCOL=${KEYSTONE_SERVICE_PROTOCOL:-http}

# Our screenrc file builder
function screen_rc {
    SCREENRC=$TOP_DIR/stack-screenrc
    if [[ ! -e $SCREENRC ]]; then
        # Name the screen session
        echo "sessionname stack" > $SCREENRC
        # Set a reasonable statusbar
        echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC
        echo "screen -t stack bash" >> $SCREENRC
    fi
    # If this service doesn't already exist in the screenrc file
    if ! grep $1 $SCREENRC 2>&1 > /dev/null; then
        NL=`echo -ne '\015'`
        echo "screen -t $1 bash" >> $SCREENRC
        echo "stuff \"$2$NL\"" >> $SCREENRC
    fi
}

# Our screen helper to launch a service in a hidden named screen
function screen_it {
    NL=`echo -ne '\015'`
    if is_service_enabled $1; then
        echo Starting $1 ... 
        # Append the service to the screen rc file
        screen_rc "$1" "$2"

        screen -S stack -X screen -t $1
        # sleep to allow bash to be ready to be send the command - we are
        # creating a new window in screen and then sends characters, so if
        # bash isn't running by the time we send the command, nothing happens
        sleep 1.5

        if [[ -n ${SCREEN_LOGDIR} ]]; then
            screen -S stack -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
            screen -S stack -p $1 -X log on
            ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
        fi
        screen -S stack -p $1 -X stuff "$2$NL"
    fi
}

GLANCE_CONF_DIR=/etc/glance

# launch the glance registry service
if is_service_enabled g-reg; then
    screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf"
fi

# launch the glance api and wait for it to answer before continuing
if is_service_enabled g-api; then
    screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
    echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
      echo "g-api did not start"
      exit 1
    fi
fi

if is_service_enabled key; then
    
    KEYSTONE_CONF_DIR=${KEYSTONE_CONF_DIR:-/etc/keystone}
    KEYSTONE_CONF=$KEYSTONE_CONF_DIR/keystone.conf
    KEYSTONE_CATALOG=$KEYSTONE_CONF_DIR/default_catalog.templates

    # Set up logging
    LOGGING_ROOT="devel"
    if [ "$SYSLOG" != "False" ]; then
        LOGGING_ROOT="$LOGGING_ROOT,production"
    fi
    KEYSTONE_LOG_CONFIG="--log-config $KEYSTONE_CONF_DIR/logging.conf"

    # launch keystone and wait for it to answer before continuing
    screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug"
    echo "Waiting for keystone to start..."
    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -O- $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/ 2>&1 | grep -q '200 OK'; do sleep 1; done"; then
      echo "keystone did not start"
      exit 1
    fi

fi

# launch the nova-api and wait for it to answer before continuing
if is_service_enabled n-api; then
    screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
    echo "Waiting for nova-api to start..."
    if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
      echo "nova-api did not start"
      exit 1
    fi
fi

# Launching nova-compute should be as simple as running ``nova-compute`` but
# have to do a little more than that in our script.  Since we add the group
# ``libvirtd`` to our user in this script, when nova-compute is run it is
# within the context of our original shell (so our groups won't be updated).
# Use 'sg' to execute nova-compute as a member of the libvirtd group.
# We don't check for is_service_enable as screen_it does it for us
screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute"
screen_it n-crt "cd $NOVA_DIR && $NOVA_DIR/bin/nova-cert"
screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume"
screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
screen_it n-cond "cd $NOVA_DIR && $NOVA_DIR/bin/nova-conductor"
screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ."
screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF"
screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/$APACHE_NAME/horizon_error.log"
screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v"

# Starting the nova-objectstore only if swift service is not enabled.
# Swift will act as s3 objectstore.
is_service_enabled swift || \
    screen_it n-obj "cd $NOVA_DIR && $NOVA_DIR/bin/nova-objectstore"



OpenStack源码调试之路(0)——pycharm远程调试OpenStack 要阅读一个源码,最好的方法是调试代码,一步步跟踪,会使你对整个过程的理解更加透彻,对于OpenStack也是如此,虽然看过很多分析源码的书,但总是觉得对不上号,加上有需求,所以觉得自己对源码进行一番调试。最开始试过python的pdb调试,虽然大神都说怎么怎么好,但终归是控制台的操作,一点都不直观,最后找到使用pycharm远程调试的方法,觉得非常好用,windows下可视化界面,变量查看,追踪回... 阅读详情

相关推荐

Pycharm 下远程调试 Neutron 简介

实验背景及环境介绍 众所周知要深入学习一款开源软件就去阅读它的源码吧,但如果只是阅读冷冰冰的代码,往往是一头雾水,你肯定希望知道代码运行起来的上下文、变量值的变化,那么你需要调试。对于 Openstack 来说,大多代码都是开源 Python 编写的,这对于学习来说成本低很多,因为你可以随时修改它的代码,重启下进程你的代码就开始运行了。即使这样,对于调试 Openstack 这样大型的软件还

海风林影 2198

用PDB库调试Python程序

如果使用过微软技术的朋友应该体会过微软的Visual Studio系列IDE给debug程序带来的方便,换了个工作就没有Visual Studio了,对于我这种从未在非GUI环境下调试过程序的人来说实在有点不爽,今天花了点时间看了一下Python自带的pdb库,发现用pdb来调试程序还是很方便的,当然了,什么远程调试,多线程之类,pdb是搞不定的。用pdb调试有多种方式可选:1.

byrsongQQ的专栏 1142

WRF-Chem新手避坑指南:从chem_opt到emiss_opt,那些手册里没明说的参数配置实战

本文为WRF-Chem新手提供从chem_opt到emiss_opt的参数配置实战指南,解析官方文档中未明确的常见陷阱与解决方案。通过华北重霾案例,详细讲解化学机制选择、排放源配置及特殊参数组合的注意事项,帮助用户避开常见错误,提升模拟效率。

weixin_30897079的博客 279

openstack调试

openstack调试   对于开源的openstack而言,调试显然非常重要,在调试的过程中,我们可以跟踪代码的执行过程,对于我们理解openstack的结构和框架有十分重要的意义。在之前的教程中提到的使用devstack工具在虚拟机中安装部署openstack,通常虚拟机运行会有点卡,为了不让虚拟机那么卡,我们抛弃了较大的python IDE(pycharm和eclipse等)。使用的是最为...

weixin_30362801的博客 239

TMC步进电机驱动stealthChop

经过九九八十一难,芯片手册拜读了好多遍,找了好多资料,问了好多人使用TMC2660驱动步进电机终于成功了。最后的问题居然是硬件把管脚画错了,然后我又没有检查,哭。。。

那可真是太开心了的博客 4489

【学习记录】IIC驱动ICM42670+卡尔曼滤波+四元数姿态角解算

ICM42670陀螺仪可以使用iic驱动,单片机平台使用GD32f305VE。

liarsup的博客 8265

用pdb调试OpenStack

点击打开链接 [plain] view plaincopy ADMIN_PASSWORD=password   MYSQL_PASSWORD=stackdb   RABBIT_PASSWORD=stackqueue   SERVICE_PASSWORD=$ADMIN_PASSWORD   #enable_service ral

luzheqi的专栏 1751

微信小程序获取用户手机号全流程实战(附完整代码)

本文详细介绍了微信小程序获取用户手机号的全流程实战,包括前端授权、后端解密及安全合规要点。通过传统授权按钮和新版手机号快速验证组件两种方案,帮助开发者高效实现功能,并附完整代码示例。重点解析了微信小程序接口的使用技巧和常见问题解决方案,确保数据安全与用户体验。

weixin_29280219的博客 568

调试openstack源码的方法

1,首先在源码文件里打个断点(import pdb;pdb.set_trace()) 2,停掉对应的服务(systemctl stop xxx) 3,手动启动该服务 4,重开一个窗口,执行调用包含断点源码文件的服务(比如nova-api,nova-compute) 5,原窗口将会在断点处停止

pengdake300的博客 727

应用软件——Altium Designer 19 Gerber/坐标文件

如何输出Gerber文件 步骤如下: 打开需要输出的PCB文件 2. 设置原点坐标 3. 打开Gerber Files 选项,File–>Fabrication Opuputs–>Gerber Files。 4. General参数设置。 用于指定输出Gerber文件中使用的单位(Units)和格式(Format)。单位可以是公制(Millimeters)和英制(Inches);格式栏中2:3,2:4,2:5代表文件中使用的不同数据精度,其中2:3表示数据含2位整数3位小数;相应的,另外两个分

染血黑兔的博客 7203

【瑞芯微px30】【RTL8363】【一】驱动移植-网卡驱动概述

linux rtl8363驱动移植

weixin_34799243的博客 1180

openstack调试方法总结

因为前几天Komodo突然一下在使用中没法代码自动补全,没法进行代码自动提示了,自己折腾了(大概十个小时,卸载重装了很多次)很久也没法让它对python代码进行自动提示,很无语,于是彻底放弃,改用Eclipse+pyDev平台。虽然浪费了时间,但是已经对Eclipse有些熟练了,还是有所收获哦。   Python的安装比较简单,因此python的安装就不说了,Eclipse的基础环境,JRE

jincm的专栏 5972

用pdb调试OpenStack Havana

作为个人学习笔记分享,有任何问题欢迎交流! Note:若是想要用pdb调试OpenStack,必须通过Devstack安装它。 Devstack安装Havana过程 1.使用一般用户(非root用户),从github上获取devstack代码 git clonehttps://github.com/openstack-dev/devstack.g...

weixin_30872867的博客 201

华为OD机试真题2025双机位A卷 Java&Go 实现【优美子数组】

华为OD机试真题2025双机位A卷 Java&Go 实现【优美子数组】

MISAYAONE的博客 240

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

OpenStack之调试——Pdb调试

用pdb调试有多种方式可选: 1. 命令行启动目标程序,加上-m参数,这样调用myscript.py的话断点就是程序的执行第一行之前 python -m pdb myscript.py 2. 在Python交互环境中启用调试 >>> import pdb >>> import mymodule >>> pdb.run(‘mymodule.test()’) 3. 比较常用的,就

仇晗的专栏 1673

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

openstack代码调试

主要记录openstack代码如何进行调试的一个流程 用的是devstack搭建的openstack,搭建完毕之后,想着用pdb进行单步调试,可以加深对代码的理解 下面以nova api为例进行说明: 首先安装remote_pdb工具,LOG.debug()是加上相应的打印信息,可以在/var/log/syslog文件中查看到 在create函数中增加from remote_pdb import RemotePdb RemotePdb('127.0.0.1',4444).set_trace()

qq_33970713的博客 635

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

使用pdb调试ceilometer代码

本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。 声明: 本博客欢迎转发,但请注明出处,保留原作者信息 博客地址:孟阿龙的博客 所有内容为本人学习、研究、总结。如有雷同,实属荣幸 Newton版本以前,Ceilometer代码调试方法: ceilometer在Newton版本以前,polling-agent使用的是oslo_service模块启...

mengalong的博客 616

怎样调试OpenStack Unit Test

相信大家都知道执行OpenStack的Unit Test,非常简单,只需要执行"run_tests.sh"就可以,但是有没有想过怎么 去调试这些Unit Test脚本呢,有个方法是使用"nosetests",具体如下: 1)修改你要调试的文件,加上"pdb.set_trace()",我现在用test_scheduler.py举例 class SchedulerDriverModuleT

狂飙的蜗牛 4151

gdb 多线程调试 暂停其他线程_OpenStack断点调试方法总结

1 关于断点调试断点是调试应用程序最主要的方式之一,通过设置断点,可以实现单步执行代码,检查变量的值以及跟踪调用栈,甚至修改进程的内存变量值或者运行代码,从而观察修改后的程序行为。大多数的调试器都是通过ptrace系统调用控制和监视进程状态,通过INT 3软件中断实现断点。当我们在代码中插入一个断点时,其实就是调试器找到指令位置(编译成机器码后的位置)嵌入一个INT 3指令,进程运行时遇到INT ...

weixin_39890431的博客 717

.net 网络调试助手源码_OpenStack断点调试方法总结

01关于断点调试断点是调试应用程序最主要的方式之一,通过设置断点,可以实现单步执行代码,检查变量的值以及跟踪调用栈,甚至修改进程的内存变量值或者运行代码,从而观察修改后的程序行为。大多数的调试器都是通过ptrace系统调用控制和监视进程状态,通过INT 3软件中断实现断点。当我们在代码中插入一个断点时,其实就是调试器找到指令位置(编译成机器码后的位置)嵌入一个INT 3指令,进程运行时遇...

weixin_39748183的博客 219

python openstack oslo_config使用_OpenStack 断点调试方法总结(其他 Python 程序同样适用)...

1、断点调试的目的和工具断点是调试应用程序最主要的方式之一,通过设置断点,可以实现单步执行代码,检查变量的值以及跟踪调用栈,甚至修改进程的内存变量值或者运行代码,从而观察修改后的程序行为。大多数的调试器都是通过ptrace系统调用控制和监视进程状态,通过INT3软件中断实现断点。当我们在代码中插入一个断点时,其实就是调试器找到指令位置(编译成机器码后的位置)嵌入一个INT3指令,进程运行时遇到I...

weixin_39832829的博客 138

nova-compute 的pdb调试方法

最近live snapshot总出问题,想自己深入调试,采用了pdb。 Openstack其他组件的调试方法大同小异,这里仅以nova-compute举例。 1. 首先要停止nova-compute服务。 service nova-compute stop2. 插入断点,比方说我在driver.py 4832行插入。 import pdb; pdb.set_trace() 3.

阿Q的专栏 1347

debugging openstack with pdb

在要开始debug的地方导入pdb: class KeypairAPI(base.Base): """Sub-set of the Compute Manager API for managing key pairs.""" def __init__(self, **kwargs): super(KeypairAPI, self).__init__(...

weixin_33701564的博客 83
上一篇: policy机制中经典的python用法
下一篇: My OpenStack Weekly Reports——社区
hackerain
博客等级 码龄16年 753粉丝 220原创
评论 9
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值