当我调试我的 PRJ 时,我收到此错误:
args 错误:报告了多个错误。\ 无法执行 MI 命令:-var-create -
args 来自调试器后端的错误消息:尝试取消引用通用指针。\ 无法创建变量对象
从 void* args 转换为 Mapper* arg 时出现错误。
更新 1
KMaster、KMapper 分别实现了 Master、Mapper 但它们并没有添加任何相关的内容。有效的是调用方法的 KMapper work()
。这是代码:
int main(){
int np=1,K=4;
string path="lucca.gps";
KMaster* master=new KMaster(path,np,K);
KMapper* mapper[np];
master->splitting();
for(int i=0;i<np;i++){
mapper[i]=new KMapper(master,master->mData[i].key,master->mData[i].value);
while(mapper[i]->work()!=0){
cout<<"failed creating mapper, retry..."<<endl;
sleep(1000);
}
}
}
int KMaster::splitting(){
cout<<"start splitting"<<endl;
fstream is(path.c_str());
string s="";
getline(is,s);
while(!is.eof()){
for(int i=0;i<nProc;i++){
pair<double,double> res;
is>>res.first;
is>>res.second;
is>>s;
mapData[i].push_back(res);
Data.push_back(res);
if(is.eof()) break;
}
}
list<pair<double,double> >::iterator it=Data.begin();
int increment=Data.size()/K;
for(int i=0;i<K;i++){
Klusters.push_back(*it);
advance(it,increment);
}
for(int i=0;i<nProc;i++){
mData[i].key=&Klusters;
mData[i].value=&mapData[i];
}
cout<<"splitting completed"<<endl;
return 0;
}
int Mapper::work(){
Mapper* m=this;
void* p=m;
return pthread_create(&thread,NULL,start,p);
}
void* start(void* args){
cout<<"start()"<<endl;
Mapper* arg= reinterpret_cast<Mapper*>(args);
arg->mapResult=arg->map(arg->k,arg->v);
cout<<"Mapper finish, sending result..."<<endl;
arg->send(arg->mapResult);
}
希望有人能帮忙!
更新 2
调试器截图: