C++ :: Debug Multithreaded Application In Unix Environment?

Mar 3, 2013

How can we debug the multithreaded application in unix environment?

View 1 Replies


ADVERTISEMENT

Visual C++ :: Static Class Member In Multithreaded Environment

Nov 21, 2014

I have a class having static member.I have get and set methods which will Get and Set Values to this variable. In a multithreaded application does it have any thread safety issues.

Class a {
static int b;
void Set (int c);
int Get();
};

View 10 Replies View Related

C++ :: Debug Function For Application - Output Values List

Jul 11, 2012

I'm trying to write a debug functions for my application so I can see all the values I like to. My goal is it looks like this:

Code:
void Debug(std::message, ...)

So that I can call it like this:

Code:
Debug("Error: %i, %i", 34, 35);

How I can work with %i, or if there are better solutions. This is what I've so far (not much), just a basic idea:

Code:
void Debug( std::string message, ...) {
va_list list;
va_start(list, message);
??? va_arg(list, ?? );
va_end(list);
// here message should contain everything and be ready for output ?
cout << message << endl;
}

View 3 Replies View Related

Visual C++ :: Slow To Load Application With Windows Debug Symbols?

Dec 31, 2013

I dumped all symbols into C:WindowsSymbols folder, It takes more than 2 minutes to load an application which really surprises me. Why and when should I use those symbols?

View 1 Replies View Related

C++ :: Multithreaded Server And Client

Apr 28, 2014

I need the code for multithreaded server and client code. one server and two or more client connect to server.

Without fork(),semaphore(),etc

View 1 Replies View Related

C++ :: Multithreaded Program Using Modal Dialog Box

Apr 9, 2014

I am writing a piece of code using gtkmm and ran into this problem. This is how i am getting the problem.

class someobj {
Gtk::Window* pWindow;
// Thread 2
void run() {
while(1)

[Code] ....

I think it is not dependent on gtkmm because thread 2 is blocked where as the parent thread is running which is causing the problem.

View 6 Replies View Related

C :: Program That Does UNIX Strings

Jun 4, 2014

I am not a programmer, C-wise. Mainly a shell scripter. any C program that I can use that can work like UNIX strings | grep "pattern"...At the moment, on a binary file, I am using UNIX strings and then grep for a pattern and print out that line and does some awk -F":" thing. This is manageable for when the binary file is 50M but not for where files are 100M and above. I mean it still works but takes longer since strings work on the entire file.

Basically the information that I am trying to extract from the binary file is some type of header that is contained in a file. I am thinking of maybe writing a 'simple' C program that will read the first few bytes of the binary file and then print the line that contains the string that I am looking for. I don't believe the header is at the end of the file but more in the beginning. I am wanting to extract the header information to be able to rename or make a copy of the binary in a more user-friendly name.

Any good reference/link to a sample program on reading a binary file maybe. Main reason why I am wanting a C program is because the binary file can be on Windows or *nix.

View 2 Replies View Related

C++ :: Converting UNIX Code To Windows

Aug 15, 2013

trying to convert some C++ code written for LINUX/MAC to run on windows. I think signal handling is not as developed for Windows but the error I am getting is that the struct I am trying to use is undefined. I have #include <csignal> at the top and the line giving the problem simply says "struct signal act;". Any pointers or is signal a LINUX native command?

View 2 Replies View Related

C# :: Convert From Datetime To Unix Time?

Sep 1, 2014

I am converting unix timestamp to datetime format like this:

static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
static readonly double MaxUnixSeconds = (DateTime.MaxValue - UnixEpoch).TotalSeconds;
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp) {
return unixTimeStamp > MaxUnixSeconds
? UnixEpoch.AddMilliseconds(unixTimeStamp)
: UnixEpoch.AddSeconds(unixTimeStamp);
}

use it:

Console.WriteLine("From UNIX do datetime 1300123800440 : " + UnixTimeStampToDateTime(1300123800440));

output: 14.03.2011 5:30 PM

Now i would like to have function which convert it back to unix timestamp but unfortuently my new function is cutting down last 3 digits for instance:

public static long UnixTimestampFromDateTime(DateTime date) {
long unixTimestamp = date.Ticks - new DateTime(1970, 1, 1).Ticks;
unixTimestamp /= TimeSpan.TicksPerSecond;
return unixTimestamp;
}

after use of it i am retrieving:

Console.WriteLine(UnixTimestampFromDateTime(Convert.ToDateTime("14.03.2011 5:30 PM")));

result:

1300123800

View 14 Replies View Related

C :: Segmentation Fault While Accessing DAT File In Unix

Oct 28, 2014

Below is my sample code of a C program. I am doing lot of processing, but my issue is I am getting a segmentation fault error in my main when I am putting the file names at the command line and using them. The program works great in Windows, but its giving error in Unix.

Below is the code of my Main function.

Code:

int main(int argc, char *argv[])
{
FILE *user, *requests;
char c;
user = fopen(argv[1], "r");
requests = fopen(argv[2], "r");
//For users
struct userStorage *USHead = NULL;
//struct users *userHead = NULL;

[Code]...

View 6 Replies View Related

C/C++ :: How To Calculate NTP Timestamp To Unix Epoch Time

Mar 18, 2015

I have been trying for several months to create a simple SNTP single Client/Server based on RFC5905. Finally I manage to make it work at least I think it works correctly, but when I tried to test my code against a real NTP server (e.g. 0.se.pool.ntp.org:123) the timestamps that I am receiving need to be recalculated. I have tried several different approaches but no matter for 3 days now but no matter what I tried nothing yet.

The problem that I am having in not so much programming error is more about knowing how the NTP server operates.

How to convert the NTP timestamp to Unix epoch timestamp?

Syntax to execute the Server e.g. ./server 127.0.0.1:5000 and Client e.g. ./client 127.0.0.1:5000

Syntax to execute the Client against a real NTP server e.g. ./client 0.se.pool.ntp.org:123

Sample of working code Client:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>

[code]....

Sample of printed output when I use Server and Client.

Reference Identifier 0 LOCL
Reference Timestamp 0.0 1426637081.3564398733
Originate Timestamp 1426637087.3570333925 1426637087.3570333925
Receive Timestamp 1426637087.3570334078 1426637087.3570334003
Transmit Timestamp 1426637087.3570333925 1426637087.3570334046

Sample of printed output when I am probing a real NTP server (e.g. 0.se.pool.ntp.org:123).

Reference Identifier 0 $
Reference Timestamp 0.0 3879449560.3503094062
Originate Timestamp 1426637090.3573978972 1426637090.3573978972
Receive Timestamp 1426637090.3573992772 2722083800.781009125
Transmit Timestamp 1426637090.3573978972 2722083800.937312997

View 2 Replies View Related

C++ :: Handle Exception In Multi-threaded Environment

Oct 24, 2014

Here is the code,

Code:
void foo() {
Acquiring lock
do something...
Func();
Releasing Lock
}

If the function Func throws an exception, there is potential deadlock issue. Then I handle exception like this,

Code:
void foo() {
Acquiring lock
do something...
try{
Func();

[Code] ....

Is this a good practice? I wonder how I can apply RAII in handling exception here.

View 2 Replies View Related

C :: Program To Recognize Pattern Of Signals (linux Environment)

Mar 6, 2015

I need to write a c program that can receive signals and recognize a certain pattern (SIGUSR1, SIGUSR2, SIGUSR1, SIGUSR2). once the pattern is caught the program terminates itself.

I am able to send the signals to the program from a different process, but I am unsure on how to get the signal handler to recognize the pattern. here is what i have so far:

Code:
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
sig_atomic_t sigusr1_count = 0;
sig_atomic_t sigusr2_count = 0;

[Code] .....

I just need getting the program to be able to catch that specific pattern.

View 4 Replies View Related

C :: Language Program Environment Does Nothing To Prevent Buffer Overflows

Sep 25, 2013

TheC language program environment does nothing to prevent buffer overflows ..... is there any pros to the obvious cons of this?

View 3 Replies View Related

Visual C++ :: Floating CDialogbar On Multiple Screen Environment

Jul 11, 2014

I have an problem with a CDialogbar if my app runs on a system with two screens (side by side). I can not resize it while the CDialogbar is in floating state on the second screen.

I figured out that the problem is the mfc-function CDockContext::Stretch().

It limits the CDialogbar to the primary screen (using ::GetDesktopWindow() to verify the position).

What can I do?

View 2 Replies View Related

Visual C++ :: Dragging And Dropping Functionality In Windows 8 Environment

Jul 14, 2014

i have developed an application in which i have icons in left side pane of application which can be dragged and dropped in client screen. Application is working fine with all the resolution except 1920x1080.

when setting the resolution to 1920x1080 while dragging icons to client area, icon is not attach to mouse pointer. instead there is a gap between the mouse pointer and the icon. i wrote code to identify the screen resolution but it does not seem to recognize 1920x1080 resolution. below code is giving incorrect resolution for 1920x1080 setting.

RECT actualDesktop;
GetClientRect(GetDesktopWindow(),&actualDesktop);

value of 'actualDesktop' variable is {top=0 bottom=783 left=0 right=1536} which is incorrect. according to current resolution size value should be {top=0 bottom=1080 left=0 right=1920}. Due to this, all the icons while dragging are adjusting according to incorrect resolution setting.

how to identify the issue and if there is any limitation with respect to screen resolution in VC++ 6.0 with windows 8 environment.

I am getting same issue when compiling in VS2012 in windows 8. Code does not seem to recognize 1920x1080 resolution setting and downgrading my application look and feel by setting it to lower resolution.

View 1 Replies View Related

C :: Program To Check For Running Pid Using System Call In UNIX / Linux

Dec 11, 2013

I have written a program which uses a pid to check if the process is currently running and return a value based on the system call result.But the program core dumps

Code:

#include <stdio.h>
#include <string.h
int main( argc, argv )
int argc;
char * argv[];
{
int p_pid = 99;
char buff[1000];
}

[code]....

What is the mistake in this code and is it portable in both unix/linux , is the method secure (grepping for program name )?

View 6 Replies View Related

C/C++ :: Know That Data Written To Shared Memory Segment In Unix Is Stored Properly

Mar 8, 2012

I am trying to write a client/server application that takes input to an array of structures from the user,stores the data in a shared memory segment and then writes the same to a file when I close the application. How do I get started? And how do I ensure that the server stores the data correctly? Also, the server needs to be a concurrent server that accepts connections from multiple clients.

View 1 Replies View Related

C# :: Server Application Using Tcp Protocol And Then Establish Connection With A Client Application

Nov 29, 2014

What happens if I make a server application using tcp protocol and then establish connection with a client application but the server crash and then the client send data. Will the data be lost or the system will continue trying to send it?

View 2 Replies View Related

C# :: How To Start Application And Automatically Pass Input To That Application

May 9, 2012

I want to create an application that starts an application and passes input to that application. I know how to start a process using the classes in System.Diagnostics, but I don't know how to pass data to the process.

For example, and this is just an example, I would like to be able to automatically start an application that requires a username and password and automatically enter the username and password. Of course, that might open the door to security vulnerabilities, but that's not the point of the exercise.

How to implement the functionality I described? Is there a general way to go about doing this or does it depend entirely on the idiosyncrasies of the application in question?

View 2 Replies View Related

C++ :: Coding And Debug Time Per LOC

Mar 23, 2013

I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:

Code: #include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;

[code].....

I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.

So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity?

View 3 Replies View Related

C/C++ :: Debug Executable That Needs Flags

Mar 20, 2015

I'm trying to step through the machine instructions of a c program. This program needs to be run with a -t flag.

This is what I tried
gdbtui
file prog
layout asm
start
stepi

When I try 'file prog -t' it doesn't work.

View 4 Replies View Related

C/C++ :: Debug Log Size Restrictions?

Dec 26, 2012

Iam creating one debug log in my c++ application through the below code.

file *log;
log = fopen("C:snmpApplicationlog.txt", "w");  

iam writing the statements in to this log by using fprintf(). As the .exe where i have put this mechanism runs continuously,the size of log file is increasing gradually.

1)If there is any way to restrict the Log file size,if the file reaches the mentioned size,the file should be discarded and logging should be done in another file with the same name.

{OR}

2)Put a time interval,once after that interval is elapsed, a new log file should be created.

View 1 Replies View Related

C++ :: Errors When Trying To Debug The Code (SFML)

May 22, 2014

I'm currently just trying C++ with SFML. So I've installe SFML 2.0 for Visual C++ 2010 Express 64 bit, and I get an error while trying to run the debug of my code.

//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow window(sf::VideoMode(1280, 720),"SFML Game1");
return 0;
}

And this is the result I'm getting when trying to run it

1
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 3 Replies View Related

Visual C++ :: How To Recover Debug Symbols

Oct 6, 2013

The breakpoints I am setting are not caught by the IDE. Any how I can recover that.

I used to know I can delete the sdf file and rebuild. Just to make sure...

View 4 Replies View Related

C Sharp :: Run Application When Log Off In Console Application

Oct 4, 2012

i have task scheduling application which execute every 30 minute i want to keep this process when system is log off in c# console application

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved