Hello to everyone
I use ubuntu as an OS in Virtual Box(virtual machine). And my goal is to list all the pci devices that can be found in the system using c++ code. Here is a part of it:
#include <stdio.h>
#include <string.h>
#include <sys/io.h>
#include <stdlib.h>
#define NOT_SPECIFIED "Not specified"
int main()
{
int i, busid, devid;
FILE * file = fopen("Pcibits.txt", "w+");
for (busid = 0; busid < 256; busid++)
{
for (devid = 0; devid < 32; devid++)
{
unsigned int recvp, ven_id, dev_id, clid;
unsigned int sendp = (busid << 16) | (devid << 11) | ((unsigned int)0x80000000);
outl(sendp, 0x0CF8);
recvp = inl(0x0CFC);
char* str = new char[32];
sprintf(str, "%d", recvp);
fwrite(str, sizeof(char), sizeof(str)/sizeof(char), file);
fclose(file);
}
}
return 0;
}
But using gdb I struggle with the error like this:
Traceback (most recent call last): File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
<b
Program received signal SIGSEGV, Segmentation fault.
0x000000000040075a in outl (__value=2256549650, __port=3320)
at /usr/include/x86_64-linux-gnu/sys/io.h:125
125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port))
What is wrong with it? As I realize the program fails on the outl-step.
Please help!)