Sponsored Content
Top Forums Programming dbx - attach to process, break when crash Post 302496424 by dhzdh on Monday 14th of February 2011 04:32:47 AM
Old 02-14-2011
Let the process produce a core file

There are two ways you can deal with this problem.
The first, and most obvious one, is to run the program under the debugger (e.g.: dbx). When it crashes, you'll get the debugger's prompt and you can explore the location and causes of the crash.

Since running under the debugger may change the behavior of the program, you may want to let it run normally. If the program crashes due to certain signals (e.g.: SIGSEGV - indicating accessing a bad address, such as address 0), it can produce a core file, at least under Unix variants, including Linux. You can then use the debugger to look at the state of the program at the time of the crash and analyze the reason for the crash.

For example, if the name of the program is prog, then
use: dbx prog core
to explore the state of the program at the time of the crash.

The core file is not always produced even when the program crashes due to a signal such as SIGSEGV. The reason is that there is a limit on the size of the core file. Often, this limit is 0. You can change this limit to "unlimited" and then the core file will be produced when the need arises.
The command to change the core file size limit is shell dependent.
For example, under bash I am using: ulimit -c unlimited
under tcsh, I use: limit coredumpsize unlimited

 

10 More Discussions You Might Find Interesting

1. Programming

Process crash when allocating memory

Hi I'm currently using C++ on a HP-UX 11i system (upgrading some libraries) and am encountering a problem with the process crashing when allocating memory via a call to new (a rather large array of objects are being created). Is there a way to find out what the sizes of the stack and heap are?... (1 Reply)
Discussion started by: themezzaman
1 Replies

2. UNIX for Advanced & Expert Users

attach process from another ssh session

Hi, I was logged in on a server, by ssh, with a vim open, when the battery of my laptop got empty. When I return to the server by ssh, I can see my previous ssh session still open, and the vim process running (ttyp0). Is there a way to attach that vim to my new session (ttyp4)? Here's part... (2 Replies)
Discussion started by: raphinou
2 Replies

3. UNIX for Advanced & Expert Users

How to attach an xterm to a process/thread ?

Hi folks, I would like to know how to hook up an xterm to another process. Here is a high level view of what I am looking for 1. Main program starts 2. It creates an new xterm window 3. It then forks a second process & passes the xterm handle to it 4. The second process uses the second... (4 Replies)
Discussion started by: RipClaw
4 Replies

4. Solaris

process doesn't crash when i use the truss ??

Hi All, We a critical application running on the Sun Solaris platform. But, for some reasons the process get's killed abnormally in the production environment and not sure what was causing this. I thought i would use the truss command to trace the errors.. so i used the bellow command truss... (5 Replies)
Discussion started by: sudharma
5 Replies

5. Programming

dbx - break on access violations

Hey everyone, Is there a way to make dbx break on access violations? (2 Replies)
Discussion started by: ctote
2 Replies

6. Programming

AIX dbx - attaching to a process that is crashing

Hey everyone, I'm trying to attach to a process that is crashing so I can debug the source code. I've tried this: dbx -a PID stop at "file.cpp":line# However, nothing ever breaks. The service crashes and restarts, but I never see it hitting the code. I've tried to use a core file, but... (2 Replies)
Discussion started by: ctote
2 Replies

7. Programming

Cannot get dbx to work correctly with a running process

Hi everyone, I've been struggling with this for a few weeks now. I'm trying to debug a running process with dbx on an AIX box. The command I'm using is 'dbx -a <pid> core' There is a function I can perform in my application that crashes this process, but it does not show up as crashed in... (0 Replies)
Discussion started by: ctote
0 Replies

8. UNIX for Dummies Questions & Answers

How can I set DBX to break on an Access Violation?

I'm trying to debug a service crash, and would like to break on an access violation - is this possible? (0 Replies)
Discussion started by: ctote
0 Replies

9. AIX

How to set the break point using dbx?

Hi, I am trying to debug my project using dbx to understand the code and functionality of modules. I compiled all my C files using gcc -g flag to enable the debug option. I was able to get in to the debug mode using dbx. I was able to create breakpoints using stop at line no. "stop at... (7 Replies)
Discussion started by: Sachin1987
7 Replies

10. UNIX for Beginners Questions & Answers

Attach process with port 2222

Hi Team, is there any way, I can start any process for e.g. run a shell script (infinite loop) and attach it to port 2222? I am trying to create a scenario where an application will start running at port 2222 and I will telnet the same to confirm, application port is listening. So,... (1 Reply)
Discussion started by: vivekpandit7
1 Replies
gcore(1)						    BSD General Commands Manual 						  gcore(1)

NAME
gcore -- get core images of running processes SYNOPSIS
gcore [-s] [-v] [-b size] [-o path | -c pathformat] pid DESCRIPTION
The gcore program creates a core file image of the process specified by pid. The resulting core file can be used with a debugger, e.g. lldb(1), to examine the state of the process. The following options are available: -s Suspend the process while the core file is captured. -v Report progress on the dump as it proceeds. -b size Limit the size of the core file to size MiBytes. The following options control the name of the core file: -o path Write the core file to path. -c pathformat Write the core file to pathformat. The pathformat string is treated as a pathname that may contain various special characters which cause the interpolation of strings representing specific attributes of the process into the name. Each special character is introduced by the % character. The format characters and their meanings are: N The name of the program being dumped, as reported by ps(1). U The uid of the process being dumped, converted to a string. P The pid of the process being dumped, converted to a string. T The time when the core file was taken, converted to ISO 8601 format. % Output a percent character. The default file name used by gcore is %N-%P-%T. By default, the core file will be written to a directory whose name is determined from the kern.corefile MIB. This can be printed or modified using sysctl(8). The directory where the core file is to be written must be accessible to the owner of the target process. gcore will not overwrite an existing file, nor will it create missing directories in the path. EXIT_STATUS The gcore utility exits 0 on success, and >0 if an error occurs. FILES
/cores/%N-%P-%T default pathname for the corefile. BUGS
With the -b flag, gcore writes out as much data as it can up to the specified limit, even if that results in an incomplete core image. Such a partial core dump may confuse subsequent programs that attempt to parse the contents of such files. SEE ALSO
lldb(1), core(5), Mach-O(5), sysctl(8), sudo(8). Darwin May 31, 2019 Darwin
All times are GMT -4. The time now is 07:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy