C.Interface.And.Implementations—memory(复杂版本)的实现

1、After the call to  free,  p  holds a dangling pointer— a pointer that refers to memory that logically does not exist. Subse-quently dereferencing p  is an error, although if the block hasn’t been reallocated for another purpose, the error might go undetected. 

2、another error: deallocating free memory. 

3、Another error is deallocating memory that wasn’t allocated by malloc , calloc , or  realloc. 


针对以上错误,此版本memory实现较为复杂,使用了哈希表数据结构。


                  

    这个是内存的结构。整体而言用哈希表+链表进行存储。同时,释放的空间用freelist循环链表进行连接。有阴影的部分表示目前已经申请正在使用的空间。C函数中几个函数都是在这个数据结构上进行操作的。


==============================mem.h=====================================

#ifndef MEM_INCLUDED
#define MEM_INCLUDED
#include "except.h"

//exported exceptions
extern const Except_T Mem_Failed;

//exported functions
extern void *Mem_alloc(long nbytes,
                       const char *file, int line);
extern void *Mem_calloc(long count, long nbytes,
                       const char *file, int line);
extern void Mem_free(void *ptr,
                     const char *file, int line);
extern void *Mem_resize(void *ptr, long nbytes,
    const char *file, int line);
//exported macros
#define ALLOC(nbytes) \
    Mem_alloc((nbytes), __FILE__, __LINE__)
#define CALLOC(count, nbytes) \
    Mem_calloc((count), (nbytes), __FILE__, __LINE__)
#define NEW(p) ((p) = ALLOC((long)sizeof *(p)))
#define NEW0(p) ((p) = CALLOC(1, (long)sizeof *(p)))
#define FREE(ptr) ((void)(Mem_free((ptr),\
    __FILE__, __LINE__), (ptr) = 0))
#define RESIZE(ptr, nbytes)((ptr) = Mem_resize((ptr),\
    (nbytes), __FILE__, __LINE__))
#endif

=============================memchk.c==================================

#include <stdlib.h>
#include <string.h>
#include "assert.h"
#include "except.h"
#include "mem.h"

//checking types
union align{
    int i;
    long l;
    long *lp;
    void *p;
    void (*fp)(void);
    float f;
    double d;
    long double ld;
};

//checking macros
#define hash(p, t) (((unsigned long)(p)>>3) & \
    (sizeof (t)/sizeof((t)[0])-1))
#define NDESCRIPTORS 512
#define NALLOC((4096 + sizeof(union align)-1)/ \
    (sizeof(union align)))*(sizeof (union align))

//data
const Except_T Mem_Failed = { "Allocation Failed" };

//checking data
static struct descriptor{
    struct descriptor *free;
    struct descriptor *link;
    const void *ptr;
    long size;
    const char *file;
    int line;
} *htab[2048];
static struct descriptor freelist = { &freelist };

//checking functions
static struct descriptor *find(const void *ptr){
    struct descriptor *bp = htab[hash(ptr, htab)];

    while(bp && bp->ptr != ptr)
        bp = bp->link;

    return bp;
}

void Mem_free(void *ptr, const char *file, int line){
    if(ptr){
        struct descriptor *bp;
        if(((unsigned long)ptr)%(sizeof (union align)) != 0
            || (bp = find(ptr)) == NULL || bp->free)
            Except_raise(&Assert_Failed, file, line);
        bp->free = freelist.free;
        freelist.free = bp;
    }
}

void *Mem_resize(void *ptr, long nbytes,
                 const char *file, int line){
    struct descriptor *bp;
    void *newptr;

    assert(ptr);
    assert(nbytes > 0);
    if(((unsigned long)ptr)%(sizeof (union align)) != 0
        || (bp = find(ptr)) == NULL || bp->free)
        Except_raise(&Assert_Failed, file, line);
    newptr = Mem_alloc(nbytes, file, line);
    memcpy(newptr, ptr, 
        nbytes < bp->size ? nbytes : bp->size);
    Mem_free(ptr, file, line);
    return newptr;
}

void *Mem_calloc(long count, long nbytes,
                 const char *file, int line){
    void *ptr;

    assert(count > 0);
    assert(nbytes > 0);
    ptr = Mem_alloc(count*nbytes, file, line);
    memset(ptr, '\0', count*nbytes);
    return ptr;
}

static struct descriptor *dalloc(void *ptr, long size, 
    const char *file, int line){
    static struct descriptor *avail;
    static int nleft;

    if(nleft <= 0){
        avail = malloc(NDESCRIPTORS * sizeof (*avail));
        if(avail == NULL)
            return NULL;
        nleft = NDESCRIPTORS;
    }

    avail->ptr = ptr;
    avail->size = size;
    avail->file = file;
    avail->line = line;
    avail->free = avail->link = NULL;
    nleft--;
    return avail++;
}

void *Mem_alloc(long nbytes, const char *file, int line){
    struct descriptor *bp;
    void *ptr;
    
    assert(nbytes > 0);
    //round nbytes up to an alignment boundary>
    nbytes = ((nbytes + sizeof(union align) - 1)/
        (sizeof(union align)))*(sizeof(union align));
    for(bp = freelist.free; bp; bp = bp->free){
        if(bp->size > nbytes){
            //use the end of the block at bp->ptr
            bp->size -= nbytes;
            ptr = (char*)bp->ptr + bp->size;
            if((bp = dalloc(ptr, nbytes, file, line)) != NULL){
                unsigned h = hash(ptr, htab);
                bp->link = htab[h];
                htab[h] = bp;
                return ptr;
            }else{
                if(file == NULL)
                    RAISE(Mem_Failed);
                else
                    Except_raise(&Mem_Failed, file, line);
            }
        }
        if(bp == &freelist){
            struct descriptor *newptr;
            //<newptr <- a block of size NALLOC + nbytes >
            if((ptr = malloc(nbytes + NALLOC)) == NULL
                || (newptr = dalloc(ptr, nbytes+NALLOC,
                __FILE__, __LINE__)) == NULL)
            {
                if(file == NULL)
                    RAISE(Mem_Failed);
                else
                    Except_raise(&Mem_Failed, file, line);
            }
            newptr->free = freelist.free;
            freelist.free = newptr;
        }
    }

    assert(0);
    return NULL;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Redis is the most popular in-memory key-value data store. It is very lightweight and its data types give it an edge over other competitors. If you need an in-memory database or a high-performance cache system that is simple to use and highly scalable, Redis is what you should use. This book is a fast-paced guide that teaches you the fundamentals of data types, explains how to manage data through commands, and shares experiences from big players in the industry. What this book covers Chapter 1, Getting Started (The Baby Steps), shows you how to install Redis and how to use redis-cli, the default Redis command-line interface. It also shows you how to install Node.js and goes through a quick JavaScript syntax reference. The String, List, and Hash data types are covered in detail, along with examples of redis-cli and Node.js. Chapter 2, Advanced Data Types (Earning a Black Belt), is a continuation of the previous chapter. It presents the Set, Sorted Set, Bitmap, and HyperLogLog data types. All the examples here are implemented with redis-cli and Node.js. Chapter 3, Time Series (A Collection of Observations), uses all of the knowledge of data types from the previous chapters to build a time series library in Node.js. The examples are incremental; the library is initially implemented using the String data type, and then the solution is improved and optimized by using the Hash data type. Uniqueness support is added to the String and Hash implementations by using the Sorted Set and HyperLogLog data types, respectively. Preface [ viii ] Chapter 4, Commands (Where the Wild Things Are), introduces Pub/Sub, transactions, and pipelines. It also introduces the scripting mechanism, which uses the Lua programming language to extend Redis. A quick Lua syntax reference is also presented. A great variety of Redis commands are presented in this chapter, including the administration commands and data type commands that were not covered in the previous chapters. This chapter also shows you how to change Redis's configuration to optimize different data types for memory or performance. Chapter 5, Clients for Your Favorite Language (Become a Redis Polyglot), shows how to use Redis with PHP, Python, and Ruby. This chapter highlights the features that vary more frequently with clients in different languages: blocking commands, transactions, pipelines, and scripting. Chapter 6, Common Pitfalls (Avoiding Traps), illustrates some common mistakes when using Redis in a production environment and related stories from real-world companies. The pitfalls in this chapter include using the wrong data type for a given problem, using too much swap space, and using inefficient backup strategies. Chapter 7, Security Techniques (Guard Your Data), shows how to set up basic security with Redis, disable and obfuscate commands, protect Redis with firewall rules, and use client-to-server SSL encryption with stunnel. Chapter 8, Scaling Redis (Beyond a Single Instance), introduces RDB and AOF persistence, replication via Redis slaves, and different methods of partitioning data across different hosts. This chapter also shows how to use twemproxy to distribute Redis data across different instances transparently. Chapter 9, Redis Cluster and Redis Sentinel (Collective Intelligence), demonstrates the differences between Redis Cluster and Redis Sentinel, their goals, and how they fit into the CAP theorem. It also shows how to set up both Sentinel and Cluster, their configurations, and what happens in different failure scenarios. Redis Cluster is covered in more detail, since it is more complex and has different tools for managing a cluster of instances. Cluster administration is explained via native Redis commands and the redis-trib tool.
The Design and Implementation of the 4.4BSD Operating System Marshall Kirk McKusick Keith Bostic Michael J. Karels John S. Quarterman Copyright © 1996 Addison-Wesley Longman, Inc The second chapter of the book, The Design and Implementation of the 4.4BSD Operating System is excerpted here with the permission of the publisher. No part of it may be further reproduced or distributed without the publisher's express written permission. The rest of the book explores the concepts introduced in this chapter in incredible detail and is an excellent reference for anyone with an interest in BSD UNIX. More information about this book is available from the publisher, with whom you can also sign up to receive news of related titles. Information about BSD courses is available from Kirk McKusick. [ Split HTML / Single HTML ] Table of Contents 2 Design Overview of 4.4BSD 2.1 4.4BSD Facilities and the Kernel 2.1.1 The Kernel 2.2 Kernel Organization 2.3 Kernel Services 2.4 Process Management 2.4.1 Signals 2.4.2 Process Groups and Sessions 2.5 Memory Management 2.5.1 BSD Memory-Management Design Decisions 2.5.2 Memory Management Inside the Kernel 2.6 I/O System 2.6.1 Descriptors and I/O 2.6.2 Descriptor Management 2.6.3 Devices 2.6.4 Socket IPC 2.6.5 Scatter/Gather I/O 2.6.6 Multiple Filesystem Support 2.7 Filesystems 2.8 Filestores 2.9 Network Filesystem 2.10 Terminals 2.11 Interprocess Communication 2.12 Network Communication 2.13 Network Implementation 2.14 System Operation References List of Tables 2-1. Machine-independent software in the 4.4BSD kernel 2-2. Machine-dependent software for the HP300 in the 4.4BSD kernel List of Figures 2-1. Process lifecycle 2-2. A small filesystem Chapter 2 Design Overview of 4.4BSD 2.1 4.4BSD Facilities and the Kernel The 4.4BSD kernel provides four basic facilities: processes, a filesystem, communications, and system startup. This section outlines where each of these four basic services is described in this book. Processes constitute a t
2013年最新版的强悍Unix版本Solaris 11.1系统文件,功能十分强大,不愧是真正血统的Unix系统! Oracle Announces Availability of Oracle Solaris 11.1 and Oracle Solaris Cluster 4.1 Delivers Oracle Database and Java Enhancements, Expanded Mission Critical Cloud Management Capabilities and Advanced Platform Features Redwood Shores, Calif – October 26, 2012 News Facts Oracle today announced general availability of Oracle Solaris 11.1 and Oracle Solaris Cluster 4.1. Oracle Solaris 11 is the first cloud OS that allows customers to build large-scale enterprise-class Infrastructure as a Service (IaaS), Platform as a Service (PaaS) and Software as a Service (SaaS) clouds on a wide range of SPARC and x86 servers and Oracle engineered systems. Oracle Solaris Cluster 4.1 extends high availability and disaster recovery capabilities of Oracle Solaris and includes unique virtual cluster features supporting highly efficient application consolidation with best-in-class availability. Oracle Solaris 11 is already widely in production with thousands of customers with mission critical deployments across industries such as financial services, communications, healthcare, retail, public sector and media and entertainment. Read customer success stories about Oracle Solaris here. Oracle Solaris 11 is also gaining strong momentum among enterprise application vendors with hundreds of applications already qualified for Oracle Solaris Ready status through the Oracle PartnerNetwork (OPN). OPN members can develop, sell and implement their solutions on Oracle Solaris 11 and take advantage of specialized Oracle Solaris resources to expand their market reach. Customers and partners can quickly and safely upgrade to Oracle Solaris 11.1 using the built-in update tools and software repositories available with Oracle Solaris 11. Oracle will host a webcast on November 7, 2012 at 8 a.m. Pacific time on Oracle Solaris 11.1 and Oracle Solaris Cluster 4.1, featuring Markus Flierl, vice president, Oracle Solaris Engineering, Core Technology and Bill Nesheim, vice president, Oracle Solaris Engineering, Platform Software. Register here. This event will also include an interactive chat with core developers of Oracle Solaris and Oracle Solaris Cluster. New and Enhanced Features in Oracle Solaris 11.1 Oracle Solaris 11.1 increases the performance, availability and I/O throughput of the latest Oracle Database technology. A new, optimized shared memory interface between the Oracle Database and Oracle Solaris 11.1 provides 8x faster database startup and shutdown, as well as online resizing of the Oracle Database System Global Area (SGA). Oracle Solaris 11.1 introduces unique new capabilities for optimizing Oracle Database performance. Oracle Solaris 11.1 exposes Oracle Solaris DTrace I/O interfaces that allow an Oracle Database administrator to identify I/O outliers and subsequently isolate network or storage bottlenecks. A new Oracle Solaris DTrace plug-in for Oracle Java Mission Control to enable customers to profile Java applications on Oracle Solaris production systems. New cloud management features add to Oracle Solaris 11’s zero overhead built-in virtualization capabilities across system, network and storage resources, including expanded support for Software Defined Networks (SDN) with Edge Virtual Bridging enhancements, to maximize network resource utilization and manage bandwidth in cloud environments. New built-in memory predictor monitors application memory use and provides optimized memory page sizes and resource location to speed overall application performance. Support for an unprecedented 32 TB of RAM and thousands of CPUs unlocks the full potential of Oracle’s latest server systems. Oracle Solaris Cluster 4.1 Highlights New Oracle Solaris 10 Zone Clusters allow customers to consolidate mission critical Oracle Solaris 10 applications on Oracle Solaris 11 cloud environments. Expanded disaster recovery operations using Oracle’s Sun ZFS Storage Appliance services along with Oracle Solaris Cluster 4.1 to coordinate failover of applications and data to a remote disaster recovery site. Faster application recovery with improved storage failure detection and resource dependencies management. New labeled security capability in Oracle Solaris Zone Clusters provides military grade application separation in highly consolidated mission-critical deployments using Oracle Solaris 11 Trusted Extensions. Integrated Oracle Deployments and Support Oracle Enterprise Manager Ops Center provides comprehensive cloud management capabilities for Oracle Solaris 11, including self-service provisioning of Oracle Solaris 11 Zones. Ops Center’s integrated systems management delivers enterprise scale cloud performance. Oracle Enterprise Manager Ops Center is available to Oracle Solaris customers at no additional cost under the Ops Center Everywhere Program. Oracle Solaris Studio delivers the latest in compiler optimizations, multithread performance and powerful analysis tools for native development, and optimized application performance and reliability on Oracle Solaris 11.1 systems. Oracle Solaris 11 guarantees binary compatibility with previous Oracle Solaris versions through the Oracle Solaris Binary Application Guarantee Program, which provides customers a seamless upgrade path and the industry’s best investment protection. Oracle Solaris Legacy Containers allows older Oracle Solaris environments to be brought forward onto latest generation hardware to provide power, cooling and footprint consolidation savings. OPN members can find Oracle Solaris tools and resources in the Oracle Solaris Knowledge Zone, including Oracle Solaris Ready, Oracle Solaris 11 Specialization and Oracle Solaris Development Initiative. The Oracle Solaris Remote Lab now provides a secure cloud environment for OPN members to test and validate their applications with Oracle Solaris 11 in SPARC and x86 virtual environments. Supporting Quotes “Oracle recommends Oracle Solaris 11 for all UNIX®-based Oracle implementations. Oracle Solaris 11.1 delivers over 300 new performance and feature enhancements and is engineered together with Oracle Database, middleware, applications to increase performance, streamline management and automate support for Oracle deployments,” said John Fowler, executive vice president, Systems, Oracle. “The combination of the secure, highly available capabilities of Oracle Solaris Cluster 4.1 and the built-in virtualization of Oracle Solaris 11.1 helps customers bring their most mission-critical applications into a cost effective, agile cloud environment and delivers extreme availability for enterprise applications.” “Clients are looking for ways to reduce the complexity of systems management while enabling Platform as a Service (PaaS) & Software as a Service (SaaS) clouds,” says Lee Diamante, solutions architect, Systems Computing Solutions at Forsythe. “The value of Oracle Solaris 11 is that it maintains all the enterprise-class features expected with a mission-critical OS, while bringing in new, innovative technologies. Forsythe has a long and rich history of delivering customer solutions on Oracle Solaris systems. This is why we are excited about the Solaris 11.1 release.” “Oracle is making it much easier for partners like Informatica to gain access to their software with the new testing environments; shrinking the time to measurable results and value,” said Julie Lockner, vice president, ILM, Informatica. “With the release of Oracle Solaris 11.1 Informatica customers now have access to mission critical deployments across major industries, with an environment of high performance and high availability. With all the new feature enhancements, we look forward to making the Informatica Platform certified on the Oracle Solaris 11 product family.”
xvii Contents Finishing Your Modules 154 Defining Module-Specific Errors 154 Choosing What to Export 155 Documenting Your Modules 156 Try It Out: Viewing Module Documentation 157 Testing Your Module 162 Running a Module as a Program 164 Try It Out: Running a Module 164 Creating a Whole Module 165 Try It Out: Finishing a Module 165 Try It Out: Smashing Imports 169 Installing Your Modules 170 Try It Out: Creating an Installable Package 171 Summary 174 Exercises 174 Chapter 11: Text Processing 175 Why Text Processing Is So Useful 175 Searching for Files 176 Clipping Logs 177 Sifting through Mail 178 Navigating the File System with the os Module 178 Try It Out: Listing Files and Playing with Paths 180 Try It Out: Searching for Files of a Particular Type 181 Try It Out: Refining a Search 183 Working with Regular Expressions and the re Module 184 Try It Out: Fun with Regular Expressions 186 Try It Out: Adding Tests 187 Summary 189 Exercises 189 Chapter 12: Testing 191 Assertions 191 Try It Out: Using Assert 192 Test Cases and Test Suites 193 Try It Out: Testing Addition 194 Try It Out: Testing Faulty Addition 195 Test Fixtures 196 Try It Out: Working with Test Fixtures 197 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xvii xviii Contents Putting It All Together with Extreme Programming 199 Implementing a Search Utility in Python 200 Try It Out: Writing a Test Suite First 201 Try It Out: A General-Purpose Search Framework 203 A More Powerful Python Search 205 Try It Out: Extending the Search Framework 206 Formal Testing in the Software Life Cycle 207 Summary 208 Chapter 13: Writing a GUI with Python 209 GUI Programming Toolkits for Python 209 PyGTK Introduction 210 pyGTK Resources 211 Creating GUI Widgets with pyGTK 213 Try It Out: Writing a Simple pyGTK Program 213 GUI Signals 214 GUI Helper Threads and the GUI Event Queue 216 Try It Out: Writing a Multithreaded pyGTK App 219 Widget Packing 222 Glade: a GUI Builder for pyGTK 223 GUI Builders for Other GUI Frameworks 224 Using libGlade with Python 225 A Glade Walkthrough 225 Starting Glade 226 Creating a Project 227 Using the Palette to Create a Window 227 Putting Widgets into the Window 228 Glade Creates an XML Representation of the GUI 230 Try It Out: Building a GUI from a Glade File 231 Creating a Real Glade Application 231 Advanced Widgets 238 Further Enhancing PyRAP 241 Summary 248 Exercises 248 Chapter 14: Accessing Databases 249 Working with DBM Persistent Dictionaries 250 Choosing a DBM Module 250 Creating Persistent Dictionaries 251 Try It Out: Creating a Persistent Dictionary 251 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xviii xix Contents Accessing Persistent Dictionaries 252 Try It Out: Accessing Persistent Dictionaries 253 Deciding When to Use DBM and When to Use a Relational Database 255 Working with Relational Databases 255 Writing SQL Statements 257 Defining Tables 259 Setting Up a Database 260 Try It Out: Creating a Gadfly Database 261 Using the Python Database APIs 262 Downloading Modules 263 Creating Connections 263 Working with Cursors 264 Try It Out: Inserting Records 264 Try It Out: Writing a Simple Query 266 Try It Out: Writing a Complex Join 267 Try It Out: Updating an Employee’s Manager 269 Try It Out: Removing Employees 270 Working with Transactions and Committing the Results 271 Examining Module Capabilities and Metadata 272 Handling Errors 272 Summary 273 Exercises 274 Chapter 15: Using Python for XML 275 What Is XML? 275 A Hierarchical Markup Language 275 A Family of Standards 277 What Is a Schema/DTD? 278 What Are Document Models For? 278 Do You Need One? 278 Document Type Definitions 278 An Example DTD 278 DTDs Aren’t Exactly XML 280 Limitations of DTDs 280 Schemas 280 An Example Schema 280 Schemas Are Pure XML 281 Schemas Are Hierarchical 281 Other Advantages of Schemas 281 Schemas Are Less Widely Supported 281 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xix xx Contents XPath 282 HTML as a Subset of XML 282 The HTML DTDs 283 HTMLParser 283 Try It Out: Using HTMLParser 283 htmllib 284 Try It Out: Using htmllib 284 XML Libraries Available for Python 285 Validating XML Using Python 285 What Is Validation? 286 Well-Formedness versus Validation 286 Available Tools 286 Try It Out: Validation Using xmlproc 286 What Is SAX? 287 Stream-based 288 Event-driven 288 What Is DOM? 288 In-memory Access 288 Why Use SAX or DOM 289 Capability Trade-Offs 289 Memory Considerations 289 Speed Considerations 289 SAX and DOM Parsers Available for Python 289 PyXML 290 xml.sax 290 xml.dom.minidom 290 Try It Out: Working with XML Using DOM 290 Try It Out: Working with XML Using SAX 292 Intro to XSLT 293 XSLT Is XML 293 Transformation and Formatting Language 293 Functional,Template-Driven 293 Using Python to Transform XML Using XSLT 294 Try It Out: Transforming XML with XSLT 294 Putting It All Together: Working with RSS 296 RSS Overview and Vocabulary 296 Making Sense of It All 296 RSS Vocabulary 297 An RSS DTD 297 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xx xxi Contents A Real-World Problem 297 Try It Out: Creating an RSS Feed 298 Creating the Document 300 Checking It Against the DTD 301 Another Real-World Problem 301 Try It Out: Creating An Aggregator 301 Summary 303 Exercises 303 Chapter 16: Network Programming 305 Try It Out: Sending Some E-mail 305 Understanding Protocols 307 Comparing Protocols and Programming Languages 307 The Internet Protocol Stack 308 A Little Bit About the Internet Protocol 309 Internet Addresses 309 Internet Ports 310 Sending Internet E-mail 311 The E-mail File Format 311 MIME Messages 313 MIME Encodings: Quoted-printable and Base64 313 MIME Content Types 314 Try It Out: Creating a MIME Message with an Attachment 315 MIME Multipart Messages 316 Try It Out: Building E-mail Messages with SmartMessage 320 Sending Mail with SMTP and smtplib 321 Try It Out: Sending Mail with MailServer 323 Retrieving Internet E-mail 323 Parsing a Local Mail Spool with mailbox 323 Try It Out: Printing a Summary of Your Mailbox 324 Fetching Mail from a POP3 Server with poplib 325 Try It Out: Printing a Summary of Your POP3 Mailbox 327 Fetching Mail from an IMAP Server with imaplib 327 Try It Out: Printing a Summary of Your IMAP Mailbox 329 IMAP’s Unique Message IDs 330 Try It Out: Fetching a Message by Unique ID 330 Secure POP3 and IMAP 331 Webmail Applications Are Not E-mail Applications 331 Socket Programming 331 Introduction to Sockets 332 Try It Out: Connecting to the SuperSimpleSocketServer with Telnet 333 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxi xxii Contents Binding to an External Hostname 334 The Mirror Server 335 Try It Out: Mirroring Text with the MirrorServer 336 The Mirror Client 336 SocketServer 337 Multithreaded Servers 339 The Python Chat Server 340 Design of the Python Chat Server 340 The Python Chat Server Protocol 341 Our Hypothetical Protocol in Action 341 Initial Connection 342 Chat Text 342 Server Commands 342 General Guidelines 343 The Python Chat Client 346 Single-Threaded Multitasking with select 348 Other Topics 350 Miscellaneous Considerations for Protocol Design 350 Trusted Servers 350 Terse Protocols 350 The Twisted Framework 351 Deferred Objects 351 The Peer-to-Peer Architecture 354 Summary 354 Exercises 354 Chapter 17: Extension Programming with C 355 Extension Module Outline 356 Building and Installing Extension Modules 358 Passing Parameters from Python to C 360 Returning Values from C to Python 363 The LAME Project 364 The LAME Extension Module 368 Using Python Objects from C Code 380 Summary 383 Exercises 383 Chapter 18: Writing Shareware and Commercial Programs 385 A Case Study: Background 385 How Much Python Should You Use? 386 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxii xxiii Contents Pure Python Licensing 387 Web Services Are Your Friend 388 Pricing Strategies 389 Watermarking 390 Other Models 394 Selling as a Platform,Rather Than a Product 395 Your Development Environment 395 Finding Python Programmers 396 Training non-Python Programmers 397 Python Employment Resources 397 Python Problems 397 Porting to Other Versions of Python 397 Porting to Other Operating Systems 398 Debugging Threads 399 Common Gotchas 399 Portable Distribution 400 Essential Libraries 401 Timeoutsocket 401 PyGTK 402 GEOip 402 Summary 403 Chapter 19: Numerical Programming 405 Numbers in Python 405 Integers 406 Long Integers 406 Floating-point Numbers 407 Formatting Numbers 408 Characters as Numbers 410 Mathematics 412 Arithmetic 412 Built-in Math Functions 414 The math Module 415 Complex Numbers 416 Arrays 418 The array Module 420 The numarray Package 422 Using Arrays 422 Computing the Standard Deviation 423 Summary 424 Exercises 425 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxiii xxiv Contents Chapter 20: Python in the Enterprise 427 Enterprise Applications 428 Document Management 428 The Evolution of Document Management Systems 429 What You Want in a Document Management System 430 People in Directories 431 Taking Action with Workflow 432 Auditing,Sarbanes-Oxley,and What You Need to Know 433 Auditing and Document Management 434 Working with Actual Enterprise Systems 435 Introducing the wftk Workflow Toolkit 435 Try It Out: Very Simple Record Retrieval 436 Try It Out: Very Simple Record Storage 438 Try It Out: Data Storage in MySQL 439 Try It Out: Storing and Retrieving Documents 441 Try It Out: A Document Retention Framework 446 The python-ldap Module 448 Try It Out: Using Basic OpenLDAP Tools 449 Try It Out: Simple LDAP Search 451 More LDAP 453 Back to the wftk 453 Try It Out: Simple Workflow Trigger 454 Try It Out: Action Queue Handler 456 Summary 458 Exercises 458 Chapter 21: Web Applications and Web Services 459 REST: The Architecture of the Web 460 Characteristics of REST 460 A Distributed Network of Interlinked Documents 461 A Client-Server Architecture 461 Servers Are Stateless 461 Resources 461 Representations 462 REST Operations 462 HTTP: Real-World REST 463 Try It Out: Python’s Three-Line Web Server 463 The Visible Web Server 464 Try It Out: Seeing an HTTP Request and Response 465 The HTTP Request 466 The HTTP Response 467 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxiv xxv Contents CGI: Turning Scripts into Web Applications 468 Try It Out: Running a CGI Script 469 The Web Server Makes a Deal with the CGI Script 470 CGI’s Special Environment Variables 471 Accepting User Input through HTML Forms 473 The cgi Module: Parsing HTML Forms 474 Try It Out: Printing Any HTML Form Submission 478 Building a Wiki 480 The BittyWiki Core Library 481 Back-end Storage 481 WikiWords 481 Writing the BittyWiki Core 481 Try It Out: Creating Wiki Pages from an Interactive Python Session 483 The BittyWiki Web Interface 484 Resources 484 Request Structure 484 But Wait—There’s More (Resources) 485 Wiki Markup 486 Web Services 493 How Web Services Work 494 REST Web Services 494 REST Quick Start: Finding Bargains on Amazon.com 495 Try It Out: Peeking at an Amazon Web Services Response 496 Introducing WishListBargainFinder 497 Giving BittyWiki a REST API 500 Wiki Search-and-Replace Using the REST Web Service 503 Try It Out: Wiki Searching and Replacing 507 XML-RPC 508 XML-RPC Quick Start: Get Tech News from Meerkat 509 The XML-RPC Request 511 Representation of Data in XML-RPC 512 The XML-RPC Response 513 If Something Goes Wrong 513 Exposing the BittyWiki API through XML-RPC 514 Try It Out: Manipulating BittyWiki through XML-RPC 517 Wiki Search-and-Replace Using the XML-RPC Web Service 518 SOAP 520 SOAP Quick Start: Surfing the Google API 520 The SOAP Request 522 The SOAP Response 524 If Something Goes Wrong 524 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxv xxvi Contents Exposing a SOAP Interface to BittyWiki 525 Try It Out: Manipulating BittyWiki through SOAP 526 Wiki Search-and-Replace Using the SOAP Web Service 527 Documenting Your Web Service API 529 Human-Readable API Documentation 529 The BittyWiki REST API Document 529 The BittyWiki XML-RPC API Document 529 The BittyWiki SOAP API Document 530 The XML-RPC Introspection API 530 Try It Out: Using the XML-RPC Introspection API 530 WSDL 531 Try It Out: Manipulating BittyWiki through a WSDL Proxy 533 Choosing a Web Service Standard 534 Web Service Etiquette 535 For Consumers of Web Services 535 For Producers of Web Services 535 Using Web Applications as Web Services 536 A Sampling of Publicly Available Web Services 536 Summary 538 Exercises 538 Chapter 22: Integrating Java with Python 539 Scripting within Java Applications 540 Comparing Python Implementations 541 Installing Jython 541 Running Jython 542 Running Jython Interactively 542 Try It Out: Running the Jython Interpreter 542 Running Jython Scripts 543 Try It Out Running a Python Script 543 Controlling the jython Script 544 Making Executable Commands 545 Try It Out: Making an Executable Script 546 Running Jython on Your Own 546 Packaging Jython-Based Applications 547 Integrating Java and Jython 547 Using Java Classes in Jython 548 Try It Out: Calling on Java Classes 548 Try It Out: Creating a User Interface from Jython 550 Accessing Databases from Jython 552 Working with the Python DB API 553 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xxvi xxvii Contents Setting Up a Database 554 Try It Out: Create Tables 555 Writing J2EE Servlets in Jython 558 Setting Up an Application Server 559 Adding the PyServlet to an Application Server 560 Extending HttpServlet 561 Try It Out: Writing a Python Servlet 562 Choosing Tools for Jython 564 Testing from Jython 565 Try It Out: Exploring Your Environment with Jython 565 Embedding the Jython Interpreter 566 Calling Jython Scripts from Java 566 Try It Out: Embedding Jython 567 Compiling Python Code to Java 568 Handling Differences between C Python and Jython 569 Summary 570 Exercises 571 Appendix A: Answers to Exercises 573 Appendix B: Online Resources 605 Appendix C: What’s New in Python 2.4 609 Glossary 613 Index 623 Contents Acknowledgments xxix Introduction xxxi Chapter 1: Programming Basics and Strings 1 How Programming Is Different from Using a Computer 1 Programming Is Consistency 2 Programming Is Control 2 Programming Copes with Change 2 What All That Means Together 3 The First Steps 3 Starting codeEditor 3 Using codeEditor’s Python Shell 4 Try It Out: Starting the Python Shell 4 Beginning to Use Python—Strings 5 What Is a String? 5 Why the Quotes? 6 Try It Out: Entering Strings with Different Quotes 6 Understanding Different Quotes 6 Putting Two Strings Together 8 Try It Out: Using + to Combine Strings 8 Putting Strings Together in Different Ways 9 Try It Out: Using a Format Specifier to Populate a String 9 Try It Out: More String Formatting 9 Displaying Strings with Print 10 Try It Out: Printing Text with Print 10 Summary 10 Exercises 11 Chapter 2: Numbers and Operators 13 Different Kinds of Numbers 13 Numbers in Python 14 Try It Out: Using Type with Different Numbers 14 Try It Out: Creating an Imaginary Number 15 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xi xii Contents Program Files 15 Try It Out: Using the Shell with the Editor 16 Using the Different Types 17 Try It Out Including Different Numbers in Strings 18 Try It Out: Escaping the % Sign in Strings 18 Basic Math 19 Try It Out Doing Basic Math 19 Try It Out: Using the Modulus Operation 20 Some Surprises 20 Try It Out: Printing the Results 21 Using Numbers 21 Order of Evaluation 21 Try It Out: Using Math Operations 21 Number Formats 22 Try It Out: Using Number Formats 22 Mistakes Will Happen 23 Try It Out: Making Mistakes 23 Some Unusual Cases 24 Try It Out: Formatting Numbers as Octal and Hexadecimal 24 Summary 24 Exercises 25 Chapter 3: Variables—Names for Values 27 Referring to Data – Using Names for Data 27 Try It Out: Assigning Values to Names 28 Changing Data Through Names 28 Try It Out: Altering Named Values 29 Copying Data 29 Names You Can’t Use and Some Rules 29 Using More Built-in Types 30 Tuples—Unchanging Sequences of Data 30 Try It Out: Creating and Using a Tuple 30 Try It Out: Accessing a Tuple Through Another Tuple 31 Lists—Changeable Sequences of Data 33 Try It Out Viewing the Elements of a List 33 Dictionaries—Groupings of Data Indexed by Name 34 Try It Out: Making a Dictionary 34 Try It Out: Getting the Keys from a Dictionary 35 Treating a String Like a List 36 Special Types 38 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xii xiii Contents Other Common Sequence Properties 38 Referencing the Last Elements 38 Ranges of Sequences 39 Try It Out: Slicing Sequences 39 Growing Lists by Appending Sequences 40 Using Lists to Temporarily Store Data 40 Try It Out: Popping Elements from a List 40 Summary 41 Exercises 42 Chapter 4: Making Decisions 43 Comparing Values—Are They the Same? 43 Try It Out: Comparing Values for Sameness 43 Doing the Opposite—Not Equal 45 Try It Out: Comparing Values for Difference 45 Comparing Values—Which One Is More? 45 Try It Out: Comparing Greater Than and Less Than 45 More Than or Equal,Less Than or Equal 47 Reversing True and False 47 Try It Out: Reversing the Outcome of a Test 47 Looking for the Results of More Than One Comparison 48 How to Get Decisions Made 48 Try It Out: Placing Tests within Tests 49 Repetition 51 How to Do Something—Again and Again 51 Try It Out: Using a while Loop 51 Stopping the Repetition 52 Try It Out: Using else While Repeating 54 Try It Out: Using continue to Keep Repeating 54 Handling Errors 55 Trying Things Out 55 Try It Out: Creating an Exception with Its Explanation 56 Summary 57 Exercises 58 Chapter 5: Functions 59 Putting Your Program into Its Own File 59 Try It Out: Run a Program with Python -i 61 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xiii xiv Contents Functions: Grouping Code under a Name 61 Try It Out: Defining a Function 61 Choosing a Name 62 Describing a Function in the Function 63 Try It Out: Displaying __doc__ 63 The Same Name in Two Different Places 64 Making Notes to Yourself 65 Try It Out: Experimenting with Comments 65 Asking a Function to Use a Value You Provide 66 Try It Out Invoking a Function with Parameters 67 Checking Your Parameters 68 Try It Out: Determining More Types with the type Function 69 Try It Out: Using Strings to Compare Types 69 Setting a Default Value for a Parameter—Just in Case 70 Try It Out: Setting a Default Parameter 70 Calling Functions from within Other Functions 71 Try It Out: Invoking the Completed Function 72 Functions Inside of Functions 72 Flagging an Error on Your Own Terms 73 Layers of Functions 74 How to Read Deeper Errors 74 Summary 75 Exercises 76 Chapter 6: Classes and Objects 79 Thinking About Programming 79 Objects You Already Know 79 Looking Ahead: How You Want to Use Objects 81 Defining a Class 81 How Code Can Be Made into an Object 81 Try It Out: Defining a Class 82 Try It Out: Creating an Object from Your Class 82 Try It Out: Writing an Internal Method 84 Try It Out: Writing Interface Methods 85 Try It Out: Using More Methods 87 Objects and Their Scope 89 Try It Out: Creating Another Class 89 Summary 92 Exercises 93 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xiv xv Contents Chapter 7: Organizing Programs 95 Modules 96 Importing a Module So That You Can Use It 96 Making a Module from Pre-existing Code 97 Try It Out: Creating a Module 97 Try It Out: Exploring Your New Module 98 Using Modules—Starting With the Command Line 99 Try It Out: Printing sys.argv 100 Changing How Import Works—Bringing in More 101 Packages 101 Try It Out: Making the Files in the Kitchen Class 102 Modules and Packages 103 Bringing Everything into the Current Scope 103 Try It Out: Exporting Modules from a Package 104 Re-importing Modules and Packages 104 Try It Out: Examining sys.modules 105 Basics of Testing Your Modules and Packages 106 Summary 106 Exercises 107 Chapter 8: Files and Directories 109 File Objects 109 Writing Text Files 110 Reading Text Files 111 Try It Out: Printing the Lengths of Lines in the Sample File 112 File Exceptions 113 Paths and Directories 113 Paths 114 Directory Contents 116 Try It Out: Getting the Contents of a Directory 116 Try It Out: Listing the Contents of Your Desktop or Home Directory 118 Obtaining Information about Files 118 Recursive Directory Listings 118 Renaming,Moving,Copying,and Removing Files 119 Example: Rotating Files 120 Creating and Removing Directories 121 Globbing 122 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xv xvi Contents Pickles 123 Try It Out: Creating a Pickle File 123 Pickling Tips 124 Efficient Pickling 125 Summary 125 Exercises 125 Chapter 9: Other Features of the Language 127 Lambda and Filter: Short Anonymous Functions 127 Reduce 128 Try It Out: Working with Reduce 128 Map: Short-Circuiting Loops 129 Try It Out: Use Map 129 Decisions within Lists—List Comprehension 130 Generating Lists for Loops 131 Try It Out: Examining an xrange Object 132 Special String Substitution Using Dictionaries 133 Try It Out: String Formatting with Dictionaries 133 Featured Modules 134 Getopt—Getting Options from the Command Line 134 Using More Than One Process 137 Threads—Doing Many Things in the Same Process 139 Storing Passwords 140 Summary 141 Exercises 142 Chapter 10: Building a Module 143 Exploring Modules 143 Importing Modules 145 Finding Modules 145 Digging through Modules 146 Creating Modules and Packages 150 Try It Out: Creating a Module with Functions 150 Working with Classes 151 Defining Object-Oriented Programming 151 Creating Classes 151 Try It Out: Creating a Meal Class 152 Extending Existing Classes 153 02_596543 ftoc.qxd 6/29/05 10:55 PM Page xvi
Version V6.48 (2019-07-26) Added flash programming support for AmbiqMicro's AMA2B1KK (Apollo2 Blue; AMA2BEVB). Added flash programming support for AmbiqMicro's AMA2B1KK (Apollo2 Blue; AMA2BEVB). Added unlocking support for Microchip SAML10 series devices. Added unlocking support for Microchip SAML10 series devices. Analog Devices ADUCM355: Reset could not be overwritten using a J-Link script file. Fixed. CCS plugin: Added a new option which allows configuring a J-Link script file (project dependent). Commander: "erase" did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. Commander: "erase" did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. DLL Updater (internal): Added Infineons Micro Inspector. DLL Updater (internal): Added Infineons Micro Inspector. DLL: STM32WB55 added support for Co-Processor Wireless stack upgrade. DLL: Added Flash programming support for CYT2B9 series devices. DLL: Added Flash programming support for CYT2B9 series devices. DLL: Added Flash programming support for Cypress Traveo2 CYT2B and CYT4B series devices. DLL: Added Flash programming support for Cypress Traveo2 CYT2B and CYT4B series devices. DLL: Added OTP flash programming support for TI's RM42L device family. DLL: Added OTP flash programming support for TI's RM44L device family. DLL: Added OTP flash programming support for TI's RM46L device family. DLL: Added OTP flash programming support for TI's RM48L device family. DLL: Added flash programming support for Panasonic MN1M7BFxx and MN1M7AFxx series devices. DLL: Added flash programming support for Panasonic MN1M7BFxx and MN1M7AFxx series devices. DLL: Added flash programming support for ST STM32G47xx series devices. DLL: Added flash programming support for ST STM32G4xx series devices. DLL: Added flash programming support for ST STM32G4xx series devices. DLL: Added flash programming support for STM32H745, STM32H755, STM32H747 and STM32H757 series devices. DLL: Added flash programming support for STM32H745, STM32H755, STM32H747 and STM32H757 series devices. DLL: Added flash programming support for WIZnet W7500 series device. DLL: Added flash programming support for WIZnet W7500 series device. DLL: Added native trace buffer support for Renesas RZ/A2M series. DLL: Added support for Cypress CYT2B series devices Cortex-M4. DLL: Added support for Cypress CYT4B series devices Cortex-M7_0 and Cortex-M7_1. DLL: Added support for Cypress MB9DF / MB9EF series (FCR4) devices. DLL: Added support for RISC-V behind a DAP as setup. DLL: Added support for RISC-V via SWD for RISC-V behind a DAP setups. DLL: Added support for SPI FLash Adesto ATXP128/ATXP128R to SPIFI-Lib for indirect flash programming. DLL: Added support for SPI FLash Adesto ATXP128/ATXP128R to SPIFI-Lib for indirect flash programming. DLL: Added support for command string "CORESIGHT_SetCoreBaseAddr" DLL: Cypress PSoC4 family: Under special circumstances, unlock did not work. Fixed. DLL: Cypress PSoC4 family: Under special circumstances, unlock did not work. Fixed. DLL: Flash programming sector sizes corrected for Traveo2 CYT4B series devices. DLL: Flash programming sector sizes corrected for Traveo2 CYT4B series devices. DLL: For the MPC560xx devices, the ECC SRAM was not initialized after connect. Fixed. DLL: Hilscher NetX90 flash bank size, fixed. DLL: Infineon TLE98xx: Some J-Link LITEs could not connect establish a successful target connection due to missing firmware functionality. Fixed. DLL: JTAG: When only having 1 TAP in the JTAG chain and its matches the one for the configured CPU core but the TAP-ID was unknown, connect did not work. Fixed. DLL: Linux: Delayed / slowed execution of certain API functions when using J-Link via USB (e.g. on Close()). Introduced in V6.46. Fixed. DLL: Linux: When calling a J-Link application via the global symlink (e.g. "JLinkExe" instead of "./JLinkExe"), sometimes the JLinkDevices.xml file was not found. Fixed. DLL: Linux: When calling a J-Link application via the global symlink (e.g. "JLinkExe" instead of "./JLinkExe"), sometimes the libjlink* shared library was not found. Fixed. DLL: Microchip J-32 OEM probes could not support legacy Atmel devices. Fixed. DLL: Minor bug in flash programming algorithm for STM32G0xx series devices, fixed. DLL: NXP KW34: Added flash programming support for the program and data flash area. DLL: NXP KW34: Added flash programming support for the program and data flash area. DLL: NXP KW35 / KW36 / KW38 / KW39: Added flash programming support for the data flash area. DLL: NXP KW35 / KW36 / KW38 / KW39: Added flash programming support for the data flash area. DLL: NXP KW38: Corrected device names showen in the device selection dialog. DLL: NXP KW38: Corrected device names showen in the device selection dialog. DLL: NXP KW3x family: Improved flash programming speed significantly. DLL: NXP KW3x family: Improved flash programming speed significantly. DLL: NXP LPC18xx / LPC43xx: After QSPI flash programming, the QSPI flash memory was no longer memory mapped accessible. Introduced in V6.41. Fixed. DLL: Open flash loaders for RISC-V did not work properly anymore (introduced with V6.46). Fixed. DLL: Programming issue while another application is already running on Hilscher NetX90, fixed. DLL: QSPI flash programming: When the QE bit was set before flash programming, it has been cleared but not restored by the DLL. Introduced in V6.46h. Fixed. DLL: Qorvo GP570 / UE878 / QPG6 family: Flash programming did not work in recent silicon revisions. Fixed. DLL: Qorvo GPxxx: Under special circumstances, flash programming did not work. Fixed. DLL: RAM size of ST STM32F412 series devices, fixed. DLL: RISC-V behind a DAP: Setting system variables , , from J-Link script files did not have any effect for RISC-V behind a DAP. Fixed. DLL: RISC-V behind a DAP: Setting system variables , , from J-Link script files did not have any effect for RISC-V behind a DAP. Fixed. DLL: RISC-V: Added reset type "Reset Pin" to explicitly allow resetting the target via the reset pin, instead of the bit DLL: RISC-V: Changed default reset type from reset pin to to support reset on almost all systems, also ones that do not populate a reset pin DLL: RISC-V: Interrupts were not disabled correctly during flash programming for built-in flash algos (works well for open flash loaders). Fixed. DLL: RISC-V: Reset could fail with "core did not halt after reset" even if the core halted correctly. Fixed. DLL: Re-attaching to existing debug session after connecting and disconnecting once via TELNET (e.g. used by RTTClient and RTTViewer) did not work properly. Fixed. DLL: Renesas R5F51306 (RX130) devices were not detected by the J-Link DLL. Fixed. DLL: Renesas RX231: OFS1 could not be modified. Fixed. DLL: Renesas RX: Added support for RX66N series devices DLL: Renesas RX: Added support for RX72M series devices DLL: Renesas RX: Added support for RX72M series devices DLL: Renesas RX: Added support for RX72N series devices DLL: Renesas RX: Added support for RX72T series devices DLL: Renesas RX: Added support for RX72T series devices DLL: Renesas RX: RX66T: Programming of option-setting memory (OSIS) did not work properly. Fixed. DLL: Renesas RX: When connecting to locked RX devices via JTAG (does not affect FINE!), 16-byte IDCODE (OSIS) could be rejected even though the correct code was given. Fixed. DLL: Renesas S7G2: QSPI flash programming did not work for QSPI flashes >= 16MB. Fixed. DLL: Resets during halt of TI RM57L843ZWT device, due to running watchdog, fixed. Enabled cross trigger interfaces to forward debug acknowledge signal to Watchdog. DLL: SPI-Flash programming for Spansion S25FL256L, fixed. DLL: STM32L031K6 secure chip did not work. Fixed. DLL: STM32WB55 added support for Co-Processor Wireless stack upgrade. DLL: TI RM42L420 added EEPROM support. DLL: TI RM44L520/RM44L920 added flash and EEPROM support DLL: TI RM57L843ZWT added EEPROM support. DLL: TI RM57L843ZWT added EEPROM support. DLL: Under some circumstances Flash Cache was not cleaned after erase operations. DLL: Unsecure read protection for STM32L151xx series devices, fixed. DLL: Unsecure write protection for STM32L151xxx series devices, fixed. DLL: When using J-Trace PRO with IAR EWARM a "failed to allocate x bytes of memory" error could occur. Fixed. DLL: Windows: Renesas RX: When using FINE interface and disabling ongoining debug mode on debug session close, it could happen that a thread was not exited gracefully, causing handle leaks. Fixed. DLL: macOS: When calling a J-Link application via the global symlink (e.g. "JLinkExe" instead of "./JLinkExe"), sometimes the libjlink* shared library was not found. Fixed. Firmware: Flasher ARM / PRO / Portable PLUS: Chip erase could fail in stand-alone mode. Fixed. Firmware: Flasher ARM / PRO / Portable PLUS: Parallel CFI NOR Flash memory programming could fail under special circumstances. Fixed. Firmware: Flasher ARM / PRO / Portable PLUS: Stand-alone mode did not work for some devices from Analog Devices (e.g. ADuCM7023). Fixed. Firmware: Flasher ARM / PRO: FWrite command was unable to receive 512 bytes via UART at once. Fixed. Firmware: Flasher ARM V4: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: Flasher ARM/PPC/RX/PRO: Target power supply monitoring could erroneously detect an over-current. Fixed. Firmware: Flasher PRO: Open flash loaders for RISC-V did not work properly anymore (introduced with V6.46). Fixed. Firmware: Flasher PRO: Universal Flash Loader mode detection in batch mode did not work. Fixed. Firmware: Flasher PRO: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: Flasher Portable PLUS did not show the correct status under special circumstances. Fixed. Firmware: Flasher Portable PLUS did not work in J-Link Mode while showing "OK" message. Fixed. Firmware: Flasher Portable PLUS: Universal Flash Loader mode detection in batch mode did not work. Fixed. Firmware: Flasher Portable PLUS: Number of bytes to program was not calculate correctly, progress bar showed wrong percentage. Fixed. Firmware: Flasher Portable PLUS: Open flash loaders for RISC-V did not work properly anymore (introduced with V6.46). Fixed. Firmware: Flasher Portable PLUS: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link EDU Mini: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link EDU Mini: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link EDU/BASE/PLUS V10: Added support for RISC-V behind a DAP as setup. Firmware: J-Link EDU/BASE/PLUS V10: Increased heap size of firmware (Added support for heap over multiple memory ranges with gaps between them) Firmware: J-Link EDU/BASE/PLUS V10: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link EDU/BASE/PLUS V10: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link EDU/BASE/PLUS V10: SWO: Under very special circumstances it could happen that the 1st byte received on SWO was swallowed. Only happened, if SWO pin was used for something else between SWO_Stop() and SWO_Start(). Fixed. Firmware: J-Link EDU/BASE/PLUS V10: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link OB-K22-SiFive: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link PRO V4: Added support for RISC-V behind a DAP as setup. Firmware: J-Link PRO V4: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link PRO V4: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link PRO V4: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link PRO V4: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Link ULTRA+ V4: Added support for RISC-V behind a DAP as setup. Firmware: J-Link ULTRA+ V4: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link ULTRA+ V4: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link ULTRA+ V4: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link ULTRA+ V4: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Link-OB-K22-SiFive: Linux: When using both VCOM ports extensively under special circumstances it could happen that the USB communication locked up. Fixed. Firmware: J-Trace PRO V1 Cortex-M: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Trace PRO V2 Cortex-M: Corrected typo on th webserver trace configuration page. Firmware: J-Trace PRO V2 Cortex-M: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Trace PRO V2 Cortex: Corrected typo on th webserver trace configuration page. Firmware: J-Trace PRO V2 Cortex: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Flasher ARM / PRO / Portable PLUS: Init/Exit step BNE and BEQ could jump to #step + 1. Fixed. Flasher ARM / PRO / Portable PLUS: Open Flashloader RAMCodes in stand-alone-mode can be >12kB now. Flasher ARM / PRO / Portable PLUS: Stand-alone mode did not work for some ARM devices. Introduced in V6.47b. Fixed. Flasher ARM / PRO: Reading or writing memory in J-Link mode via JTAG caused the firmware to hang and report a USB timeout. Fixed. Flasher: Added stand-alone mode support for Traveo2 CYT2B and CYT4B devices. Flasher: Added stand-alone mode support for Traveo2 CYT2B and CYT4B devices. GDBServer: Under special circumstances, a remote "g" packet error popped up when using the GDBServer with Cortex-AR or MIPS. Fixed. GUI applications (Linux): The directory the application was executed from affected the behavior of the application. Fixed. J-Flash Lite: Updated to select the flash base address of the selected device by default as "Prog. Addr." instead of always 0x00000000. J-Flash Lite: Updated to select the flash base address of the selected device by default as "Prog. Addr." instead of always 0x00000000. J-Flash SPI: Added flash programming support for ISSI IS25LP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25LP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25LP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25LP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP128D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP128D SPI Flash. J-Flash SPI: Licenses that have been burned into J-Link via J-Link Commander "license add" command were not detected properly. Fixed. J-Flash: Generated data files could be unnecessarily big. Fixed. J-Flash: Generated data files could be unnecessarily big. Fixed. J-Flash: Improved error messages during the check, if the data fits into the flash memory. J-Flash: Improved error messages during the check, if the data fits into the flash memory. J-Flash: Licenses that have been burned into J-Link via J-Link Commander "license add" command were not detected properly. Fixed. J-Link BASE/EDU/PLUS: SPI flash programming with J-Flash SPI was very slow. Fixed. J-Link Commander: RISC-V: Added to the list of suggested/available interfaces JFlash: Added command line parameter "?" (Same functionality as "-?"). JFlash: Added command line parameter "?" (Same functionality as "-?"). JFlashSPI: Added SPI flash programming support for ISSI IS25LP016D SPI flash. JFlashSPI: Added SPI flash programming support for ISSI IS25LP016D SPI flash. JFlashSPI_CL: Added command line parameter "?" (Same functionality as "-?"). JFlashSPI_CL: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTClient: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTClient: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTLogger: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTLogger: Added command line parameter "?" (Same functionality as "-?"). JLinkSTR91x: Added command line parameter "?" (Same functionality as "-?") and implemented "help" functionality which returns the available command line parameters. JLinkSTR91x: Added command line parameter "?" (Same functionality as "-?") and implemented "help" functionality which returns the available command line parameters. JTAGLoad: Added command line parameters "?" and "-?" (Same functionality as "/?"). JTAGLoad: Added command line parameters "?" and "-?" (Same functionality as "/?"). PCodes: Changed an ambiguous J-Link report output. PCodes: Resolved an issue where some Cypress PSoC4 devices would not unlock automatically when connecting to them. Fixed. Package: USB driver for VCOM: Under very special circumstances bluescreens could occur when using VCOM. Fixed. (Driver update only applies to Windows Vista and later. Windows XP still uses the old driver as the new one is not compatible to Windows XP anymore) RTTClient: Connecting to existing session did not work correctly on MacOS. Fixed. RTTClient: Linux: Ubuntu: Attaching to existing debug session did not work properly. Fixed. RTTLogger (Linux): Using logrotate lead to null characters being printed before RTT data. Fixed., RTTViewer: Added 'All terminals' message in case of connection loss. RTTViewer: Added information display on how to correctly enter RTT control block search range. RTTViewer: Echo to Terminal 0 / 'All terminals' was not working correctly. Fixed. RTTViewer: Fixed 'Attach to existing session' mode for Windows, MacOS and Linux. RTTViewer: Fixed typo. RTTViewer: Improved J-Link connect/ disconnect sequence. RTTViewer: Improved handling for data logging. RTTViewer: Improved handling for terminal logging. RTTViewer: Improved log messages when connecting to J-Link. RTTViewer: Improved log output. RTTViewer: Improved reconnecting for attach mode. RTTViewer: Improved the handling in case reading of RTT data failed. RTTViewer: In some occasions, the CL option '--autoconnect' did not work. Fixed. RTTViewer: In some rare occasions, clearing a terminal could crash the application. Fixed. RTTViewer: Linux: Ubuntu: Option "Attaching to existing debug session" did not work properly. Fixed. RTTViewer: Some ANSI CSI sequences caused the application to crash. Fixed. RTTViewer: The '--autoconnect' CL option caused the application to crash. Fixed. RemoteServer: Command line options '-select USB=' and '-SelectEmuBySN ' did not work correctly. Fixed. SDK (Windows): Linking against the *.lib files with MinGW did throw errors reg. undefined references to "__security_check_cookie" and "__GSHandlerCheck". Fixed. SDK: JLINKARM_EraseChip() did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. SDK: JLINKARM_EraseChip() did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. Trace: Under certain circumstances backtrace was not showing for targets with PTM. Fixed. UM08002: Chapter "Python support" added. UM08002: Chapter "Python support" updated. Section "API Functions": Added "FlashDownload" description

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值