当我给出“info share”命令并且我还在 gdb 上加载了符号文件和核心时,我收到“此时没有加载共享库”。但通常核心转储应该根据其相应的应用程序加载共享库。我已经指定了 solib-search-path,GDB 在搜索符号时将在其中查找共享库。
在“此时没有加载共享库”的情况下是否可以获得回溯?
gdb>info sharedlibrary
No shared libraries loaded at this time.
gdb> bt
#0 0xb6d1f232 in ?? ()
#1 0xb6d25ddc in ?? ()
#2 0xb6d25ddc in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Run Code Online (Sandbox Code Playgroud)
非常感谢,提前。
我正在努力实现这一目标:
编写一个接受三个用户输入的程序:作业分数、期中分数和期末考试分数。
这些输入是 float 类型,值应该在 0 到 100 之间。
该程序应以百分比和字母等级的形式计算最终成绩。
• 最终成绩的计算方式为:作业 20%、期中考试 30%、期末考试 50%。字母等级计算为:A(最终成绩 ? 80%)、B(80 > 最终成绩 ? 70%)、C(70 > 最终成绩 ? 60%)、D(60 > 最终成绩 ? 50%)和 F (50 > 最终成绩)。
显示最终成绩和字母成绩。
使用以下代码:
#include <stdio.h>
int checkMark(int);
float getMark();
float computeFinalGrade(float assign, float midterm, float finalExam, float finalGrade);
int computeLetterGrade(float);
int checkMark(int x)
{
while(x<0 || x>100) //While x is a negative number:
{
printf("Invalid entry.Try again:");
scanf("%d",&x);
}
if(x>0 && x<=100)//If x is a positive number:
x=x; …
Run Code Online (Sandbox Code Playgroud) 今天我尝试检测核心转储并提醒我的事实上确实发现了一个错误的断言(当我在前台或后台的命令行上运行它时通常核心转储它)但没有核心被丢弃.我写了这个简单的测试:
int main
{
sleep(3);
assert(false);
}
Run Code Online (Sandbox Code Playgroud)
当我编译并运行时,它将始终进行核心转储.但是当我把它放在crontab上时,我收到了来自cron守护进程的电子邮件说:
rocket: main.cpp:10: int main(int, char**): Assertion `false' failed.
/bin/sh: line 1: 32448 Aborted ./rocket
Run Code Online (Sandbox Code Playgroud)
并且没有放入核心文件/cores
.为什么这样,我怎么能得到我的核心?
gcc通常将构建ID嵌入到共享对象中,以允许自动检索符号(以及共享对象本身).该计划在此记录:
http://fedoraproject.org/wiki/Releases/FeatureBuildId
我有一个我想分析的用户模式核心转储,我知道,根据上面的文章,它很可能包含我关心的所有共享对象的构建ID(总共几十个).如果我可以从核心转储中提取构建ID,那么我可以在我们的存档中找到正确的版本,并能够调试此核心转储(以及未来的核心转储).
核心转储来自另一台我无法访问的计算机,我无法信任该计算机上的用户,以便向我提供有关该计算机上的哪些模块的其他信息.
所以...任何想法gdb命令或read-elf魔法会找到我这些构建ID?
当进程崩溃然后核心转储时,我们遇到了一个问题。由于该进程内存占用较大,大约20GB,core dump需要将20GB的核心数据写入磁盘,此时磁盘使用率变得非常高,负载急剧增加。
如何限制core dump的写入速度?进程崩溃导致服务器挂起,这太糟糕了。
我正在写一个程序,它取一个1-10之间的数字,并显示所有可能的方法来安排数字.
防爆输入:3输出:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
Run Code Online (Sandbox Code Playgroud)
每当我输入9或10时,程序会产生分段错误并转储核心.我相信问题是我的递归算法被调用了太多次.有人可以帮助指出我如何限制必要的递归调用量?这是我目前的代码:
void rearange(int numbers[11], int index, int num, int fact) {
int temp = numbers[index];
numbers[index] = numbers[index-1];
numbers[index-1] = temp;
int i;
for (i = 1; i <= num; ++i) // print the current sequence
{
printf("%d ", numbers[i]);
}
printf("\n");
fact--; // decrement how many sequences remain
index--; // decrement our index in the array
if (index == …
Run Code Online (Sandbox Code Playgroud) 我一直有这个问题已经有一段时间了,我已经搜索过这种类型的错误,我相信它与内存泄漏或指向什么都没有的指针有关.
我一遍又一遍地检查我的代码,我无法找到这个问题的确切位置,因为我不知道如何调试它.即使我尝试断开代码的第一行,它也会崩溃.
它正在从文件中读取一堆ISBN并检查它们是否有效.
虽然看起来很多,但逻辑非常简单.
这是我的代码:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <list>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
using namespace std;
class Isbn
{
private:
string isbnCode;
public:
Isbn()
{
}
Isbn(string isbn): isbnCode(isbn)
{
}
~Isbn()
{
}
string getIsbn()
{
return isbnCode;
}
void setIsbn(string input)
{
isbnCode = input;
}
};
void setListOfIsbn(const string filename, list<Isbn> &listOfIsbn);
void validateIsbns(const list<Isbn> listOfIsbn, list<bool> &validations);
void printValidations(const list<Isbn> listOfIsbn,
const list<bool> validations);
string bToS(const bool bValue); …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个程序,允许用户输入要读取的人员数据库的文件名; 然后,程序在每个状态链接中创建状态对象的链接列表和人员对象的链接列表,以组织文件中的信息.
我知道链表部分有效,因为我能够直接在文件名中编码并打印出状态列表和每个州的人员列表; 但是,当我尝试允许用户输入文件名作为命令时,我收到一个总线错误.当我在gdb中运行代码时,它告诉我的是:
Program received signal SIGBUS, Bus error.
0x280df0bd in std::operator>><char, std::char_traits<char> > ()
from /usr/lib/libstdc++.so.5
Run Code Online (Sandbox Code Playgroud)
我甚至没有得到一个行号!任何帮助将非常感激.这是我的代码的命令和读取部分:
List<State*>* read(char* filename) {
string fname, lname, birthday, state;
int ssn;
List<State*>* state_list = new List<State*>();
ifstream file(filename);
if (file.fail()) {
cerr << "Error reading file.\n";
exit(1);
}
while (!file.eof()) {
file >> birthday >> ssn >> fname >> lname >> state;
Link<State*>* searchres = searchList(state, state_list);
Person* p = new Person(fname, lname, ssn, birthday, state);
if (searchres == NULL) // …
Run Code Online (Sandbox Code Playgroud) 我是C的新人,现在我正在学习mmap.我想从mmaped文件中获取第N个字节,但是我得到了这个错误Segmentation Fault (core dumped)
当我测试我的程序时,gdb
我得到了这行的错误 printf("%d\n", (int) data[sk]);
然后我print data
和我得到了
(gdb) print data[sk]
Cannot access memory at address 0xfe5f07d0
(gdb) print data
$1 = 0xfe5f0000 <Address 0xfe5f0000 out of bounds>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我会收到这个错误.这是我的代码
int main( int argc, char * argv[] ){
int sk;
int d;
char *data;
size_t s;
if(argc == 3){
sk = atoi(argv[2]);
d = da_open(argv[1]);
s = da_fileSize(d);
data = (char*)da_mmap(d, s);
printf("File Size: %d\n", (int) s);
printf("%d\n", (int) data[sk]); // this line is …
Run Code Online (Sandbox Code Playgroud) 请说明(输出原因)运行两个代码段会发生什么。请也说明它们的区别。分为以下两种版本setArr(int, int)
...
#include <stdio.h>
void setArr(int, int);
int *arr[10]; // array of 10 int pointers
int main(int argc, char *argv[]) {
int i;
setArr(0, 0);
setArr(1, 100);
setArr(2, 200);
setArr(3, 300);
setArr(4, 400);
for (i = 0; i < 5; i++)
printf("arr[%d]: %d\n", i, *arr[i]); /* should be 0,100, 200,300,400 */
return 0;
}
Run Code Online (Sandbox Code Playgroud)
的版本 setArr
版本A
void setArr(int index, int v) {
int i = v;
*arr[index] = i;
}
Run Code Online (Sandbox Code Playgroud)
输出: Segmentation fault (core dumped)
版本B
void …
Run Code Online (Sandbox Code Playgroud)