diff options
Diffstat (limited to 'lldb/tools/driver')
| -rw-r--r-- | lldb/tools/driver/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | lldb/tools/driver/ELWrapper.cpp | 422 | ||||
| -rw-r--r-- | lldb/tools/driver/ELWrapper.h | 122 | ||||
| -rw-r--r-- | lldb/tools/driver/GetOptWrapper.cpp | 33 | ||||
| -rw-r--r-- | lldb/tools/driver/GetOptWrapper.h | 49 | ||||
| -rw-r--r-- | lldb/tools/driver/Platform.h | 3 |
6 files changed, 1 insertions, 633 deletions
diff --git a/lldb/tools/driver/CMakeLists.txt b/lldb/tools/driver/CMakeLists.txt index f671b5bddaf..af3dbbe6fb7 100644 --- a/lldb/tools/driver/CMakeLists.txt +++ b/lldb/tools/driver/CMakeLists.txt @@ -1,12 +1,7 @@ set(LLVM_NO_RTTI 1) add_lldb_executable(lldb Driver.cpp - #DriverEvents.cpp - #DriverOptions.cpp - #DriverPosix.cpp - ELWrapper.cpp Platform.cpp - GetOptWrapper.cpp ) target_link_libraries(lldb liblldb) diff --git a/lldb/tools/driver/ELWrapper.cpp b/lldb/tools/driver/ELWrapper.cpp deleted file mode 100644 index 258f47e5169..00000000000 --- a/lldb/tools/driver/ELWrapper.cpp +++ /dev/null @@ -1,422 +0,0 @@ -//===-- ELWrapper.cpp -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// this file is only relevant for Visual C++ -#if defined( _MSC_VER ) - -#include "lldb/Host/windows/windows.h" - -#include "ELWrapper.h" -#include <vector> -#include <assert.h> - -// index one of the variable arguments -// presuming "(EditLine *el, ..." is first in the argument list -#define GETARG( X ) ( (void* ) *( ( (int**) &el ) + ((X) + 2) ) ) - -// edit line EL_ADDFN function pointer type -typedef unsigned char (*el_addfn_func)(EditLine *e, int ch); - -// edit line wrapper binding container -struct el_binding -{ - // - const char *name; - const char *help; - // function pointer to callback routine - el_addfn_func func; - // ascii key this function is bound to - const char *key; -}; - -// stored key bindings -static std::vector<el_binding*> _bindings; - -//TODO: this should infact be related to the exact edit line context we create -static void *clientData = NULL; - -// store the current prompt string -// default to what we expect to receive anyway -static const char *_prompt = "(lldb) "; - -#if !defined( _WIP_INPUT_METHOD ) - -static char * -el_get_s (char *buffer, int chars) -{ - return gets_s(buffer, chars); -} -#else - -static void -con_output (char _in) -{ - HANDLE hout = GetStdHandle( STD_OUTPUT_HANDLE ); - DWORD written = 0; - // get the cursor position - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo( hout, &info ); - // output this char - WriteConsoleOutputCharacterA( hout, &_in, 1, info.dwCursorPosition, &written ); - // advance cursor position - info.dwCursorPosition.X++; - SetConsoleCursorPosition( hout, info.dwCursorPosition ); -} - -static void -con_backspace (void) -{ - HANDLE hout = GetStdHandle( STD_OUTPUT_HANDLE ); - DWORD written = 0; - // get cursor position - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo( hout, &info ); - // nudge cursor backwards - info.dwCursorPosition.X--; - SetConsoleCursorPosition( hout, info.dwCursorPosition ); - // blank out the last character - WriteConsoleOutputCharacterA( hout, " ", 1, info.dwCursorPosition, &written ); -} - -static void -con_return (void) -{ - HANDLE hout = GetStdHandle( STD_OUTPUT_HANDLE ); - DWORD written = 0; - // get cursor position - CONSOLE_SCREEN_BUFFER_INFO info; - GetConsoleScreenBufferInfo( hout, &info ); - // move onto the new line - info.dwCursorPosition.X = 0; - info.dwCursorPosition.Y++; - SetConsoleCursorPosition( hout, info.dwCursorPosition ); -} - -static bool -runBind (char _key) -{ - for ( int i=0; i<_bindings.size(); i++ ) - { - el_binding *bind = _bindings[i]; - if ( bind->key[0] == _key ) - { - bind->func( (EditLine*) -1, _key ); - return true; - } - } - return false; -} - -// replacement get_s which is EL_BIND aware -static char * -el_get_s (char *buffer, int chars) -{ - // - char *head = buffer; - // - for ( ;; Sleep( 10 ) ) - { - // - INPUT_RECORD _record; - // - DWORD _read = 0; - if ( ReadConsoleInputA( GetStdHandle( STD_INPUT_HANDLE ), &_record, 1, &_read ) == FALSE ) - break; - // if we didnt read a key - if ( _read == 0 ) - continue; - // only interested in key events - if ( _record.EventType != KEY_EVENT ) - continue; - // is the key down - if (! _record.Event.KeyEvent.bKeyDown ) - continue; - // read the ascii key character - char _key = _record.Event.KeyEvent.uChar.AsciiChar; - // non ascii conformant key press - if ( _key == 0 ) - { - // check the scan code - // if VK_UP scroll back through history - // if VK_DOWN scroll forward through history - continue; - } - // try to execute any bind this key may have - if ( runBind( _key ) ) - continue; - // if we read a return key - if ( _key == '\n' || _key == '\r' ) - { - con_return( ); - break; - } - // key is backspace - if ( _key == 0x8 ) - { - // avoid deleting past beginning - if ( head > buffer ) - { - con_backspace( ); - head--; - } - continue; - } - - // add this key to the input buffer - if ( (head-buffer) < (chars-1) ) - { - con_output( _key ); - *(head++) = _key; - } - } - // insert end of line character - *head = '\0'; - - return buffer; -} -#endif - -// edit line initalise -EditLine * -el_init (const char *, FILE *, FILE *, FILE *) -{ - // - SetConsoleTitleA( "lldb" ); - // return dummy handle - return (EditLine*) -1; -} - -const char * -el_gets (EditLine *el, int *length) -{ - // print the prompt if we have one - if ( _prompt != NULL ) - printf( _prompt ); - // create a buffer for the user input - char *buffer = new char[ MAX_PATH ]; - // try to get user input string - if ( el_get_s( buffer, MAX_PATH ) ) - { - // get the string length in 'length' - while ( buffer[ *length ] != '\0' ) - (*length)++; - // return the input buffer - // remember that this memory has the be free'd somewhere - return buffer; - } - else - { - // on error - delete [] buffer; - return NULL; - } -} - -int -el_set (EditLine *el, int code, ...) -{ - int **arg = (int**) ⪙ - // - switch ( code ) - { - // edit line set prompt message - case ( EL_PROMPT ): - { - // EL_PROMPT, char *(*f)( EditLine *) - // define a prompt printing function as 'f', which is to return a string that - // contains the prompt. - - // get the function pointer from the arg list - void *func_vp = (void*) *(arg+2); - // cast to suitable prototype - const char* (*func_fp)(EditLine*) = (const char*(*)(EditLine *)) func_vp; - // call to get the prompt as a string - _prompt = func_fp( el ); - } - break; - case ( EL_EDITOR ): - { - // EL_EDITOR, const char *mode - // set editing mode to "emacs" or "vi" - } - break; - case ( EL_HIST ): - { - // EL_HIST, History *(*fun)(History *, int op, ... ), const char *ptr - // defines which histroy function to use, which is usualy history(). Ptr should be the - // value returned by history_init(). - } - break; - case ( EL_ADDFN ): - { - // EL_ADDFN, const char *name, const char *help, unsigned char (*func)(EditLine *e, int ch) - // add a user defined function, func), referred to as 'name' which is invoked when a key which is bound to 'name' is - // entered. 'help' is a description of 'name'. at involcation time, 'ch' is the key which caused the invocation. the - // return value of 'func()' should be one of: - // CC_NORM add a normal character - // CC_NEWLINE end of line was entered - // CC_EOF EOF was entered - // CC_ARGHACK expecting further command input as arguments, do nothing visually. - // CC_REFRESH refresh display. - // CC_REFRESH_BEEP refresh display and beep. - // CC_CURSOR cursor moved so update and perform CC_REFRESH - // CC_REDISPLAY redisplay entire input line. this is usefull if a key binding outputs extra information. - // CC_ERROR an error occured. beep and flush tty. - // CC_FATAL fatal error, reset tty to known state. - - el_binding *binding = new el_binding; - binding->name = (const char *) GETARG( 0 ); - binding->help = (const char *) GETARG( 1 ); - binding->func = (el_addfn_func) GETARG( 2 ); - binding->key = 0; - // add this to the bindings list - _bindings.push_back( binding ); - } - break; - case ( EL_BIND ): - { - // EL_BIND, const char *, ..., NULL - // perform the BIND buildin command. Refer to editrc(5) for more information. - - const char *name = (const char*) GETARG( 1 ); - - for ( int i=0; i<_bindings.size(); i++ ) - { - el_binding *bind = _bindings[i]; - if ( strcmp( bind->name, name ) == 0 ) - { - bind->key = (const char *) GETARG( 0 ); - break; - } - } - - } - break; - case ( EL_CLIENTDATA ): - { - clientData = GETARG( 0 ); - } - break; - default: - assert( !"Not Implemented!" ); - } - return 0; -} - -void -el_end (EditLine *el) -{ - assert( !"Not implemented!" ); -} - -void -el_reset (EditLine *) -{ - assert( !"Not implemented!" ); -} - -int -el_getc (EditLine *, char *) -{ - assert( !"Not implemented!" ); - return 0; -} - -void -el_push (EditLine *, char *) -{ - assert( !"Not implemented!" ); -} - -void -el_beep (EditLine *) -{ - Beep( 1000, 500 ); -} - -int -el_parse (EditLine *, int, const char **) -{ - assert( !"Not implemented!" ); - return 0; -} - -int -el_get (EditLine *el, int code, ...) -{ - switch ( code ) - { - case ( EL_CLIENTDATA ): - { - void **dout = (void**) GETARG( 0 ); - *dout = clientData; - } - break; - default: - assert( !"Not implemented!" ); - } - return 0; -} - -int -el_source (EditLine *el, const char *file) -{ - // init edit line by reading the contents of 'file' - // nothing to do here on windows... - return 0; -} - -void -el_resize (EditLine *) -{ - assert( !"Not implemented!" ); -} - -const LineInfo * -el_line (EditLine *el) -{ - assert( !"Not implemented!" ); - return 0; -} - -int -el_insertstr (EditLine *, const char *) -{ - assert( !"Not implemented!" ); - return 0; -} - -void -el_deletestr (EditLine *, int) -{ - assert( !"Not implemented!" ); -} - -History * -history_init (void) -{ - // return dummy handle - return (History*) -1; -} - -void -history_end (History *) -{ - assert( !"Not implemented!" ); -} - -int -history (History *, HistEvent *, int op, ...) -{ - // perform operation 'op' on the history list with optional argumetns as needed by - // the operation. - return 0; -} - -#endif diff --git a/lldb/tools/driver/ELWrapper.h b/lldb/tools/driver/ELWrapper.h deleted file mode 100644 index a30182d948b..00000000000 --- a/lldb/tools/driver/ELWrapper.h +++ /dev/null @@ -1,122 +0,0 @@ -//===-- ELWrapper.h ---------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#pragma once - -#include <stdio.h> - -// EditLine editor function return codes. -// For user-defined function interface -#define CC_NORM 0 -#define CC_NEWLINE 1 -#define CC_EOF 2 -#define CC_ARGHACK 3 -#define CC_REFRESH 4 -#define CC_CURSOR 5 -#define CC_ERROR 6 -#define CC_FATAL 7 -#define CC_REDISPLAY 8 -#define CC_REFRESH_BEEP 9 - -// el_set/el_get parameters -#define EL_PROMPT 0 // , el_pfunc_t -#define EL_TERMINAL 1 // , const char * -#define EL_EDITOR 2 // , const char * -#define EL_SIGNAL 3 // , int); -#define EL_BIND 4 // , const char *, ..., NULL -#define EL_TELLTC 5 // , const char *, ..., NULL -#define EL_SETTC 6 // , const char *, ..., NULL -#define EL_ECHOTC 7 // , const char *, ..., NULL -#define EL_SETTY 8 // , const char *, ..., NULL -#define EL_ADDFN 9 // , const char *, const char *, el_func_t -#define EL_HIST 10 // , hist_fun_t, const char * -#define EL_EDITMODE 11 // , int -#define EL_RPROMPT 12 // , el_pfunc_t -#define EL_GETCFN 13 // , el_rfunc_t -#define EL_CLIENTDATA 14 // , void * -#define EL_UNBUFFERED 15 // , int -#define EL_PREP_TERM 16 // , int -#define EL_GETTC 17 // , const char *, ..., NULL -#define EL_GETFP 18 // , int, FILE ** -#define EL_SETFP 19 // , int, FILE * -#define EL_REFRESH 20 // , void - -#define EL_BUILTIN_GETCFN (NULL) - -// history defines -#define H_FUNC 0 // , UTSL -#define H_SETSIZE 1 // , const int -#define H_GETSIZE 2 // , void -#define H_FIRST 3 // , void -#define H_LAST 4 // , void -#define H_PREV 5 // , void -#define H_NEXT 6 // , void -#define H_CURR 8 // , const int -#define H_SET 7 // , int -#define H_ADD 9 // , const char * -#define H_ENTER 10 // , const char * -#define H_APPEND 11 // , const char * -#define H_END 12 // , void -#define H_NEXT_STR 13 // , const char * -#define H_PREV_STR 14 // , const char * -#define H_NEXT_EVENT 15 // , const int -#define H_PREV_EVENT 16 // , const int -#define H_LOAD 17 // , const char * -#define H_SAVE 18 // , const char * -#define H_CLEAR 19 // , void -#define H_SETUNIQUE 20 // , int -#define H_GETUNIQUE 21 // , void -#define H_DEL 22 // , int - -struct EditLine -{ -}; - -struct LineInfo -{ - const char *buffer; - const char *cursor; - const char *lastchar; -}; - -struct History -{ -}; - -struct HistEvent -{ - int num; - const char *str; -}; - -extern "C" -{ - // edit line API - EditLine *el_init ( const char *, FILE *, FILE *, FILE * ); - const char *el_gets ( EditLine *, int * ); - int el_set ( EditLine *, int, ... ); - - void el_end ( EditLine * ); - void el_reset ( EditLine * ); - int el_getc ( EditLine *, char * ); - void el_push ( EditLine *, char * ); - void el_beep ( EditLine * ); - int el_parse ( EditLine *, int, const char ** ); - int el_get ( EditLine *, int, ... ); - int el_source ( EditLine *, const char * ); - void el_resize ( EditLine * ); - const LineInfo *el_line ( EditLine * ); - int el_insertstr( EditLine *, const char * ); - void el_deletestr( EditLine *, int ); - - // history API - History *history_init( void ); - void history_end ( History * ); - int history ( History *, HistEvent *, int, ... ); -};
\ No newline at end of file diff --git a/lldb/tools/driver/GetOptWrapper.cpp b/lldb/tools/driver/GetOptWrapper.cpp deleted file mode 100644 index e7cdfd786c6..00000000000 --- a/lldb/tools/driver/GetOptWrapper.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===-- GetOptWrapper.cpp ---------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// this file is only relevant for Visual C++ -#if defined( _MSC_VER ) - -#include "GetOptWrapper.h" - -/* - -// already defined in lldbHostCommon.lib due to 'getopt.inc' - -extern int -getopt_long_only -( - int ___argc, - char *const *___argv, - const char *__shortopts, - const struct option *__longopts, - int *__longind -) -{ - return -1; -} -*/ - -#endif
\ No newline at end of file diff --git a/lldb/tools/driver/GetOptWrapper.h b/lldb/tools/driver/GetOptWrapper.h deleted file mode 100644 index 9c9cf03d762..00000000000 --- a/lldb/tools/driver/GetOptWrapper.h +++ /dev/null @@ -1,49 +0,0 @@ -//===-- GetOptWrapper.h -----------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_GetOptWrapper_h_ -#define lldb_GetOptWrapper_h_ - -// from getopt.h -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -// defined int unistd.h -extern int optreset; - -// from getopt.h -extern char *optarg; -extern int optind; -extern int opterr; -extern int optopt; - -// option structure -struct option -{ - const char *name; - // has_arg can't be an enum because some compilers complain about - // type mismatches in all the code that assumes it is an int. - int has_arg; - int *flag; - int val; -}; - -// -extern int -getopt_long_only -( - int ___argc, - char *const *___argv, - const char *__shortopts, - const struct option *__longopts, - int *__longind -); - -#endif // lldb_GetOptWrapper_h_
\ No newline at end of file diff --git a/lldb/tools/driver/Platform.h b/lldb/tools/driver/Platform.h index f1fe1e4aac1..faa2991bf6f 100644 --- a/lldb/tools/driver/Platform.h +++ b/lldb/tools/driver/Platform.h @@ -18,9 +18,8 @@ #include <io.h> #include <eh.h> #include <inttypes.h> - #include "ELWrapper.h" #include "lldb/Host/windows/Windows.h" - #include "GetOptWrapper.h" + #include "lldb/Host/HostGetOpt.h" struct timeval { |

