using dbx: I can't make it watch a variable change?! Help, please!


 
Thread Tools Search this Thread
Top Forums Programming using dbx: I can't make it watch a variable change?! Help, please!
# 1  
Old 06-24-2010
using dbx: I can't make it watch a variable change?! Help, please!

(I have mentioned about this situation and arisen problems in another thread: Is there a limit for a code line length in C?, but those questions are OffTop for that subject; so I open a new topic, here.)

The main problem is that I have some situation in my program where memory has been changed unexpectedly and inconsistently.
I have a source where some weird condition unstably produces the Segmentation Violation.
The error could disappeared or be moved into different place by adding/removing some line of code (some printf() and additional declaration/definitions.)
By 'dbx', I see how some variable changed unexpectedly into impossible values.
I see the resulted change when the variable is used, but I can't catch when it is happening (when the variable is changed!)

I agree with Corona688 in the mentioned thread:
Quote:
Originally Posted by Corona688
...

What you're describing sounds more like a buffer overflow. Writing past the end of an array on the stack can mangle other local variables, causing behavior like you describe. Moving around lines of code may change what gets mangled or at least when, changing the behavior.
.. and I am trying to use dbx to figure that out.
But dbx doesn't want to work for me.
I am new for dbx and not sure the reason of my problems with dbx (incorrect usage or the dbx problem in our system) and search on web does not help. That why I asking if anyone here have some related experience with dbx and could advise me how to handle this situation

I did try to set the 'check', 'change' and 'cond', but not able to get it work:

Code:
(/opt/SUNWspro/WS6U2/bin/sparcv9/dbx) stop cond (cnr_totl > 3)
dbx: events requiring automatic single-stepping are unavailable for MT programs
(/opt/SUNWspro/WS6U2/bin/sparcv9/dbx) stop change cnr_totl
dbx: events requiring automatic single-stepping are unavailable for MT programs
(/opt/SUNWspro/WS6U2/bin/sparcv9/dbx) trace cnr_totl
dbx: events requiring automatic single-stepping are unavailable for MT programs

I am not sure if I use it incorrect or it does not work in our system (other developers or did not try that or was not able to get it work here.)
About the MT - from my side the program is not multy-threaded, but maybe something done by library?!
Getting the 'threads' by 'dbx' it shows only one thread. I do not understand why 'dbx' complains like that!
Code:
(/opt/SUNWspro/WS6U2/bin/sparcv9/dbx) threads
*>    t@1  a l@1  ?()   breakpoint              in main()

But I was able to set 'check -all'.

By that I have some warnings, but I could not have any useful information from that!
For example, it says:
Code:
Read from uninitialized (rui) on thread 1:
Attempting to read 4 bytes at address 0xffbfd184
    which is 140 bytes above the current stack pointer
Variable is 'lnSecond'
stopped in InsertInt at line 955 in file "mrpf.c"
  955               lnFirst, lnSecond, lnThird, lnFourth);

That is sounds like some pointer was already changed incorrectly, but when that happens I have no idea.
In fact, I already see that memory has been overwritten already some how. I have some counters that I know not going to be more than 2-3 thousands, but it already displayed (some printfs) garbage:
Code:
ln-1453:   ln_nmb=1681535539, p_cnt=1681535539, cnr_pm_1=1681535539

.., but the dbx did not react on inappropriate access of these counter's memory.

Please, help me to use 'dbx' in correct way, if it is possible!
Maybe you have any idea how I can catch a problem in my program?

(It is not reasonable to ask me to provide code here as the program is huge, I do not know where the problem is and, finally, it greatly depends on other programs, utility, library and local tools.)
(Sorry for long post; I have tried to give enough information to understand the situation.)
# 2  
Old 06-24-2010
If the multithreading may be happening in a library, what libraries are you using?
# 3  
Old 06-25-2010
(Editting - no issue anymore - adding the final notes to this - 09/26/2010)
Quote:
Originally Posted by Corona688
If the multithreading may be happening in a library, what libraries are you using?
Speaking about library I, acctualy, mean our system libraries, as there much functionality is compiled to dynamic libraries and attached in compilation.

Why I am speaking about our stuff with 'maybe', it is because it done in 'chane inclusion', like the 'common_tools' also includes other libraries, that would include again some libraries..
It is not simple and worthless to spend time to search if anywhere it would use some threads.
(BTW, the Oracle libraries: don't it use some extra threads? The program uses Oracle.)
-
Yes, this connection makes the program multy-threaded (alex_5161)
Anywhay, I've been able to get dbx to watch for some address change, acctually, access.
By 'stop access w <var_addr>'. (the 'w' - access mode = 'write')

Not sure if that make any difference, but before that I've set 'check -all' that load and do something.

Also it was useful (and important) to use such commands as
'whereis -a <address>'
to see the variable name, that using that address;
'whereis <var>'
that gives the variable name with full scope specification (and all other location for the same var, if exist in other functions or files)...

So, I've found the overflawed string - char-arr, that I've get concatenated in inappropriate place in loop. That stuff I have corrected.

But, on long run (in reality it is processing arround million records) I have another Segmentation that by now I do not understand why it is happening.
It is raised by 'strstr()' having, it seems to me by now, appropriate pointers..
So, I am not even ready to present a question regarding that situation..
-
That was the same situation, but harder to find. I have get 'secuired concat.' (with attention to allocated size) and have that disapeared. (alex_5161 - 09/26/2010)
I still have a question about the 'dbx' - I can't get the 'cond (<var> == <val>)' to work.
I try to use it with 'stop cond (..)', but have the same responce as I've shown earlier here.
-
This will not work in multy-threaded program.
In 'dbx' by it's help:
Code:
(/opt/SUNWspro/WS6U2/bin/sparcv9/dbx) help event watchpoint
event watchpoint (topic)

There are two generations of watchpoint mechanisms available under dbx.

1) Use:

        stop|when|trace access <mode> <addr-exp> [ , <byte-size-exp> ]
....

This mechanism is mostly implemented in the kernel (see proc(3) under PCWATCH
for more details) and offers the following advantages over the older
mechanisms:
....

2) Use:

        stop|when|trace cond <cond-expr>
        stop|when|trace change <variable>
...
Because of the single-stepping they are very slow and do not apply to
multi-threaded applications.


No any question in this topik from me.
Thanks to all for your time and efford!

Last edited by alex_5161; 09-28-2010 at 01:18 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make change to variable value inside of awk script

Hello, I have text data that looks like this, Mrv16a3102061815532D 6 6 0 0 0 0 999 V2000 -0.4018 1.9634 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 1.5509 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 -1.1163 0.7259 ... (9 Replies)
Discussion started by: LMHmedchem
9 Replies

2. Shell Programming and Scripting

Add character to specific columns using sed or awk and make it a permanent change

Hi, I am writing a shell script where I want that # should be added in all those lines as the first character where the pattern matches. file has lot of functions defined a.sh #!/bin/bash fn a { beautiful evening sunny day } fn b { } fn c { hello world .its a beautiful day ... (12 Replies)
Discussion started by: ashima jain
12 Replies

3. UNIX for Dummies Questions & Answers

Will authconfig make permanent change or lost after reboot?

Hi, I made following configuration to create user directory: # authconfig --enablemkhomedir --update But the directory is created as permission 755, I'd like to modify the script to change directory access permission to 700, where is the script which copies /etc/skel to /home... (0 Replies)
Discussion started by: hce
0 Replies

4. UNIX for Dummies Questions & Answers

Need to make change in a file

i want to make null file using awk.. (7 Replies)
Discussion started by: Adhi
7 Replies

5. Shell Programming and Scripting

Change Variable Value from Multiple Scripts and Use these Variable

Hi to All, Please find below details. file_config.config export file1_status="SUCCESS" export file2_status="SUCCESS" file_one.sh I am calling another two shell script from these script. I need to pass individual two script status (If it's "FAILED") to file_main.sh. file_main.sh I... (2 Replies)
Discussion started by: div_Neev
2 Replies

6. UNIX for Dummies Questions & Answers

Cannot make sudoers change work

I logged in as root and visudo'd /etc/sudoers. I found several users with the username ALL=(ALL) ALL entries and added an account after the last one. Saved the file. When the user logs in and does "sudo su -" they are prompted for their password and then told they are not in the sudoers file.... (8 Replies)
Discussion started by: rpm_on_lnx
8 Replies

7. UNIX for Dummies Questions & Answers

how to change the destination directory of a make install

Hi there, I'm installing the sleuthkit from sources (because the debian package is crap). So I go threw the process of wget + tar + configure + make + make install. At the end, all the executables and libraries are in /usr/local/bin/, /usr/local/lib/, /usr/local/share/... How can I do to... (3 Replies)
Discussion started by: chebarbudo
3 Replies

8. UNIX for Dummies Questions & Answers

How to make ulimit change permanent

ulimit -a gives the following output:$ulimit -a time(seconds) unlimited file(blocks) 2097152 data(kbytes) 131072 stack(kbytes) 16384 memory(kbytes) unlimited coredump(blocks) 32768 nofiles(descriptors) 400 vmemory(kbytes) 147456 Abot output... (3 Replies)
Discussion started by: nervous
3 Replies

9. Shell Programming and Scripting

How to make the same change in multiple shell scripts?

I would like to make the same change in multiple shell script files and would like to know if anyone can be of some help? I would appreciate it. (4 Replies)
Discussion started by: rdakhan
4 Replies

10. UNIX for Dummies Questions & Answers

How to change current working directory for dbx on UNIX?

How to change current working directory for dbx on UNIX? means I'll run pgm from one directory , but getcwd() should return path which I want to be, which is not d current dir :) (5 Replies)
Discussion started by: login0001
5 Replies
Login or Register to Ask a Question