~pac72/ubuntu/lucid/ddd/devel

« back to all changes in this revision

Viewing changes to ddd/exectty.C

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2004-07-22 03:49:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040722034937-cysl08t1jvba4jrx
Tags: 1:3.3.9-3
USERINFO has been renamed to USERINFO.txt; adjust debian/rules code
to match, to get correct information on the About DDD dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: exectty.C,v 1.68 2001/04/26 11:08:07 zeller Exp $ -*- C++ -*-
 
1
// $Id$ -*- C++ -*-
2
2
// Execution TTY
3
3
 
4
4
// Copyright (C) 1996-1998 Technische Universitaet Braunschweig, Germany.
28
28
// or send a mail to the DDD developers <ddd@gnu.org>.
29
29
 
30
30
char exectty_rcsid[] = 
31
 
    "$Id: exectty.C,v 1.68 2001/04/26 11:08:07 zeller Exp $";
32
 
 
33
 
#ifdef __GNUG__
34
 
#pragma implementation
35
 
#endif
 
31
    "$Id$";
36
32
 
37
33
#include "exectty.h"
38
34
 
59
55
#include "windows.h"
60
56
#include "wm.h"
61
57
 
62
 
#include <fstream.h>
 
58
#include <fstream>
63
59
#include <signal.h>
64
60
#include <unistd.h>
65
61
 
153
149
        XtSetArg(args[arg], XmNdialogStyle, 
154
150
                 XmDIALOG_FULL_APPLICATION_MODAL); arg++;
155
151
        dialog = verify(XmCreateWorkingDialog(find_shell(origin), 
156
 
                                              CONST_CAST(char *,"launch_tty_dialog"), 
 
152
                                              XMST("launch_tty_dialog"), 
157
153
                                              args, arg));
158
154
        XtUnmanageChild(XmMessageBoxGetChild(dialog, 
159
155
                                             XmDIALOG_OK_BUTTON));
216
212
    {
217
213
        // We're already running.  Don't start a new tty
218
214
        // if the old one is still running.
219
 
        ostrstream os;
 
215
        std::ostringstream os;
220
216
        os << "kill -2 " << pid << " 2>/dev/null"
221
217
           << " || ( " << command << " )";
222
218
        command = string(os);
237
233
 
238
234
        if (reply.length() > 2)
239
235
        {
240
 
            istrstream is(reply.chars());
 
236
            std::istringstream is(reply.chars());
241
237
            is >> ttyname >> pid >> term >> windowid;
242
238
        }
243
239
 
245
241
    }
246
242
 
247
243
    // Sanity check
248
 
    if (ttyname == "" || ttyname[0] != '/')
 
244
    if (ttyname.empty() || ttyname[0] != '/')
249
245
        pid = -1;
250
246
 
251
247
    // Waiting is over
288
284
        args = command.after(rxwhite);
289
285
    }
290
286
 
291
 
    if (args == "" && gdb->type() == GDB)
 
287
    if (args.empty() && gdb->type() == GDB)
292
288
    {
293
289
        args = gdb_question("show args");
294
290
 
326
322
                         + quote(term_type), "tty_type_error", origin);
327
323
        }
328
324
    }
329
 
    else if (reply != "")
 
325
    else if (!reply.empty())
330
326
    {
331
327
        if (!silent)
332
328
            post_gdb_message(reply, true, origin);
345
341
// Set debugger TTY to TTY_NAME and terminal type to TERM_TYPE.
346
342
// Use without arguments to silently restore original TTY.
347
343
static int gdb_set_tty(string tty_name = "",
348
 
                       string term_type = "dumb",
 
344
                       const string& term_type = "dumb",
349
345
                       Widget origin = 0)
350
346
{
351
347
    bool silent = false;
352
 
    if (tty_name == "")
 
348
    if (tty_name.empty())
353
349
    {
354
350
        tty_name = gdb->slave_tty();
355
351
        silent = true;
372
368
                               "tty_command_error", origin);
373
369
                return -1;
374
370
            }
375
 
            else if (reply != "")
 
371
            else if (!reply.empty())
376
372
            {
377
373
                if (!silent)
378
374
                    post_gdb_message(reply, true, origin);
409
405
                                   "tty_command_error", origin);
410
406
                    return -1;
411
407
                }
412
 
                else if (reply != "")
 
408
                else if (!reply.empty())
413
409
                {
414
410
                    if (!silent)
415
411
                        post_gdb_message(reply, true, origin);
428
424
                                       "tty_command_error", origin);
429
425
                        return -1;
430
426
                    }
431
 
                    else if (reply != "")
 
427
                    else if (!reply.empty())
432
428
                    {
433
429
                        if (!silent)
434
430
                            post_gdb_message(reply, true, origin);
480
476
    }
481
477
    break;
482
478
 
483
 
    case XDB:
 
479
    case BASH:
 
480
    case DBG:
484
481
    case JDB:
485
482
    case PYDB:  // for now
 
483
    case XDB:
486
484
        // No way to set environment variables
487
485
        break;
488
486
    }
554
552
    string args;
555
553
    get_args(command, base, args);
556
554
 
557
 
    if (gdb_redirection != "")
 
555
    if (!gdb_redirection.empty())
558
556
    {
559
557
        static string empty;
560
558
        args.gsub(gdb_redirection, empty);
572
570
        // In GDB, COMMAND is interpreted by the user's shell.
573
571
        static string shell;
574
572
 
575
 
        if (shell == "")
 
573
        if (shell.empty())
576
574
        {
577
575
            // The shell is determined only once, as it cannot change.
578
576
            if (remote_gdb())
649
647
        add_sh_redirection(gdb_redirection, tty_name, args);
650
648
        break;
651
649
 
 
650
    case DBG:
 
651
        break;                  // Don't know if it's there.
 
652
 
652
653
    case JDB:
653
654
        break;                  // No redirection in JDB
654
655
 
 
656
    case BASH:
 
657
        break;                  // No redirection in BASH (for now)
 
658
 
655
659
    case PYDB:
656
660
        break;                  // No redirection in PYDB (for now)
657
661
    }
658
662
 
659
663
    string new_args;
660
 
    if (gdb_redirection != "" && !has_redirection(args, gdb_redirection))
 
664
    if (!gdb_redirection.empty() && !has_redirection(args, gdb_redirection))
661
665
    {
662
 
        if (args == "")
 
666
        if (args.empty())
663
667
            new_args = gdb_redirection;
664
668
        else
665
669
            new_args = gdb_redirection + " " + args;
666
670
    }
667
671
 
668
 
    if (gdb_redirection != "")
 
672
    if (!gdb_redirection.empty())
669
673
        gdb_out_ignore = " " + gdb_redirection;
670
674
 
671
675
    if (gdb->type() == PERL)
687
691
static void unredirect_process(string& command,
688
692
                               Widget origin = 0)
689
693
{
690
 
    if (gdb_redirection != "")
 
694
    if (!gdb_redirection.empty())
691
695
    {
692
696
        // Disable output redirection upon next run
693
697
        string base;
709
713
                // redirected to /dev/tty.
710
714
                string new_args;
711
715
                add_sh_redirection(new_args, "/dev/tty", args);
712
 
                if (args != "")
713
 
                    new_args = new_args + " " + args;
 
716
                if (!args.empty())
 
717
                    new_args += " " + args;
714
718
                command = gdb->run_command(new_args);
715
719
            }
716
720
        }
776
780
    }
777
781
    else
778
782
    {
779
 
        ofstream tty(tty_name.chars());
 
783
        std::ofstream tty(tty_name.chars());
780
784
        tty << init;
781
785
    }
782
786
}
791
795
 
792
796
    message = message.after(": ");
793
797
    static string empty;
794
 
    if (gdb_out_ignore != "")
 
798
    if (!gdb_out_ignore.empty())
795
799
        message.gsub(gdb_out_ignore, empty);
796
800
 
797
801
    string program = message;
798
802
    if (program.contains(' '))
799
803
        program = program.before(' ');
800
804
 
801
 
    if (program != "")
 
805
    if (!program.empty())
802
806
    {
803
807
        string program_base = program;
804
808
        if (program_base.contains('/'))
828
832
    get_args(command, base, args);
829
833
    bool rerun = base.contains("re", 0);
830
834
 
831
 
    if (rerun && !gdb->rerun_clears_args() && args == "")
 
835
    if (rerun && !gdb->rerun_clears_args() && args.empty())
832
836
    {
833
837
        // `rerun' without args - Use last arguments
834
838
        command = base + " " + last_args;
835
839
    }
836
 
    else if (!rerun && gdb->rerun_clears_args() && args == "")
 
840
    else if (!rerun && gdb->rerun_clears_args() && args.empty())
837
841
    {
838
842
        // `run' without args - Use last arguments
839
843
        command = base + " " + last_args;
936
940
        unredirect_process(command, origin);
937
941
    }
938
942
 
939
 
    if (command != "")
 
943
    if (!command.empty())
940
944
        gdb_run_command = command;
941
945
 
942
946
    set_buffer_gdb_output();
971
975
 
972
976
        if (remote_gdb())
973
977
        {
974
 
            ostrstream os;
 
978
            std::ostringstream os;
975
979
            os << "kill -" << SIGHUP << " " << separate_tty_pid 
976
980
               << " >/dev/null </dev/null 2>&1 &";
977
981
            Agent agent(sh_command(string(os)));