我试图使用gdb和stl将值转储到向量中,但是向量位于#included header.h文件中,并且不会出现在调试中。
如何将值转移到头文件中的向量内?
代码:
#cat buymngr.h
void buymngr(){
//vector defs
vector<std::string> buydat;
vector<std::string> markdat;
vector<std::string> pricedat;
vector<std::string> qworkcoin;
buydat = getmyData();
markdat = getmarketbuyData();
cout << "Bork!" << endl;
if(buydat[2] == std::string("Buy")){
cout << "Bork2!" << endl;
for(int b = 2; b < buydat.size(); b+=7){
int y = 3; y+=7;
if ( buydat[b] == "Buy" ) {
pricedat.push_back(buydat[b+1]);
//I need to dump these 2 vectors
qworkcoin.push_back(buydat[y+1]);
}
}
}
#cat main.cpp
#include <cstdio>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <unistd.h>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <sstream>
#include "getmyData.h"
#include "getmarketsellData.h"
#include "getmarketbuyData.h"
#include "buymngr.h"
#include "sellmngr.h"
using namespace std;
//Le Main
int main(void)
{
buymngr();
sellmngr();
}
调试:
gdb> r
Starting program: /home/main
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
I got my own data
I just got market buy data
Bork!
Bork2!
Program received signal SIGSEGV, Segmentation fault.
_______________________________________________________________________________
eax:0000000A ebx:0060A1B0 ecx:0060A1B0 edx:0060A2E8 eflags:00010206
esi:0060A2E8 edi:0060A1B0 esp:FFFFBD90 ebp:FFFFBDF0 eip:Error while running hook_stop:
Value can't be converted to integer.
0x00007ffff7b9355b in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/libstdc++.so.6
gdb> l
Line number 30 out of range; masterMain.cpp has 29 lines.
gdb> ll
Undefined command: "ll". Try "help".
gdb> #include "buymngr.h"
gdb> include "buymngr.h"
Undefined command: "include". Try "help".
gdb> l
Line number 30 out of range; masterMain.cpp has 29 lines.
gdb> p