AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1107474

intrigued_66's questions

Martin Hope
intrigued_66
Asked: 2024-12-02 08:33:11 +0800 CST

GDB 如何生成核心转储文件?

  • 5

我总是在交互式会话中使用 GDB(gdb --args <program>)

两个问题:

  1. 是否可以配置.gdbinit自动生成核心转储文件?

  2. 与第一个问题相关,如果程序崩溃,是否有 GDB 会话命令可以手动生成核心转储文件?

debugging
  • 1 个回答
  • 26 Views
Martin Hope
intrigued_66
Asked: 2024-06-11 05:08:25 +0800 CST

发现问题后强制 ThreadSanitizer 崩溃

  • 6

我正在运行带有 -02 和 g 编译器标志且不使用 gdb 的 ThreadSanitizer。它检测到竞争条件并打印堆栈跟踪,但它继续运行。我很幸运能够进行监控。

有没有办法在检测到问题时强制 ThreadSanitizer 崩溃?

c++
  • 1 个回答
  • 22 Views
Martin Hope
intrigued_66
Asked: 2024-05-26 11:25:04 +0800 CST

情节地,将纪元时间戳(以毫秒为单位)转换为可读的日期时间?

  • 7

下面的代码使用 Python 列表创建 Plotly 图表。

时间戳是 Epoch 毫秒。如何将 x 轴格式化为可读的日期时间?

我尝试过fig.layout['xaxis_tickformat'] = '%HH-%MM-%SS',但没有成功。

import plotly.graph_objects as go

time_series = [1716693661000, 1716693662000, 1716693663000, 1716693664000]
prices = [20, 45, 32, 19]
 
fig = go.Figure()
fig.add_trace(go.Scatter(x=time_series, y=prices, yaxis='y'))

fig.update_layout(xaxis=dict(rangeslider=dict(visible=True),type="linear"))
fig.layout['xaxis_tickformat'] = '%Y-%m-%d'

fig.show()
python
  • 1 个回答
  • 20 Views
Martin Hope
intrigued_66
Asked: 2024-05-25 07:07:26 +0800 CST

如何在 Plotly 中将 Pandas 列设置为日期时间 x 轴

  • 6

我有三个列表,其中包含要通过 Plotly 显示的数据。第一列表示纪元时间戳(以毫秒为单位),第二列和第三列是要绘制的系列。

我正在尝试正确创建 pandas 数据框,以传递给 Plotly。

到目前为止我有这个:

import pandas as pd

epoch=[1716591253000, 1716591254000, 1716591255000, 1716591256000]
series_1=[5,6,7,8]
series_2=[9,10,11,12]

df = pd.DataFrame(data=zip(epoch,series_1,series_2),columns=['Datetime','Series 1','Series 2'])

print(df)

但我不确定如何告诉 pandas 第一列是日期时间列,并且在传递给 Plotly 时需要作为 x 轴。

我找到了这些时间序列的例子:

https://plotly.com/python/time-series/

但不幸的是他们正在加载预先创建的数据

python
  • 1 个回答
  • 26 Views
Martin Hope
intrigued_66
Asked: 2024-04-20 08:32:26 +0800 CST

在这种情况下如何避免循环引用?[复制]

  • 3
这个问题在这里已经有了答案:
C++ 中的前向声明是什么? (8 个回答)
什么时候可以使用前向声明? (13 个回答)
3 小时前关闭。

我有三节课。每个类都有自己的标题。

我希望每个类都有两个额外的构造函数来从其余两种类型进行转换:

// A.h
A(const B& b){}
A(const C& c){}

// B.h
B(const A& a){}
B(const C& c){}

// C.h
C(const A& a){}
C(const B& b){}

但是,如果我在每个标头中包含其他两个标头,我最终将得到循环依赖。

实现这一点的最佳方法是什么?

c++
  • 1 个回答
  • 48 Views
Martin Hope
intrigued_66
Asked: 2024-01-20 09:15:18 +0800 CST

原始套接字未在正确的接口上捕获 DHCP 数据包,但 Wireshark 可以

  • 5

我正在关注原始套接字嗅探器的 C 应用程序示例:

https://www.binarytides.com/packet-sniffer-code-c-linux/

除非我在创建套接字后将套接字绑定到我的接口:

const std::string& iff = "wlp3s0";

int r = setsockopt(sock_raw, SOL_SOCKET, SO_BINDTODEVICE, iff.c_str(), iff.length());
if (r == -1)
{
    std::abort();
}

然后我让应用程序运行:

sudo ./the_app

我打开 Wireshark 并监听 wlp3s0 无线接口。我从捕获中删除了有线以太网接口。

然后,我运行sudo dhclient -r并sudo dhclient停止/启动 DHCP,Wireshark 检测到 4 或 5 个 DHCP 数据包,如预期的那样:

在此输入图像描述

然而,C 原始套接字嗅探器显示绝对没有收到 UDP 数据包。

如果我随后打开 Web 浏览器,它就会开始显示 TCP 数据包(Wireshark 报告 DHCP 数据包是 UDP)。

发生了什么?我使用的是 Ubuntu 22.04

最小的例子:

#include<stdio.h>   //For standard things
#include<stdlib.h>  //malloc
#include<string.h>  //memset
#include<netinet/ip_icmp.h> //Provides declarations for icmp header
#include<netinet/udp.h> //Provides declarations for udp header
#include<netinet/tcp.h> //Provides declarations for tcp header
#include<netinet/ip.h>  //Provides declarations for ip header
#include<sys/socket.h>
#include<arpa/inet.h>
#include <unistd.h>

void ProcessPacket(unsigned char* , int);

int tcp=0,udp=0,icmp=0,others=0,igmp=0,total=0,i,j;
struct sockaddr_in source,dest;

int main()
{    
    unsigned char *buffer = (unsigned char *)malloc(65536); //Its Big!
    
    printf("Starting...\n");
    int sock_raw = socket(AF_INET , SOCK_RAW , IPPROTO_TCP);

    if(sock_raw < 0)
    {
        std::abort();
    }

    int r = setsockopt(sock_raw, SOL_SOCKET, SO_BINDTODEVICE, "wlp3s0", strlen("wlp3s0"));
    
    if (r == -1)
    {
        std::abort();
    }
   
    while(1)
    {
        int data_size = recv(sock_raw , buffer , 65536 , 0);
        
        if(data_size <0 )
        {
            std::abort();
        }

        ProcessPacket(buffer , data_size);
    }
    
    ::close(sock_raw);
    return 0;
}

void ProcessPacket(unsigned char* buffer, int size)
{
    //Get the IP Header part of this packet
    struct iphdr *iph = (struct iphdr*)buffer;
    ++total;
    switch (iph->protocol) //Check the Protocol and do accordingly...
    {
        case 1:  //ICMP Protocol
            ++icmp;
            //print_icmp_packet(buffer, size);
            break;
        
        case 2:  //IGMP Protocol
            ++igmp;
            break;
        
        case 6:  //TCP Protocol
            ++tcp;
            //print_tcp_packet(buffer , size);
            break;
        
        case 17: //UDP Protocol
            ++udp;
            //print_udp_packet(buffer , size);
            break;
        
        default: //Some Other Protocol like ARP etc.
            ++others;
            break;
    }

    printf("TCP : %d   UDP : %d   ICMP : %d   IGMP : %d   Others : %d   Total : %d\r",tcp,udp,icmp,igmp,others,total);
}
c
  • 1 个回答
  • 45 Views
Martin Hope
intrigued_66
Asked: 2023-08-23 02:53:08 +0800 CST

STL/Boost 类似数组的容器,按排序顺序存储元素,没有间隙?

  • 6

我想在固定大小的数组上插入和“删除”元素。每次操作后,元素都按排序顺序且连续(无间隙)。

第一个元素将被插入到中间。

是否有现有的容器(包括 Boost)可以做到这一点?我可以写一些逻辑,但这肯定是一个不常见的要求?

我可以在上面添加一些附加/非普通逻辑。

c++
  • 2 个回答
  • 40 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve