FAQ Database Discussion Community


Codelite debugger error: Failed to locate gdb! at '/usr/bin/gdb'

c++,debugging,gcc,gdb,codelite
So I have just installed codelite on Ubuntu trusty (14.04) x64 Everything seems to be working fine but when I try to run the debugger I get the error in the question title and it just stops there and does nothing. I have searched far and wide and can't find...

Examining strings using gdb

assembly,gdb,att
I would like to know how to view command line arguments passed to a function using gdb. To test this I compiled the following code .global main main: pushl %ebp movl %esp, %ebp movl $1, %eax movl $0, %ebx int $0x80 with gcc -Wall -Wextra -g -m32 args.s to invoke...

trying to understand this instruction in context w. Segment registers

assembly,x86,gdb
I am trying to understand this instruction: 0x80496fa <yellow_preflight+18>: mov eax,ds:0x804c220 and these are the register values at runtime: EAX: 0x000000D2 EBX: 0xB7FB6FF4 ECX: 0xBFFFF438 EDX: 0xBFFFF3A4 o d I t S z A P c ESI: 0x00000000 EDI: 0x00000000 EBP: 0xBFFFF468 ESP: 0xBFFFF450 EIP: 0x080496FF CS: 0073 DS: 007B...

Confusion in Word Size in x86

assembly,x86,gdb
I have the following code, in x86 assembly, which tries to print X on the screen: mov ah , 0x0e mov al , the_secret int 0x10 mov al , [the_secret] int 0x10 mov bx , the_secret add bx , 0x7c00 mov al , [bx] int 0x10 mov al , [0x7c1e]...

Set a breakpoint into LibC with gdb

linker,gdb,debug-symbols,libc
Why I cannot set a breakpoint (using gdb) in an exported function within LibC? As being Libc dynamically linked, it must contains the symbols of the functions it exports. Shouldn't I be able to set a breakpoint to any of these functions? I merely tried to do: (gdb) b [email protected]@GLIBC_2.2.5...

How to set breakpoints and make it break when debugging core dump with gdb?

gdb,coredump
How to set breakpoints and make it break when debugging core dump with gdb? When I use the command "gdb program core", the process halt at the crash point, how can I make the process break before halting there. If I cannot make it break, which commands I can use...

Debug information file conventions for Red Hat/Fedora?

linux,debugging,gdb,redhat,lldb
According to lothar's answer at How to generate gcc debug symbol outside the build target, I can create a two part executable - the stripped executable and the debug information file. After creating the stripped executable and the debug information file, I install the executable as normal (with make install)....

How do I switch from lldb to gdb debugger types?

xcode,debugging,gdb,lldb
I have been looking around for quite a while trying to figure out how to switch from lldb to gdb and could not find anything on how to switch between the 2 in Xcode 6.1. I am trying to debug my app and I might be able to figure it...

Best way to print information when debugging a race condition

c,debugging,gdb,printf,race-condition
I am debugging an application to fix a segmentation fault that I suspect to be caused by a race condition. I'd like to put some print statements in the code, but I know for experience that adding calls to printf is not recommended since this could change the behavior of...

Can't select GDB in Qt Creator on Windows

c++,windows,gdb,qt-creator
I've selected GDB instead of CDB as the debugger in Qt Creator on Windows: But when I start debugging a program, it fails with this error: Unable to create a debugger engine of the type "No engine" It works if I select CDB from the Combo. Why am I getting...

gdb debugging process after exec call

gdb,exec
I don't know how to debug after the process after calling execle. I've looked at other websites and some suggested using set fork-follow-mode child, which helped me get into the fork. However, after the fork, I exit into the main function and never get into the program I am exec'ing....

this pointer gets set to null when entering function call stack - happening with Google Test under gdb

c++11,gdb,cygwin,googletest,g++4.8
(gdb) list 95, 195 95 int BishopArranger::FillAndRecurse(int cursor) 96 { 97 if (cursor == _solutionVec.size()) 98 { 99 return 1; 100 } 101 102 unordered_set<tuple<int, int>> candidates = GetCandidates(cursor); //kn 103 if (candidates.empty()) 104 { 105 return 0; 106 } 107 108 int sum = 0; 109 for (unordered_set<tuple<int, int>>::iterator...

Displaying IEEE 754 floating point representation in GDB?

floating-point,gdb
When I ask GDB to print a real in binary, I get this: (gdb) p/t 5210887.5 $1 = 10011111000001100000111 According to this, 0 10010101 00111110000011000001111 is the expected value. Aligning them, 1 0011111000001100000111 0 10010101 00111110000011000001111 And it looks like GDB is giving me the integer representation after rounding. Thing...

how to make gdbserver accept more than one connection?

gdb,kernel,qemu,gdbserver
I'm debugging an operating system (kernel + one user space application) within qemu, using gdb connected to gdbserver. Since i'm in presence of two binaries, i would like to connect to gdbserver firstly with the kernel binary, and secondly with the user space binary so that i could switch from...

What languages can be debugged under gdb and how [closed]

python,ruby,gdb
I've read here that gdb can be used to debug languages like Python or Ruby. How is it possible? Which another languages can gdb debug? How to debug those languages under gdb?

R packages: breakpoint setup for C function with gdb in Debian (Testing)

c,r,debugging,gdb,debian
I'd like to debug a C function from a package of mine. I would like to check execution with gdb, although i find difficulties to set breakpoints. Following 4.4.1 Finding entry points in dynamically loaded code from Writing R Extensions: 1) Call the debugger on the R executable, for example...

Using the Macro SEC_IS_BEING_DEBUGGED_RETURN_NIL in iOS app

ios,objective-c,xcode,gdb,cycript
I learnt about the below piece of code, which is claimed to prevent Method Swizzling to some extent. #ifndef DEBUG SEC_IS_BEING_DEBUGGED_RETURN_NIL(); #endif But while including in my project for testing, I get an error. Implicit declaration of function 'SEC_IS_BEING_DEBUGGED_RETURN_NIL' is invalid in C99 Can someone help me out on this...

dsym file UUID doesn't match the one in xx, No symbol table is loaded in eclipse CDT

c++,gcc,gdb,eclipse-cdt,symlink
I am trying to debug a C++ project in eclipse CDT. It builds fine and runs fine. I don't know what is wrong. I wonder if there's any link that I set wrong. I am getting this error: warning: dsym file UUID doesn't match the one in /Users/project-path/src/simple_client No symbol...

gdb can't access memory address error

c,gdb
here is my disas code: 0x0804844d <+0>: push %ebp 0x0804844e <+1>: mov %esp,%ebp 0x08048450 <+3>: and $0xfffffff0,%esp 0x08048453 <+6>: sub $0x20,%esp 0x08048456 <+9>: movl $0x8048540,(%esp) 0x0804845d <+16>: call 0x8048310 <[email protected]> 0x08048462 <+21>: lea 0x1c(%esp),%eax 0x08048466 <+25>: mov %eax,0x4(%esp) 0x0804846a <+29>: movl $0x8048555,(%esp) 0x08048471 <+36>: call 0x8048320 <[email protected]> 0x08048476 <+41>: mov...

Eclipse Luna GDB debugger support

c++,eclipse,gdb,eclipse-luna
I'm having some issue with gdb on my mac running 10.8.5. Specifically the GDB install is not code signed and must be ran as root. This has become problematic and limits my ability to utilize GDB from with in eclipse luna. I have tried 99% of the options available to...

How to convert a gdb Value to a python numeral object while debugging C program

python,c,gdb,gdb-python
I'm using python2.6's gdb module while debugging a C program, and would like to convert a gdb.Value instance into a python numeral object (variable) based off the instance's '.Type'. E.g. turn my C program's SomeStruct->some_float_val = 1./6; to a Python gdb.Value via sfv=gdb.parse_and_eval('SomeStruct->some_double_val'), but THEN turn this into a double...

Examining ASCII

c,gdb,ascii
How can I get the ASCII representation of hexadecimal values in the memory by examining in gdb? The gdb command x/[repeatCount] [memoryAddress] gives me hexadecimal 32-bit values starting at memoryAddress repeatCount times but I want the readable text/String which is represented by this data. How do I do that? This...

execute multiple gdb commands in emacs

c++,emacs,gdb
If there is a way to do this natively in gdb, something like 'load script', then feel free to ignore the emacs part of this question. I frequently wind up doing the following in a pretty high-count loop: start gdb (in emacs if that helps). set several breakpoints (same breakpoints...

how can I prevent arm-none-eabi compiler generating main symbol

gdb,cross-compiling,debug-symbols
I'm using arm-none-eabi to compile source file. after compiling and generating elf file. I got the following symbols using nm command 00021da8 T ISR_Init U main U malloc 010008b0 D MASTER_AHB_MAP I'm using gdb to debug, but I have problem with main symbol which is not defined. gdb generate following...

Eclipse C++ GDB debugger for Mac

c++,eclipse,osx,gdb,osx-mavericks
i've been trying for a whole day to use Eclipse but i failed every time. I know that i may be wrong and i do know that there are a lot of people out there who are working hard for an open source project, but if i can't use a...

redirect I/Os in GDB in MI mode

gdb
with normal interpreter, one can run a program with redirected inputs and outputs like this: run < input_file > output_file In MI mode, run command equivalent is -exec-run but it does not take argument for I/O redirection and I did not find any dedicated command. What is the way to...

Creating shared_ptr seems to cause segfault

c++,segmentation-fault,gdb,valgrind
I have the following function static node_ptr make_node_ptr() { return node_ptr(new node()); } where using node_ptr = std::shared_ptr<node>; I tried to find my segmentation fault with valgrind and gdb. In both I get more or less the same stack trace. Program received signal SIGSEGV, Segmentation fault. 0x00007fff8f5d7e82 in szone_malloc_should_clear ()...

Examining local variables returned function

c,gdb,stack-trace
I have a coredump of a process that has crashed (hard to reproduce). I have figured out that something goes wrong in a function that has just returned (it returned a NULL pointer rather than a non-NULL pointer). It would be of great help for me to know the contents...

What does cmp %eax,0x80498d4(,%ebx,4) mean?

c,assembly,x86,gdb,att
I know there are some other questions similar to this, but I'm still having trouble understanding the () part of it. Could someone spell this syntax out for me? Thanks.

GDB and LLDB “swallow” status set by child process in OS X

gdb,fork,osx-yosemite,lldb,sigsegv
Given the following code: #include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/wait.h> int main(int ac, char** av) { int status; pid_t cpid = fork(); if(0 == cpid) { /* Child */ return *(volatile int*) 0; /* exits with signal 11 */ } else { /* Parent */ do { waitpid(cpid,...

How to disable “Type to continue, or q to quit” in gdb?

debugging,gdb
I want to automatise gdb, and waiting for the user input is undesirable. How to disable the message "Type <return> to continue, or q <return> to quit" in gdb?

How to force a breakpoint from .gdbinit?

gdb,breakpoints
When I set a breakpoint in my .gdbinit using: b foobar I get this: Function "foobar" not defined. Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal] Now the first line is understandable, because the function resides in a shared library. However,...

finding a memory allocation error with omnet++

c++,gdb,std,valgrind,omnet++
I am doing networks simulations under omnet++ & veins(v2.0-rc1), for this purpose I experiment 4 scenarios with 20 repetitions for both one. I am getting some errors (i guess that is a memory allocation error) during the simulations of the 3rd & 4th scenarios wich share a common functionnality (ack)....

Weird behaviour of GDB

c++,gdb
I've been trying to debug a little thingie, and almost went insane while trying to do so. After several hours of figuring out the problem, I finally have a snippet of code that is the root of my problem: #include <iostream> #include <vector> #include <stack> using namespace std; int main()...

What is gdb -i=mi means

linux,emacs,gdb,emacs24
When starting the gdb from emacs, emacs asks if the gdb should be started as gdb -i=mi The option -i is not defined in the manpage of gdb. If the gdb is invoked from command line with option -i=mi it works. So it must be specific to gdb. Where is...

eclipse debugger - breakpoint unexpected behaviour

eclipse,debugging,gdb
I need some help with using Eclipse breakpoints. I am working on multithread c++ application using Eclipse Luna Service Release 2 RC3 (4.4.2), with GDB 7.1, on ubuntu 10.04 32-bits. I manage to put and stop on breakpoints but on continuing I don't get the debugger stop on the same...

how stack differs in 32 bit and 64 bit processors

c,assembly,gdb,disassembling
i disassembled the following code in gdb for both 32 bit and 64 bit intel processors. void main() { 5 char *args[2]; 6 7 args[0] = "/bin/sh"; 8 args[1] = NULL; 9 execve(args[0],args,NULL); 10 exit(0); 11 } Following are the assembly code generated. For 64 bit Dump of assembler code...

how to use a GDB input file for multiple input

c,input,gdb
EDIT: GDB was not the issue. Bugs in my code created the behaviour. I am wondering how GDB's input works. For example I created the following small c program: #include <stdlib.h> #include <stdio.h> int main(){ setbuf(stdout,NULL); printf("first:\n"); char *inp; size_t k = 0; getline(&inp, &k, stdin); printf("%s",inp); free(inp); // read...

How can I debug the Bourne Shell with gdb?

bash,gdb,tar
I built a toolchain script to prepare a Linux build environment. The script can be found here: https://github.com/mynameismevin/prometheus/blob/toolchain/ptool-make.sh The script runs perfectly until after the Perl section around line 416. After Perl is done, when it goes to unzip sed, it complains with this error: tar (child): sed-4.2.2.tar.bz2: Cannot open:...

FIXED: C++ server/client program: “Connection refused”

c++,c,sockets,gdb,client-server
I'm writing a simple program to transfer files from server to client (both on the same computer for now). Using "telnet 127.0.0.1 [port]", I can succesfully get the file from the server, but when I run the client, the server refuses connection. I suspect that the client is trying to...

GDB Compiling Issues

gdb,powerpc
I want to cross compile GDB for powerpc and I've been going through this link (https://benakiva.wordpress.com/2007/01/15/cross-compiling-gdb-for-powerpc-platform/) but on running the command I am getting the following errors: configure: warning: –target=powerpc-linux: invalid host type configure: warning: –enable-sim-powerpc: invalid host type configure: error: can only configure for one host and one target...

Unable to create a debugger engine of the type “No engine”

c++,windows,gdb,qt-creator
I just installed Qt Creator (Windows 64 bits) and I am checking that everything works as expected. At this point the only problem I have is related to the debuggers. Firstly I tried adding gdb manually (gdb.exe) and some problem about python popped-up, so I added gdb-python (gdb-python27.exe) and the...

Is there a C debugger for zOS? [closed]

c,debugging,gdb,mainframe,zos
Is the a c debugger for zOS? I know there is XDC, but I'm not really interested in the assembly. I would rather have one that focuses on C.

How to display value having RIP relative address in gdb?

assembly,gdb,x86-64
I'd like to display an integer which lays in global.variable+8(%rip) How can I do it? And what exactly does this address mean? It's an address of global.variable + %rip + 8, isn't it?...

c++ Crash when shared_ptr goes out of scope…after running at least 100,000 times successfully

c++,segmentation-fault,gdb,shared-ptr
This code has run 100,000's of times before crashing around (6hrs of running in tests). When the crash happens it occurs when shared_ptr goes out of scope...the purpose of this function is to fill the passed in vector of shared_ptr ( in this case), with the messages filtered by type...So...

Which versions of gdb and gcc allow watching rvalue references?

debugging,c++11,gcc,gdb,rvalue-reference
I am using GDB 7.8.0.20140729-cvs and GCC 4.8.2. Whenever I try to print the value of a variable referenced by an rvalue reference, I get an error from the debugger complaining about an unknown type, forcing me to manually cast the T && to a T *. Are there newer...

Stopping debugger at an optimized out line of code

c++,gcc,gdb
If I want to stop in an empty block of code it's always a problem. if (...) { // I want the debugger to stop here! } If I add an arbitrary line of code which does not affect program behaviour it is likely to be optimized out, depending on...

Assmeby SUBQ and dest registers

assembly,gdb
So I wrote a code in assembly and I was trying to validate my output with GDB and found a mind puzzling thing!! So initially: %r15 == 0 and %rsp == 0x7fffffffe378 then #inst src, dest movq %rsp, %r15 %r15 == 0x7fffffffe378 and %rsp == 0x7fffffffe378 then subq $88, %rsp...

Running daemon as regular application (debugging in KDevelop)

c++,debugging,gdb,daemon,kdevelop
There are tools that enable one to run a console command or a console application as a daemon. To "daemonize" it, so to say. Is there a way to run a daemon as a regular console application? I'm coding in KDevelop and don't see any options for daemon debugging. Thanks...

gdb debugging stripped executables

linux,debugging,gdb,stripping
I have an executable provided as is. The creators have compiled it with minimal dependencies and no symbols. When I load it in gdb it sais: ...(no debugging symbols found)...done. I would like to do step-by-step debugging in the assembler code with the optional exit point in case the execution...

Is there a simple way to see a list of global variables in GDB?

gdb
I have an application that needs to use GDB/MI to get information about a process. Right now I am setting a breakpoint in main and running the process. By using "info locals" I can get a neat list of the local variables in the current frame. While this is good,...

How set breakpoint to class member variable in gdb

c++,gdb,breakpoints,watchpoint
How can I set breakpoint (or watchpoint) to member variable in class for all instances of this class? I have tried set breakpoint on line in class with this member variable but this is not working....

Debug information file conventions for Debian/Ubuntu?

linux,debugging,gdb,debian,lldb
According to lothar's answer at How to generate gcc debug symbol outside the build target, I can create a two part executable - the stripped executable and the debug information file. After creating the stripped executable and the debug information file, I install the executable as normal (with make install)....

gdb:How to print value at memory address in ASM

assembly,x86,gdb,reverse-engineering
0x08048c62 <+0>: sub $0x2c,%esp 0x08048c65 <+3>: lea 0x1c(%esp),%eax 0x08048c69 <+7>: mov %eax,0xc(%esp) 0x08048c6d <+11>: lea 0x18(%esp),%eax 0x08048c71 <+15>: mov %eax,0x8(%esp) 0x08048c75 <+19>: movl $0x804a73d,0x4(%esp) 0x08048c7d <+27>: mov 0x30(%esp),%eax 0x08048c81 <+31>: mov %eax,(%esp) 0x08048c84 <+34>: call 0x80488d0 <[email protected]> => 0x08048c89 <+39>: cmp $0x1,%eax How do I print out what is...

Is it possible to modify variables in an executable without symbol tables in GDB?

c,gdb
I've been told it is possible, but it seems every time I try I continuously get an error saying "No symbol tables have been loaded." Have I been tricked, or is it in fact possible?

Remote debugging of pure C program with GDB

android,c,android-ndk,gdb,gdbserver
I am trying to remotely debug a pure C program on an Android device. The Android device (target) is connected via USB to a host machine. What I did was: Copied from the target the following files: /system/lib, /vendor/lib, /system/bin/app_process, and /system/bin/linker. Target: Copied gdbserver from NDK to the target...

How to debug program with custom elf interpreter?

debugging,gdb,ld,elf
I can debug some program (say /bin/ls) like this: [[email protected] ~]$ gdb -q --args /bin/ls Reading symbols from /bin/ls...Reading symbols from /bin/ls...(no debugging symbols found)...done. (no debugging symbols found)...done. Missing separate debuginfos, use: debuginfo-install coreutils-8.22-19.fc21.x86_64 (gdb) start Temporary breakpoint 1 at 0x402990 Starting program: /usr/bin/ls [Thread debugging using libthread_db enabled]...

Unknown Segfault

c,segmentation-fault,gdb
Thanks in advance for your help. I've done all the research I could trying to debug this. Adding printf's seems to change where the segfault occurs. I'm hardly familiar with gdb but somehow the program ran without issue in it. I've got some quantum observation problem going on. Let's get...

Memory location addressing in ASM

assembly,gdb,x86-64,breakpoints
I'm trying to write self modifying asm code. At some point, I try the following : (NASM compiler) start_of_code: ; ... snip ... cmp byte [rax], 0x66 jae above_label add byte[rax], 0x20 ; ... snip ... above_label: inc rax loop start_of_code gdb shows the following values at start x/8xb $rax...

Debugin UDI program by gdb

linux,gdb
The program from below asks user for his name, greetings him and then gives us his real ID. We could assume that in case of 16-letter name (or longer) the uid variable will be overwritten and the program gives us incorrect user ID. But it isn't. How to explain this...

Why does print (absolute value) gives me back ASCII code in gdb

assembly,gdb,stackframe
Here is my assambly code: 0x0804841d <+0>: push %ebp 0x0804841e <+1>: mov %esp,%ebp 0x08048420 <+3>: and $0xfffffff0,%esp 0x08048423 <+6>: sub $0x20,%esp 0x08048426 <+9>: movl $0x8,0x1c(%esp) 0x0804842e <+17>: movl $0x80484d0,(%esp) 0x08048435 <+24>: call 0x80482f0 <[email protected]> =>0x0804843a <+29>: leave 0x0804843b <+30>: ret When i type print 0x80484d0 it gives me back $1...

GDB: Append to solib-search-path

gdb
How can I append to the contents of solib-search-path? I would like to do smothing like: set solib-search-path $(solib-search-path):some/other/path ...

How do I trace “fate” of a particular value?

c,gdb,valgrind,trace
I see some value in some place, but unsure where it has originated in my program. How do I figure out where this value initially comes from? I expect the following event types to be logged: A value originated from constant, arithmetical expression or syscall - the initial event; The...

How to step over function call in gdb?

c++,gdb
I want to understand how we can do stepping over function call. For instance, in the following simplest program: #include<iostream> #include "test.h" using std::cout; using std::endl; Uint u; int main() { cout << "executin starting..." << endl; cout << u.a << endl; cout << "execution completed" << endl; } Ok,...

How to find illegal instructions in a program?

c++,c,assembly,gdb,benchmarking
I have a benchmark which is meant to run on a specific simulator, Some instructions where added to the benchmark to communicate with the simulator(not perform CPU operations), like dump stats or reset stats and so on. Now I need to run the same benchmarks on another simulator, and there...

Using GDB in 16-bit mode

c,assembly,x86,gdb
I have the following code, where I am trying to implement a function that prints string using the BIOS functions: int printString(char* string) { int i = 0; while (*(string + i) != '\0') { char al = *(string + i); char ah = 0xe; int ax = ah *...

Is there a generic format for core files?

debugging,gdb,core
I've noticed that no matter which compiler I use (gcc, llvm, clang, icc, etc.), if I get a core dump, I can almost always just throw it into GDB (or probably other debuggers, but I end up with GDB reflexively most of the time) without worrying about how the program/library...

Include source code of malloc.c in gdb?

c,debugging,gdb,malloc
How can I include/view the source code of malloc in gdb? I want to do a step by step execution in gdb, and step into malloc.c source code when any of the malloc functions is called. Currently what gdb says is: malloc.c: No such file or directory. This guy here...

C - Error is “free(): invalid next size (normal) ”

pointers,gdb,valgrind,sigabrt
I just can not find what is causing this problem. MYSQL *startup(unsigned char *path_to_file, int size_of_path) { MYSQL *con; bool path_is_file = false; bool path_is_directory = false; FILE *startup_file; int i; unsigned char buffer[LINEBUFFERSIZE]; unsigned char string[LINEBUFFERSIZE]; unsigned char c; //Allocate memory for the new file path unsigned char *path;...

My 64 bit machine can only store 4 bytes each memory location

c,memory,gdb,64bit,32bit-64bit
My computer is 64bit mac. How many bytes of information is stored in one of these locations in memory? When I tried something in gdb x /2x first 0x7ffff661c020: 0xf661b020 0x00007fff My code is #define PUT(p, val) (*((size_t *)(p)) = (val)) PUT(first, (size_t)some pointers); I use gcc -g to compile...

Dwarf Error: Can't read DWARF data from '/tmp/spyauth787438238

debugging,gdb,g++,redhat
I am trying to debug a C++ code using GDB. I can run debugger, set breakpoints and also breakpoints are hit correctly. But when I've tried to execute 'next' command when a breakpoint is hit, it throws the following error: "Dwarf Error: Can't read DWARF data from '/tmp/spyauth787438238" Also I...

GDB: dump arguments to all calls of a specific function

c,gdb,profiling
I need to profile the values passed as arguments to the standard C library function sqrt() in my program. The trivial way is to insert code to dump these values to a file before the actual call to sqrt() (e.g. a simple fprintf()). However, if sqrt() is called from inside...

Segfault when accessing a structure's member

c,pointers,segmentation-fault,gdb,c89
I'm confronted to a strange problem, my program has a segfault when i try to access a structure member but my structure's address is not NULL and I've never freed this structure. The structure's address is something like "0x8000000000" or "0x2000000000". Here is gdb's bt : Program received signal SIGSEGV,...

Forcing a program to call a function in C with an input string

c,gdb,buffer,machine-code
So I'm doing an exercise where I want to call the function void not_called() just by inputting a buffer. Basically what I want to do is use a buffer overflow to call not_called(). I'm approaching this by using a binary exploit string then using a program hex2raw (takes hex format...

How to evaluate an expression to be used for a gdb monitor command?

gdb,monitor
Inside a scripted gdb session I want to use monitor <cmd> where cmd should contain the address of a symbol. For example: monitor foobar &myVariable should become to: monitor foobar 0x00004711 Because the remote side cannot evaluate the expression. Whatever I tried, the string "&myVariable" gets sent instead of the...

gdb exiting instead of spawning a shell

c,bash,shell,gdb,suid
I am trying to exploit a SUID program. The program is: #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> #define e(); if(((unsigned int)ptr & 0xff000000)==0xca000000) { setresuid(geteuid(), geteuid(), geteuid()); execlp("/bin/sh", "sh", "-i", NULL); } void print(unsigned char *buf, int len) { int i; printf("[ "); for(i=0; i < len; i++)...

Dump debug_loc section from executable

linux,gcc,gdb,dwarf
How do I dump debug_loc section from an executable on Linux if default options (-g) are provided to GCC while compiling a C file? I use readelf linux utility. GCC by default produces DWARF info in DWARF4 format, so if I pass -g-dwarf2 I can see .debug_loc section but how...

How to properly use gdb?

multithreading,debugging,segmentation-fault,gdb
I want gdb to display only my code (skip the included headers). I'm struggling with the segmentation fault thrown randomly by my multithreaded program. In gdb I can see this: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffeffff700 (LWP 27533)] 0x0000000000409939 in std::thread::joinable (this=0x0) at /usr/include/c++/4.9.2/thread:162 162 {...

How to drill down into shared_ptr [Netbeans, clang++, gdb]

c++,debugging,gdb,clang,netbeans-8
I'm using Netbeans C++ 8.0.2 clang++ (Ubuntu clang version 3.6.0-2ubuntu1 (tags/RELEASE_360/final) (based on LLVM 3.6.0)) gdb (GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9) In my "C++ Simple Tests," whenever I inspect a variable that is a shared_ptr, all I see for value is: std::shared_ptr (count 1, weak 0) 0x64d3a0 or similar. There...

gdb: size of a struct that isn't in context?

c++,c,debugging,struct,gdb
I am sometimes experiencing a need to know a size of a struct which is not in the scope currently (not even on the stack, that is frame-related commands won't help). Most often that happen when I am debugging client and server (written in different languages), and having one of...

How to debug global variable corruption in c program in arm platform? [closed]

c++,c,gdb,memory-corruption
Somewhere in my code an integer global variable is getting corrupted and it is actually causing a failure in an if condition check.The condition check is failing due to junk value assigned to the variable. Which would be the best approach to solve this problem? Since my target platform is...

GDB breakpoint command list

gdb,breakpoints
When I set a breakpoint in GDB and attach a command-list to it, if I execute a "next" in this command-list, the following commands are ignored, which is normal (See https://sourceware.org/gdb/current/onlinedocs/gdb/Break-Commands.html#Break-Commands). However, it could be very useful for me to override this limitation... So, is it possible to execute a...

Under Linux, is it possible to gcore a process whose executable has been deleted?

linux,debugging,gdb,gcore
Programming on CentOS 6.6, I deleted an executable (whoops, make clean) while it was running in a screen session. Now, unrelated, I want to gcore the process to debug something. I have rebuilt the executable, but gcore doesn't accept the replaced file. It knows the original file was deleted and...

Can't access to Object stored in multidimensional vector (C++)

c++,debugging,memory,vector,gdb
I try to access to an object stored in a multidimensionnal vector : It is an object of the class Case. Carte::Carte(int x, int y) { this->x = x; this->y = y; for(int i; i<x; i++){ carte.push_back(std::vector<Case*>()); for(int j = 0; j<y; j++){ Case aCase(i, j); carte[i].push_back(&aCase); } } }...

nm versus gdb break

gdb,virtual-address-space,nm
I am working on Ubuntu 14.04 LTS. I have an executable file exec compiled from file.c. The file.c makes use of functions from a static library. For example, let's says that fubar() is a function of the static library that is used in file.c. This is something that I have...

Cannot load shared libraries in gdb

linux,gdb
I'm trying to run application in gdb but it seem's I have problem with debbuger. I cannot load shared libraries all the ways I've tried to. Libraries are stored in /usr/local/lib64 and environment is ok: echo $LD_LIBRARY_PATH /usr/local/lib64:/home/user/lib When I run appllication in gbd, the following happens: (gdb) set solib-search-path...

GDB core backtrace Bogus adresses

c++,gdb,g++,core,backtrace
When I compile same code with g++ with -o2 flag I can backtrace successfully without any Bogus adresses. Like; 0x08156079 in CItem::GetValue (this=0x3adb0f00, idx=0) at item.cpp:957 0x081b123c in quest::item_has_flag (L=0x3af9bdc0) at questlua_item.cpp:155 0x08363cba in luaD_precall (L=0x3af9bdc0, func=0x3b1cedd8) at ldo.c:249 0x0836ba86 in luaV_execute (L=0x3af9bdc0) at lvm.c:637 0x08363fad in resume (L=0x3af9bdc0, ud=0xffffa164)...

Missing gdb symbols in Backtrace?

java,gdb
I am running this test because I want to see the stacktrace of a program. Below is my program: public class NanoTime { public static void main (String[] args) { long StartTime = System.nanoTime(); StringBuffer buffer = new StringBuffer(); for(int i=0; i<1000; i++) { buffer.append("a"); } long EndTime = System.nanoTime();...

How can I get GDB to advance to the correct place?

assembly,gdb,microblaze,ovp
I am using GDB with Microblaze assembly running under OVPsim. I have the following problem: (gdb) advance PTE_entry_empty 0x00000598 in PTE_entry_empty() 1: x/i $pc => 0x598 <PTE_entry_empty+36>: mfs r6, rear ie., although I ask GDB to advance to a particular symbol it goes well beyond it - and even seems...

Remote Debugging with gdb

debugging,gdb
Hello Guys I am using gdb to debug the C code. The gdb process is running on a Cisco switch image. I have the memory address of some variable which is a string and it has the memory address say 0xfffffff. How can i know through which function this string...

Seg Fault on cin. Tried the endl thing. Lousy at gdb

c++,vector,segmentation-fault,gdb
I getting a strange segfault I don't understand. [email protected] ~/code/byun-sp15 $ g++ -g all_pairs.cpp [email protected] ~/code/byun-sp15 $ ./a.out Please enter filename: table.txt Segmentation fault As you can see from the cout staements, it is segfaulting right in cin>>filename; Here's the main function: #include <iostream> #include <fstream> #include <vector> #include <sstream>...

How to get the symbol name of JVM native level function?

java,gdb
I would like to set a breakpoint with gdb but I don't know the corresponding symbol for the method. Is there a way to do that?

GDB backtrace without stopping

c++,multithreading,gdb,signals
I am trying to let my program run continously with GDB. Currently I have a bash script which starts GDB with my program and when it crashes it prints the backtrace and starts GDB again (endless loop). Now I added a signal handler for my program which kills specific threads...

Gdb struct values all become 0 after “next”

c,struct,gdb,elf
So my struct values are becoming 0 after a "next" command in gdb, which should have no effect. 166 RawElfSymbol *currSymb = symbolTabSec; (gdb) p *currSymb $8 = {name = 623313010, addr = 540682099, size = 1931505518, type_and_bind = 117 'u', ignored = 99 'c', section_tag = 8296} (gdb) next...

Segmentation fault strcmp in c

c,debugging,segmentation-fault,gdb,strcmp
I am trying to run a program in c that takes in a text file and string from the user and then searches the file for that string. It keeps getting a segmentation fault and gdb is pointing me towards this function but I am not sure what the problem...

Program counter changes oddly without any instruction modifying it (qemu-arm, bare metal)

assembly,segmentation-fault,gdb,arm,qemu
I'm currently trying to make a program i wrote run on a bare metal arm device. Since i'm not having the device (yet), i try to run the code on an arm emulation using qemu. i run my code with this command: qemu-system-arm -M realview-pb-a8 -m 128M -nographic -s -S...

Detect execution flow divergence

c++,debugging,gdb
I have an application that should produce the same output given the same input but it produces different outputs across executions. Is it possible to use GDB to detect divergence between executions? Is it at all possible to automate this?...

How to set breakpoints in a php script using gdb

php,gdb
I am trying to debug a php scripts via console with GDB but I am not able to set breakpoints. This is what I've done. I've created a script with this content: <?php echo "1"; echo "1"; echo "1"; echo "1"; echo "1"; echo "1"; echo "1"; And this is...

gdb giving a function name followed by a number instead of file and line number

c,debugging,segmentation-fault,gdb
I have a segmentation fault in my program, and I'm using gdb to identify where it's happening. However, I am not able to see a clear line number where the error is occurring. Below is a screenshot of my output. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 20065168...

Print addresses of all local variables in C

debugging,pointers,gcc,gdb,memory-address
I want to print the addresses of all the local and global variables which are being used in a function, at different points of execution of a program and store them in a file. I am trying to use gdb for this same. The "info local" command prints the values...